Skip to content

Commit 80cfe38

Browse files
committed
fix: add support for Zabbix API v6.4
1 parent 718d958 commit 80cfe38

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

.github/workflows/mamonsu-tests-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
docker_os: ['centos:7', 'centos:8']
30-
zabbix_version: ['6.2.9']
30+
zabbix_version: ['6.2.9', '6.4.13']
3131
pg_version: ['12', '13', '14', '15']
3232
include:
3333
- docker_os: 'centos:8'

.github/workflows/mamonsu-tests-master.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ jobs:
2727
strategy:
2828
matrix:
2929
docker_os: ['ubuntu:20.04', 'centos:7', 'centos:8']
30-
zabbix_version: ['4.0.44', '4.4.10', '5.0.30', '5.4.12', '6.0.12', '6.2.9']
30+
zabbix_version: ['4.0.44', '4.4.10', '5.0.30', '5.4.12', '6.0.12', '6.2.9', '6.4.13']
3131
pg_version: ['12', '13', '14', '15']
3232
include:
3333
- docker_os: 'centos:8'
3434
pg_version: '16'
3535
zabbix_version: '6.2.9'
36+
- docker_os: 'centos:8'
37+
pg_version: '16'
38+
zabbix_version: '6.4.13'
3639
exclude:
3740
# excludes PG 15, 16 on CentOS
3841
- docker_os: 'centos:7'

mamonsu/tools/zabbix_cli/request.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections import OrderedDict
66

77

8+
from distutils.version import LooseVersion
89
import urllib.request as urllib2
910

1011

@@ -13,20 +14,22 @@ class Request(object):
1314
def __init__(self, url, user, passwd):
1415
self._url, self._user, self._passwd = url, user, passwd
1516
self._id, self._auth_tocken = 0, None
16-
17+
self._api_version = self.post(method='apiinfo.version', params=[])
18+
1719
def set_user(self, user):
1820
self._user=user
19-
21+
2022
def set_passwd(self, passwd):
2123
self._passwd=passwd
22-
24+
2325
def _auth(self):
2426
if self._auth_tocken is None:
2527
if not self._user:
2628
return None
29+
user_field = 'user' if LooseVersion(self._api_version) < LooseVersion('6.4') else 'username'
2730
self._auth_tocken = self.post(
2831
'user.login',
29-
{'user': self._user, 'password': self._passwd})
32+
{user_field: self._user, 'password': self._passwd})
3033
return self._auth_tocken
3134

3235
def _get_id(self):

0 commit comments

Comments
 (0)