Zabbix: 2.0
Mysql: 5.1
OS: RHEL 6.1
Issue error with item.create.
ZabbixAPIException: ("Error -32602: Invalid params., No interface found. while sending {'params': {'hostid': u'10884', 'key_': 'vfs.fs.size[/bigfs/project,used]', 'name': 'Used disk on $1', 'delay': 3600, 'value_type': 3, 'units': 'B', 'type': 0}, 'jsonrpc': '2.0', 'method': 'item.create', 'auth': u'822525c62cb851293f571483fd6f1210', 'id': 3}", -32602)
code:
import sys
from pyzabbix import ZabbixAPI
# The hostname at which the Zabbix web interface is available
ZABBIX_SERVER = 'http://ryzabbix/zabbix'
host_name = 'ctchpcva001'
# Login to the Zabbix API
zapi = ZabbixAPI(ZABBIX_SERVER)
zapi.login('deyjohn', 'N3wY3@r14')
hosts = zapi.host.get(filter= {'host': host_name} )
if hosts:
host_id = hosts[0]["hostid"]
print "Found host id: ", host_id
else:
print("No hosts found")
sys.exit()
zapi.item.create(
hostid=host_id,
name='Used disk on $1',
key_='vfs.fs.size[/fstool/project,used]',
units='B',
delay=3600,
type=0,
value_type=3
)
#Solution: With 2.0 Zabbix the interface needs to be specified. Add this section before item create:
host_interface = zapi.hostinterface.get(filter={"hostid": host_id} )
if host_interface:
interface = host_interface[0]["interfaceid"]
else:
print("no interface found")
sys.exit()
# add interface to the item.create
zapi.item.create(
hostid=host_id,
interfaceid=interface,
name='Used disk on $1',
key_='vfs.fs.size[/fstool/project,used]',
units='B',
delay=3600,
type=0,
value_type=3
)
Mysql: 5.1
OS: RHEL 6.1
Issue error with item.create.
ZabbixAPIException: ("Error -32602: Invalid params., No interface found. while sending {'params': {'hostid': u'10884', 'key_': 'vfs.fs.size[/bigfs/project,used]', 'name': 'Used disk on $1', 'delay': 3600, 'value_type': 3, 'units': 'B', 'type': 0}, 'jsonrpc': '2.0', 'method': 'item.create', 'auth': u'822525c62cb851293f571483fd6f1210', 'id': 3}", -32602)
code:
import sys
from pyzabbix import ZabbixAPI
# The hostname at which the Zabbix web interface is available
ZABBIX_SERVER = 'http://ryzabbix/zabbix'
host_name = 'ctchpcva001'
# Login to the Zabbix API
zapi = ZabbixAPI(ZABBIX_SERVER)
zapi.login('deyjohn', 'N3wY3@r14')
hosts = zapi.host.get(filter= {'host': host_name} )
if hosts:
host_id = hosts[0]["hostid"]
print "Found host id: ", host_id
else:
print("No hosts found")
sys.exit()
zapi.item.create(
hostid=host_id,
name='Used disk on $1',
key_='vfs.fs.size[/fstool/project,used]',
units='B',
delay=3600,
type=0,
value_type=3
)
#Solution: With 2.0 Zabbix the interface needs to be specified. Add this section before item create:
host_interface = zapi.hostinterface.get(filter={"hostid": host_id} )
if host_interface:
interface = host_interface[0]["interfaceid"]
else:
print("no interface found")
sys.exit()
# add interface to the item.create
zapi.item.create(
hostid=host_id,
interfaceid=interface,
name='Used disk on $1',
key_='vfs.fs.size[/fstool/project,used]',
units='B',
delay=3600,
type=0,
value_type=3
)