Answer the question
In order to leave comments, you need to log in
How to create a zabbix api host?
I am using pyzabbix, I want to add a new host
z = ZabbixAPI(SERVER)
z.login(user=NAME, password=PASSWORD)
z.host.create({ "jsonrpc": "2.0",
"method": "host.create",
"params": {
"host": "blablalbalba",
"interfaces": [
{
"type": 1,
"main": 1,
"useip": 1,
"ip": "myip/zabbix",
"dns": "",
"port": "10050"
}
],
"groups": [
{
"groupid": "37"
}
],
"templates": [
{
"templateid": "20045"
}
],
},
"auth": null,
"id": 1})
Traceback (most recent call last):
File "/home/kolas/PycharmProjects/untitled/test1.py", line 62, in <module>
"id": 1})
File "/usr/local/lib/python2.7/dist-packages/pyzabbix/__init__.py", line 157, in fn
args or kwargs
File "/usr/local/lib/python2.7/dist-packages/pyzabbix/__init__.py", line 99, in do_request
separators=(',', ': ')))
File "/usr/lib/python2.7/json/__init__.py", line 251, in dumps
sort_keys=sort_keys, **kw).encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 209, in encode
chunks = list(chunks)
File "/usr/lib/python2.7/json/encoder.py", line 434, in _iterencode
for chunk in _iterencode_dict(o, _current_indent_level):
File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib/python2.7/json/encoder.py", line 332, in _iterencode_list
for chunk in chunks:
File "/usr/lib/python2.7/json/encoder.py", line 408, in _iterencode_dict
for chunk in chunks:
File "/usr/lib/python2.7/json/encoder.py", line 442, in _iterencode
o = _default(o)
File "/usr/lib/python2.7/json/encoder.py", line 184, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: <module 'null' from '/usr/local/lib/python2.7/dist-packages/null.pyc'> is not JSON serializable
Answer the question
In order to leave comments, you need to log in
found the answer instead of host.create() you need to use do_request
z.do_request(method="host.create",params= {
"host": "blablalbalba",
"interfaces": [
{
"type": 1,
"main": 1,
"useip": 1,
"ip": "ip",
"dns": "",
"port": "10050"
}
],
"groups": [
{
"groupid": "37"
}
],
"templates": [
{
"templateid": "10104"
}
],
}
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question