Ad Widget
Collapse
Zabbix API. Библиотека для Python
Collapse
X
-
Но ведь в этой доке http://www.zabbix.com/documentation/...x/api/host/get точно приведён вывод содержащий поле IP, которое не входит в список interfaces.Comment
-
Вы правыНо ведь в этой доке http://www.zabbix.com/documentation/...x/api/host/get точно приведён вывод содержащий поле IP, которое не входит в список interfaces.
выводCode:zapi.host.get( { "output": "extend", "filter": {"host": ["33-kyib22p3","Zabbix-server"]} } )
Строк не хватает как обозначено в мануалеCode:10: Response Body: {u'jsonrpc': u'2.0', u'result': [{u'available': u'0', u'maintenance_type': u'0', u'maintenances': [], u'ipmi_username': u'', u'snmp_disable_until': u'0', u'ipmi_authtype': u'0', u'ipmi_disable_until': u'0', u'lastaccess': u'0', u'snmp_error': u'', u'ipmi_privilege': u'2', u'jmx_error': u'', u'jmx_available': u'0', u'ipmi_errors_from': u'0', u'maintenanceid': u'0', u'snmp_available': u'1', u'status': u'0', u'host': u'33-kyib22p3', u'disable_until': u'0', u'ipmi_password': u'', u'ipmi_available': u'0', u'maintenance_status': u'0', u'snmp_errors_from': u'0', u'ipmi_error': u'', u'proxy_hostid': u'0', u'hostid': u'10911', u'name': u'33-kyib22p3', u'jmx_errors_from': u'0', u'jmx_disable_until': u'0', u'error': u'', u'maintenance_from': u'0', u'errors_from': u'0'}, {u'available': u'1', u'maintenance_type': u'0', u'maintenances': [], u'ipmi_username': u'zabbix', u'snmp_disable_until': u'0', u'ipmi_authtype': u'-1', u'ipmi_disable_until': u'0', u'lastaccess': u'0', u'snmp_error': u'', u'ipmi_privilege': u'4', u'jmx_error': u'', u'jmx_available': u'0', u'ipmi_errors_from': u'0', u'maintenanceid': u'0', u'snmp_available': u'0', u'status': u'0', u'host': u'Zabbix server', u'disable_until': u'0', u'ipmi_password': u'2286sena', u'ipmi_available': u'0', u'maintenance_status': u'0', u'snmp_errors_from': u'0', u'ipmi_error': u'', u'proxy_hostid': u'0', u'hostid': u'10017', u'name': u'Zabbix server', u'jmx_errors_from': u'0', u'jmx_disable_until': u'0', u'error': u'', u'maintenance_from': u'0', u'errors_from': u'0'}], u'id': 1}
http://www.zabbix.com/documentation/...x/api/host/get
попробую поставить
Хм не помоглоLast edited by sersad; 26-06-2012, 14:18.Comment
-
-
Зря тикет поднял, извиняюсь. Без подсказки не допер как дернуть нужные данныеYou need to use "selectInterfaces" parameter to get host interface information. This parameter was added from Zabbix 2.0 API because host can have multiple interfaces from 2.0.
Please see http://www.zabbix.com/documentation/...x/api/host/get for more details of host.get method on 2.0.
Code:zapi.host.get( { "output": "extend", "filter": {"host": ["33-kyib22p3"]}, "selectInterfaces": "extend" } )
дает следуюущее
Code:10: Response Body: {u'jsonrpc': u'2.0', u'result': [{u'available': u'0', u'maintenance_type': u'0', u'maintenances': [], u'ipmi_username': u'', u'snmp_disable_until': u'0', u'ipmi_authtype': u'0', u'ipmi_disable_until': u'0', u'lastaccess': u'0', u'snmp_error': u'', u'ipmi_privilege': u'2', u'jmx_error': u'', u'jmx_available': u'0', u'ipmi_errors_from': u'0', u'maintenanceid': u'0', u'snmp_available': u'1', u'status': u'0', u'interfaces': {u'32734': {u'interfaceid': u'32734', u'hostid': u'10911', u'ip': u'10.21.133.84', u'useip': u'1', u'dns': u'', u'main': u'1', u'type': u'2', u'port': u'161'}, u'32733': {u'interfaceid': u'32733', u'hostid': u'10911', u'ip': u'10.21.133.84', u'useip': u'1', u'dns': u'', u'main': u'0', u'type': u'2', u'port': u'161'}}, u'host': u'33-kyib22p3', u'disable_until': u'0', u'ipmi_password': u'', u'ipmi_available': u'0', u'maintenance_status': u'0', u'snmp_errors_from': u'0', u'ipmi_error': u'', u'proxy_hostid': u'0', u'hostid': u'10911', u'name': u'33-kyib22p3', u'jmx_errors_from': u'0', u'jmx_disable_until': u'0', u'error': u'', u'maintenance_from': u'0', u'errors_from': u'0'}], u'id': 1}Comment
-
Не удивительно что не смог, ведь документация у них не для человеков написана =(
Вот я сейчас пытаюсь сделать host.update на поля из "Host inventory", да что там профиль, тот же статус меняю и получаю ошибку =(
zapi.host.update({
"hostid" : hostid,
"status" : 0 })
(u'Error -32602: Invalid params., No permissions to referred object or it does not exist! while sending {"params": {"status": 0, "hostid": [{"hostid": "10187"}]}, "jsonrpc": "2.0", "method": "host.update", "auth": "1763c136fd064c5255d1a9cf90c5326f", "id": 5}', -32602)
Разумеется у пользователя есть полные права на запись всего.Last edited by alp; 27-06-2012, 13:12.Comment
-
приветствую.
Не подскажите что я не так делаю?
спасибо.Code:In [206]: zapi.host.create({ "host":"testsw", "interfaces":[{ "type":2, "main":2, "ip":u"172.17.22.33", "port":161, "useip":1}], 'groups':[{ "groupid":9 }], "templates":[{ "templateid":10124 }], "inventory":{ "macaddress_a":"00:00:00:00:00:00" } }) ZabbixAPIException: (u'Error -32602: Invalid params., Incorrect arguments passed to function. while sending {"params": {"templates": [{"templateid": 10124}], "host": "testsw", "interfaces": [{"ip": "172.17.22.33", "main": 2, "type": 2, "port": 161, "useip": 1}], "groups": [{"groupid": 9}], "inventory": {"macaddress_a": "00:00:00:00:00:00"}}, "jsonrpc": "2.0", "method": "host.create", "auth": "5bb48d0208688f222fbd346b1d9a17a6", "id": 45}', -32602) In [210]: zapi.hostgroup.get({"filter":{"name":'switch'}}) Out[210]: [{u'groupid': u'9'}] In [211]: zapi.template.get({"filter":{"name":'dlink.des-3200-26'}}) Out[211]: [{u'hostid': u'10124', u'templateid': u'10124'}]Last edited by fast-l; 30-09-2012, 08:35.Comment
-
There are two problems with the interface:приветствую.
Не подскажите что я не так делаю?
спасибо.Code:In [206]: zapi.host.create({ "host":"testsw", "interfaces":[{ "type":2, "main":2, "ip":u"172.17.22.33", "port":161, "useip":1}], 'groups':[{ "groupid":9 }], "templates":[{ "templateid":10124 }], "inventory":{ "macaddress_a":"00:00:00:00:00:00" } }) ZabbixAPIException: (u'Error -32602: Invalid params., Incorrect arguments passed to function. while sending {"params": {"templates": [{"templateid": 10124}], "host": "testsw", "interfaces": [{"ip": "172.17.22.33", "main": 2, "type": 2, "port": 161, "useip": 1}], "groups": [{"groupid": 9}], "inventory": {"macaddress_a": "00:00:00:00:00:00"}}, "jsonrpc": "2.0", "method": "host.create", "auth": "5bb48d0208688f222fbd346b1d9a17a6", "id": 45}', -32602) In [210]: zapi.hostgroup.get({"filter":{"name":'switch'}}) Out[210]: [{u'groupid': u'9'}] In [211]: zapi.template.get({"filter":{"name":'dlink.des-3200-26'}}) Out[211]: [{u'hostid': u'10124', u'templateid': u'10124'}]
1. You should pass the "dns" attribute, and empty string if you don't use DNS;
2. The "main" attribute is a boolean value, so it can't be set to "2".Comment
-
Да дело было в этом. Спасибо.
fixed and woking rghit now. thanks a lotCode:In [31]: zapi.host.create({ "host":"testsw", "interfaces":[{ "type":2, "dns":"", "main":1, "ip":"172.17.22.33", "port":161, "useip":1}], "groups": [{"groupid": u'9'}], "templates": [{ "templateid":10124 }], "inventory": { "macaddress_a":"00:00:00:00:00:00" } }) Out[31]: {u'hostids': [u'10143']}Last edited by fast-l; 01-10-2012, 16:18.Comment
Comment