Ad Widget

Collapse

Not able to retrieve host information using Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Supriya123
    Junior Member
    • Jun 2019
    • 17

    #1

    Not able to retrieve host information using Zabbix API

    Hi All,

    I am new to access Zabbix API using python. When I was trying to get host information using user name and password it says invalid username and password.

    Here is my python script

    #!/usr/bin/env python

    from pyzabbix import ZabbixAPI

    from pprint import pprint




    # Create ZabbixAPI class instance

    zapi = ZabbixAPI("http://xx.xx.x.xxx/zabbix")

    zapi.login("Admin", "{somepassword}")

    print "Connected to Zabbix API Version %s" % zapi.api_version()




    for h in zapi.host.get(output="extend"):

    pprint(h)


    Here is my output

    [root@zabbix-vx-010101-1 html]# python monitoredhosts.py

    Traceback (most recent call last):

    File "monitoredhosts.py", line 6, in <module>

    zapi = ZabbixAPI("http://10.21.1.239/zabbix")

    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 171, in __init__

    self._login(user, password)

    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 201, in _login

    self.auth = self.user.login(user=user, password=password)

    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 90, in fn

    args or kwargs

    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 263, in do_request

    raise ZabbixAPIException(err)

    pyzabbix.api.ZabbixAPIException: {u'message': u'Application error.', u'code': -32500, u'data': u'Login name or password is incorrect.', 'json': "{'params': {'password': 'zabbix', 'user': 'Admin'}, 'jsonrpc': '2.0', 'method': 'user.login', 'id': '1'}"}


    Can you please help me , where I am doing wrong. My username and password are correct I am able to login to UI with these credentials.

    Appreciate your help
Working...