Ad Widget
Collapse
Zabbix API -- items_to_csv error
Collapse
X
-
Hi,
You change the parameter in zabbix_api.py:
auth = None
Also change this:
obj = self.json_obj('user.authenticate', { 'user' : l_user,
to:
obj = self.json_obj('user.login', { 'user' : l_user,
Regards.
PD Sorry for mi english
-
It is normal to execute the following
[root@zabbix opt]# ./fetch_items_to_csv.py -s 127.0.0.1 -u admin -p zabbix -n 10.1.1.1
Only the last value from each key has been fetched, specify t1 or t1 and t2 to fetch more data
But
The execution of the following is abnormal and the data cannot be generated
[root@zabbix opt]# ./fetch_items_to_csv.py -s 127.0.0.1 -u admin -p zabbix -n 10.1.1.1 -t1 '2020-09-01 10:30:00' -t2 '2020-09-01 16:00:00' -v 1
Traceback (most recent call last):
File "./fetch_items_to_csv.py", line 179, in <module>
fetch_to_csv(args.username, args.password, "http://"+args.server_IP+"/zabbix", args.hostname, args.key, args.output, args.datetime1,args.datetime2,args.debuglevel)
File "./fetch_items_to_csv.py", line 102, in fetch_to_csv
history = zapi.history.get({"hostids":[hostid,],"time_from":timestamp1,"time_till":timestamp2, "output":"extend" })
File "/opt/zabbix_api.py", line 304, in wrapper
return self.do_request(self.json_obj(name,opts))['result']
File "/opt/zabbix_api.py", line 286, in do_request
return self.parent.do_request(req)
File "/opt/zabbix_api.py", line 251, in do_request
raise ZabbixAPIException(msg,jobj['error']['code'])
zabbix_api.ZabbixAPIException: (u'Error -32602: Invalid params., Invalid parameter "/time_from": an integer is expected.', -32602)
[root@zabbix opt]#Comment
-
An old thread, but I was having this same problem and resolved this problem by modifying the fetch_items_to_csv.py slightly to force the date conversion to be an integer,The execution of the following is abnormal and the data cannot be generated
[root@zabbix opt]# ./fetch_items_to_csv.py -s 127.0.0.1 -u admin -p zabbix -n 10.1.1.1 -t1 '2020-09-01 10:30:00' -t2 '2020-09-01 16:00:00' -v 1
Traceback (most recent call last):
File "./fetch_items_to_csv.py", line 179, in <module>
fetch_to_csv(args.username, args.password, "http://"+args.server_IP+"/zabbix", args.hostname, args.key, args.output, args.datetime1,args.datetime2,args.debuglevel)
File "./fetch_items_to_csv.py", line 102, in fetch_to_csv
history = zapi.history.get({"hostids":[hostid,],"time_from":timestamp1,"time_till":timestamp2, "output":"extend" })
File "/opt/zabbix_api.py", line 304, in wrapper
return self.do_request(self.json_obj(name,opts))['result']
File "/opt/zabbix_api.py", line 286, in do_request
return self.parent.do_request(req)
File "/opt/zabbix_api.py", line 251, in do_request
raise ZabbixAPIException(msg,jobj['error']['code'])
zabbix_api.ZabbixAPIException: (u'Error -32602: Invalid params., Invalid parameter "/time_from": an integer is expected.', -32602)
[root@zabbix opt]#
For example
I also used the latest version of the zabbix_api.py taken from https://github.com/gescheit/scripts/.../zabbix_api.py which resolved the old auth issue.Code:71: timestamp1=int(time.mktime(d1.timetuple())) 72: timestamp2=int(round(time.time()))
Comment
Comment