Skip to content

Commit

Permalink
fix: add support for Zabbix API v6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mstyushin committed Apr 4, 2024
1 parent 718d958 commit 42c3eb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/mamonsu-tests-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ jobs:
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.2.9'
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.4.13'
exclude:
- docker_os: 'centos:8'
pg_version: '12'
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/mamonsu-tests-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.2.9'
- docker_os: 'centos:8'
pg_version: '16'
zabbix_version: '6.4.13'
- docker_os: 'ubuntu:20.04'
pg_version: '16'
zabbix_version: '6.4.13'
- docker_os: 'ubuntu:20.04'
pg_version: '15'
zabbix_version: '6.4.13'
exclude:
# excludes PG 15, 16 on CentOS
- docker_os: 'centos:7'
Expand Down
11 changes: 7 additions & 4 deletions mamonsu/tools/zabbix_cli/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from collections import OrderedDict


from distutils.version import LooseVersion
import urllib.request as urllib2


Expand All @@ -13,20 +14,22 @@ class Request(object):
def __init__(self, url, user, passwd):
self._url, self._user, self._passwd = url, user, passwd
self._id, self._auth_tocken = 0, None

self._api_version = self.post(method='apiinfo.version', params=[])

def set_user(self, user):
self._user=user

def set_passwd(self, passwd):
self._passwd=passwd

def _auth(self):
if self._auth_tocken is None:
if not self._user:
return None
user_field = 'user' if LooseVersion(self._api_version) < LooseVersion('6.4') else 'username'
self._auth_tocken = self.post(
'user.login',
{'user': self._user, 'password': self._passwd})
{user_field: self._user, 'password': self._passwd})
return self._auth_tocken

def _get_id(self):
Expand Down

0 comments on commit 42c3eb5

Please sign in to comment.