Ad Widget

Collapse

PyZabbix for Accessing Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ankurhacked
    Junior Member
    • Apr 2018
    • 2

    #1

    PyZabbix for Accessing Zabbix API

    Hi Guys,

    I am new to this forum and have a question rather a problem I am encountering while accessing Zabbix API from my Linux Machine. The error is as follows: I am getting a 403 forbidden error, this happens only when I access from Linux, if I install Python on windows and make the same API call it works just fine.


    Type "help", "copyright", "credits" or "license" for more information.
    >>> from pyzabbix import ZabbixAPI
    >>> zapi = ZabbixAPI("http://myserverzabbix")
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 156, in __init__
    self._login(user, password)
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 186, in _login
    self.auth = self.user.login(user=user, password=password)
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 82, in fn
    args or kwargs
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 236, in do_request
    res = urlopen(req)
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 109, in inner
    res = func(req)
    File "/usr/lib/python2.7/site-packages/pyzabbix/api.py", line 118, in urlopen
    return urllib2.urlopen(*args, **kwargs)
    File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
    File "/usr/lib64/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
    File "/usr/lib64/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
    File "/usr/lib64/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
    File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
    File "/usr/lib64/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
    urllib2.HTTPError: HTTP Error 403: Forbidden
    >>>
  • aigars.kadikis
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Mar 2018
    • 208

    #2
    Is http_code 200? or 301 at least?
    Code:
    curl -s -o /dev/null -w "%{http_code}\n" "http://myserverzabbix/"
    What kind of Linux operating system you have? Is SELinux installed? Try to get SELinux status:
    Code:
    getenforce

    Comment

    • ankurhacked
      Junior Member
      • Apr 2018
      • 2

      #3
      Thanks aigars.kadikis . I have managed to resolve the issue. The issue was with the server connecting to a Proxy. So now I am not using the proxy and the connection to Zabbix from Python works fine.

      Comment

      Working...