Ad Widget

Collapse

How to get all hosts by ZABBIX API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yaohua
    Junior Member
    • Jul 2017
    • 3

    #1

    How to get all hosts by ZABBIX API

    I use ZABBIX API to get all hosts.but the respone is null
    As following is my code:

    PHP Code:
    import urllib3
    import json
    Zabbix_Cusor 
    urllib3.PoolManager()
    Zabbix_username 'Admin'
    Zabbix_pass 'zabbix'
    Zabbix_header = {"Content-Type":"application/json"}
    Get_Hosts json.dumps({
        
    "jsonrpc""2.0",
        
    "method""host.get",
        
    "params": {
            
    "output""extend",
        },
    })
    b  Zabbix_Cusor.request('POST',
                              
    Zabbix_url,
                              
    body=Get_Hosts,
                              
    headers=Zabbix_header)
    try:
        
    User_Data json.loads(b.data)['result']
        for 
    i in User_Data:
            print(
    i"\n")
    except TypeError:
        print(
    "No respone"
    please help me
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2
    You don't have any authentication.

    Why you don't use some existing library? http://zabbix.org/wiki/Docs/api/libraries#Python
    Devops Monitoring Expert advice: Dockerize/automate/monitor all the things.
    My DevOps stack: Docker / Kubernetes / Mesos / ECS / Terraform / Elasticsearch / Zabbix / Grafana / Puppet / Ansible / Vagrant

    Comment

    • Yaohua
      Junior Member
      • Jul 2017
      • 3

      #3
      Originally posted by jan.garaj
      You don't have any authentication.

      Why you don't use some existing library? http://zabbix.org/wiki/Docs/api/libraries#Python
      Yeah,I got it.Thanks.

      Comment

      Working...