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

Bgmot modules zabbix70 #1273

Merged
merged 18 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env_srv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ZBX_ENABLEGLOBALSCRIPTS=1
2 changes: 1 addition & 1 deletion .github/workflows/plugins-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
matrix:
zabbix_container:
- version: "6.0"
- version: "6.2"
- version: "6.4"
- version: "7.0"
ansible:
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-changelogs
- stable-2.15
Expand Down
5 changes: 5 additions & 0 deletions changelogs/fragments/zabbix70_modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
breaking_changes:
- Remove support for Zabbix 6.2
minor_changes:
- zabbix_discovery_rule, zabbix_group_events_info, zabbix_host, zabbix_host_events_info, zabbix_proxy, zabbix_proxy_info modules updated to work wih Zabbix 7.0
- added new module zabbix_proxy_group (Zabbix 7.0)
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ services:
- "zabbix-db"
links:
- "zabbix-db"
env_file:
- ./.env_srv
zabbix-web:
image: zabbix/zabbix-web-nginx-pgsql:ubuntu-${zabbix_version}-latest
environment:
Expand Down
23 changes: 17 additions & 6 deletions plugins/modules/zabbix_discovery_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,18 @@ def get_proxy_by_proxy_name(self, proxy_name):
proxy matching proxy name
"""
try:
proxy_list = self._zapi.proxy.get({
"output": "extend",
"selectInterface": "extend",
"filter": {"host": [proxy_name]}
})
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
proxy_list = self._zapi.proxy.get({
"output": "extend",
"selectInterface": "extend",
"filter": {"host": [proxy_name]}
})
else:
proxy_list = self._zapi.proxy.get({
"output": "extend",
"filter": {"name": [proxy_name]}
})

if len(proxy_list) < 1:
self._module.fail_json(msg="Proxy not found: %s" % proxy_name)
else:
Expand All @@ -458,7 +465,11 @@ def _construct_parameters(self, **kwargs):
"dchecks": kwargs["dchecks"]
}
if kwargs["proxy"]:
_params["proxy_hostid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
_params["proxy_hostid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]
else:
_params["proxyid"] = self.get_proxy_by_proxy_name(kwargs["proxy"])["proxyid"]

return _params

def check_difference(self, **kwargs):
Expand Down
17 changes: 12 additions & 5 deletions plugins/modules/zabbix_group_events_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
description: acknowledges informations
type: complex
contains:
alias:
username:
description: Account who acknowledge
type: str
clock:
Expand Down Expand Up @@ -208,6 +208,9 @@
from ansible.module_utils.basic import AnsibleModule

from ansible_collections.community.zabbix.plugins.module_utils.base import ZabbixBase

from ansible.module_utils.compat.version import LooseVersion

import ansible_collections.community.zabbix.plugins.module_utils.helpers as zabbix_utils


Expand All @@ -228,10 +231,14 @@ def get_triggers_by_group_id_in_problem_state(self, group_id, trigger_severity):
def get_last_event_by_trigger_id(self, triggers_id):
""" Get the last event from triggerid"""
output = ["eventid", "clock", "acknowledged", "value"]
select_acknowledges = ["clock", "alias", "message"]
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"select_acknowledges": select_acknowledges, "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
if LooseVersion(self._zbx_api_version) < LooseVersion("7.0"):
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"select_acknowledges": "extend", "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
else:
event = self._zapi.event.get({"output": output, "objectids": triggers_id,
"selectAcknowledges": "extend", "limit": 1, "sortfield": "clock",
"sortorder": "DESC"})
return event[0]


Expand Down
Loading
Loading