Hi guys,
I need some help with my zabbix-api interface.
We need in our production monitoring Zabbix environment multiple items with the type snmptrap. I made the first few hundreds by hand but after a while thought there must be a better way =)
My zabbix-api is working, I can create basic agent.ping item for some test template, but when I try to create snmptrap item there is some problems. It gives error code 32602, Invalid params, Incorrect arguments passed to function.
I am using Python3.6.8 and Zabbix 4.4.5
Python script:
import requests
import json
zabbix_url = "http://zabbix_url/zabbix/api_jsonrpc.php"
user = "user"
passwd = "passwd"
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": user,
"password": passwd
},
"id": 1
})
auth_token = r.json()["result"]
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "item.create",
"params": {
"name": "TEST",
"key_": "snmptrap[TEST]",
"hostid": "10412", # id of the template
"type": 17, # number of the snmptrap
"value_type": 4, # number of the text value
},
"auth": auth_token,
"id": 1
})
print(json.dumps(r.json(), indent=4))
print("\nLogout user")
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "user.logout",
"params": {},
"id": 3,
"auth": auth_token
})
print(json.dumps(r.json(), indent=4))
Could someone please help to resolve this problem, what I am missing here? There shouldn't be so much required fields to this snmptrap type item creation.
Have a good day!
Br,
Totti
I need some help with my zabbix-api interface.
We need in our production monitoring Zabbix environment multiple items with the type snmptrap. I made the first few hundreds by hand but after a while thought there must be a better way =)
My zabbix-api is working, I can create basic agent.ping item for some test template, but when I try to create snmptrap item there is some problems. It gives error code 32602, Invalid params, Incorrect arguments passed to function.
I am using Python3.6.8 and Zabbix 4.4.5
Python script:
import requests
import json
zabbix_url = "http://zabbix_url/zabbix/api_jsonrpc.php"
user = "user"
passwd = "passwd"
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": user,
"password": passwd
},
"id": 1
})
auth_token = r.json()["result"]
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "item.create",
"params": {
"name": "TEST",
"key_": "snmptrap[TEST]",
"hostid": "10412", # id of the template
"type": 17, # number of the snmptrap
"value_type": 4, # number of the text value
},
"auth": auth_token,
"id": 1
})
print(json.dumps(r.json(), indent=4))
print("\nLogout user")
r = requests.post(zabbix_url,
json={
"jsonrpc": "2.0",
"method": "user.logout",
"params": {},
"id": 3,
"auth": auth_token
})
print(json.dumps(r.json(), indent=4))
Could someone please help to resolve this problem, what I am missing here? There shouldn't be so much required fields to this snmptrap type item creation.
Have a good day!
Br,
Totti
Comment