Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem creating host interface using create_host_interface #128

Open
techie879 opened this issue Jul 1, 2020 · 11 comments
Open

problem creating host interface using create_host_interface #128

techie879 opened this issue Jul 1, 2020 · 11 comments
Labels

Comments

@techie879
Copy link

techie879 commented Jul 1, 2020

Hi,

I am having trouble creating SNMP host interface using the following, and could use some hints from you.

some quick background info -- SNMP interface IP is different then the host IP in my case.

My txt file is:

create_host_interface hpc3-14-03 1 "" "" 10.240.62.16 "" 0

here is the error i get:

020-07-01 08:57:26,101 [zabbix_cli.cli][None][263865][ERROR]: Problems creating host interface on hpc3-14-03- (u"Error -32602: Invalid params.: Incorrect arguments passed to function. while sending {u'params': {'hostid': '10336', 'ip': '10.240.62.16', 'useip': 1, 'dns': '', 'main': 0, 'type': 2, 'port': '161'}, u'jsonrpc': u'2.0', u'method': u'hostinterface.create', u'auth': u'xxx', u'id': 8}", -32602)
[root@hpc3-xcat-1 ~]# cat create_interface.txt

I am not sure which incorrect argument is passed here.

thanks

@paalbra
Copy link
Contributor

paalbra commented Jul 1, 2020

What python version is this?

What version of Zabbix?

What kind of host is this? A regular host? Does it have any other SNMP interfaces already?

@paalbra
Copy link
Contributor

paalbra commented Jul 1, 2020

PS. You probably don't want to post your auth key by the way

@paalbra
Copy link
Contributor

paalbra commented Jul 1, 2020

And what Zabbix-cli version or commit is this?

@techie879
Copy link
Author

Hi,

Python version is 2.7.15 . For zabbix-cli version I am using 2.2.1 . I checked out tag 2.2.1 and installed it. I am running zabbix 5 LTS.

it is a HP apollo server. currently it does not have any SNMP interface setup. Attached a snippet from zabbix GUI.
Inkedzabbix_png_LI

@paalbra
Copy link
Contributor

paalbra commented Jul 1, 2020

Looks like they've change the API between 4.0 and 5.0. We've only tested zabbix-cli with 4.0.

https://www.zabbix.com/documentation/4.0/manual/api/reference/hostinterface/object#host_interface
vs
https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object#host_interface

The details param/field is required when creating SNMP interfaces. I haven't been able to confirm it, but I guess that this is the issue.

@techie879
Copy link
Author

aah, OK. thanks for letting me know. Would there be a fix in the future?

@paalbra
Copy link
Contributor

paalbra commented Jul 1, 2020

Yes, supporting the new LTS is something we'll need to do. I don't think this is much work, but we're a bit low on resources right now. I can't guarantee anything :/

@paalbra
Copy link
Contributor

paalbra commented Jul 3, 2020

@techie879 This is only a small hotfix, but could you try with this? https://github.com/unioslo/zabbix-cli/commits/fix-128

This simple commit might resolve your issue, but I'm not sure 7ad6c2c

Sadly they haven't updated their appliance-container that I use for testing. They don't have a proper 5.0 LTS image yet. https://hub.docker.com/r/zabbix/zabbix-appliance

@techie879
Copy link
Author

techie879 commented Jul 5, 2020 via email

@paalbra
Copy link
Contributor

paalbra commented Jul 6, 2020

They've apparently made some major changes to SNMP https://www.zabbix.com/documentation/current/manual/api/changes_4.4_-_5.0

Also: Their documentation contains errors: https://www.zabbix.com/documentation/5.0/manual/api/reference/hostinterface/object

details is not an array. And it looks like they've improperly labeled required/not required fields.

This is a valid request:

curl -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"hostinterface.create","params":{"hostid":"1","dns":"","ip":"127.0.0.1","main":0,"port":"10050","type":2,"useip":1,"details":{"version":2,"community":"public"}},"auth":"xxx","id":1}' 'http://localhost/zabbix/api_jsonrpc.php'.

There's no simple quickfix for this. The command will probably need to take more parameters as input :/

@stemsin
Copy link

stemsin commented Feb 27, 2021

If anyone has faced the same, as a dirty fix you can use the below: in "./zabbix_cli/cli.py"

3165         query = {
3166             "hostid": hostid,
3167             "type": int(interface_type),
3168             "main": int(interface_main),
3169             "useip": int(interface_useip),
3170             "port": str(interface_port),
>>3171             "details": {"version":2,"community":"public"}
3172         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants