Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create maintenance on Zabbix 6 #637

Closed
polcape opened this issue Feb 20, 2022 · 7 comments · Fixed by #665
Closed

Can't create maintenance on Zabbix 6 #637

polcape opened this issue Feb 20, 2022 · 7 comments · Fixed by #665

Comments

@polcape
Copy link
Contributor

polcape commented Feb 20, 2022

SUMMARY

Launch creation of maintenance failed

ISSUE TYPE
  • Bug Report
COMPONENT NAME

Zabbix maintenance

ANSIBLE VERSION
ansible [core 2.12.2]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.6 (default, Nov  9 2021, 13:31:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)]
  jinja version = 3.0.3
  libyaml = True

CONFIGURATION
OS / ENVIRONMENT / Zabbix Version

Zabbix version 6
Os Rocky Linux 8.5
Python 3.9

STEPS TO REPRODUCE

Launch playbook to create maintenance I get this error, seems cast error on time string

- hosts: server
  tasks:
  - name: Test
    community.zabbix.zabbix_maintenance:
      name: Test
      host_groups:
        - Test
      state: present
      collect_data: yes
      server_url: https://zabbix
      login_user: xxx
      login_password: xxx
EXPECTED RESULTS

Maintenance created without error

ACTUAL RESULTS

I get this error

fatal: [server]: FAILED! => {"changed": false, "msg": "Failed to create maintenance: (u'Error -32602: Invalid params., Invalid parameter \"/1/active_since\": an unsigned integer is expected. while sending {\"params\": {\"maintenance_type\": 0, \"active_since\": \"1645364880.0\", \"active_till\": \"1645365660.0\", \"groupids\": [\"32\"], \"timeperiods\": [{\"timeperiod_type\": \"0\", \"start_date\": \"1645365060.0\", \"period\": \"600\"}], \"description\": \"Created by Ansible\", \"hostids\": [], \"name\": \"Test\"}, \"jsonrpc\": \"2.0\", \"method\": \"maintenance.create\", \"auth\": \"dd0f5d574072ce6bc66d511b\", \"id\": 4}', -32602)"}
@polcape
Copy link
Contributor Author

polcape commented Feb 20, 2022

I solved to change the line 311 of zabbix_maintenance.py of this collection from this

    start_time =  time.mktime(now.timetuple())

to this

    start_time =  int(time.mktime(now.timetuple()))

@gmueller2000privat
Copy link

Any plans to fix this in the next release?

@dj-wasabi
Copy link
Contributor

Hi @polcape

Are you able to create a PR for this? Thank you! 👍

polcape added a commit to polcape/community.zabbix that referenced this issue Apr 5, 2022
Change to int cast as discussed here ansible-collections#637
@polcape
Copy link
Contributor Author

polcape commented Apr 5, 2022

Hi @dj-wasabi,
done with #665

@gmueller2000privat
Copy link

browsing through the code I think this change is not enough. At least update_maintenance needs also this change or could you please try this?

@polcape
Copy link
Contributor Author

polcape commented Apr 5, 2022

Probably @gmueller2000privat , in my script I am using only create_maintenance

@D3DeFi
Copy link
Contributor

D3DeFi commented Apr 8, 2022

browsing through the code I think this change is not enough. At least update_maintenance needs also this change or could you please try this?

@gmueller2000privat start_time is propagated to both create_maintenance and update_maintenance method calls. Do you happen to still get error when updating maintenance with the patch from @polcape ?

D3DeFi pushed a commit that referenced this issue Apr 8, 2022
Change to int cast as discussed here #637
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants