Hi,
what I am trying to do is to make oncall rotation by replacing users in a usergroup. For this I get the groupid of the specific usergroup and the userid for the users that are to be added to the standby group.
This I tried using pyzabbix
Most likely the problem is my lack of python skills...
What I get is:
I must be doing something simple wrong. Can you point me in the right direction?
BTW: using zabbix-2.4.4
what I am trying to do is to make oncall rotation by replacing users in a usergroup. For this I get the groupid of the specific usergroup and the userid for the users that are to be added to the standby group.
This I tried using pyzabbix
Most likely the problem is my lack of python skills...
Code:
#!/usr/bin/python
from pyzabbix import ZabbixAPI
zapi = ZabbixAPI("http://localhost/zabbix")
zapi.login("admin", "admin")
standbygroups = zapi.usergroup.get( output= ['usergrpid','name'],
filter= { "name": ["standby" ] }
)
standbygroup = standbygroups[0]
sbygrpid= standbygroup['usrgrpid']
newsbyusers= zapi.user.get ( output= ['userid','name']
, filter= { "name": ["Arjan"]}
)
newsbyuser= newsbyusers[0]
# replace current standby group members with new:
res= zapi.usergroup.update (usergrpid= sbygrpid
,userids= newsbyusers
)
Code:
Traceback (most recent call last):
File "bin/zab_auth.py", line 31, in <module>
,userids= newsbyusers
File "/Library/Python/2.7/site-packages/pyzabbix/__init__.py", line 156, in fn
args or kwargs
File "/Library/Python/2.7/site-packages/pyzabbix/__init__.py", line 133, in do_request
raise ZabbixAPIException(msg, response_json['error']['code'])
pyzabbix.ZabbixAPIException: ("Error -32602: Invalid params., Incorrect parameters for user group. while sending {'params': {'usergrpid': u'17', 'userids': [{u'userid': u'10', u'name': u'Arjan'}]}, 'jsonrpc': '2.0', 'method': 'usergroup.update', 'auth': u'10d28651473917e670c82a78f4fc19d7', 'id': 4}", -32602)
BTW: using zabbix-2.4.4