Ad Widget

Collapse

Zabbix API item.get with hostnames

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karzer
    Member
    • Mar 2010
    • 61

    #1

    Zabbix API item.get with hostnames

    Hello,

    Im trying get certain key with hostnames.

    In my code im getting all Servers in group no:292 with a key named "Cpu Total (Processor Time])".

    But the data only i get from host is id. I need hostnames too. Is there any api info about this or should i just write another api query to get ID and Hostnames and match them in a loop? I have more then hundred server in this group so api query will have better performance.

    My wider purpose is make a dashboard with our needs with certain keys. This is one of them..

    Thanks for help.

    $(document).ready(function(){
    $.ajax({
    url: 'http://url/zabbix/api_jsonrpc.php',
    contentType:"application/json-rpc",
    data: JSON.stringify ({
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
    "output": "extend",
    "groupids": "292",
    "search": {
    "hostids": "14719"
    "key_": "Processor Time]",
    "filter":"lastvalue"
    }, "sortfield": "name"
    },
    "id": 2,
    "auth": "$authkey"} ),

    type:"POST",
    success: function(searchResult) {
    var resultData
    resultData = searchResult["result"][0]["lastvalue"];
    $('#cpuValue').html(resultData);
    }
    });
    });
  • jan.garaj
    Senior Member
    Zabbix Certified Specialist
    • Jan 2010
    • 506

    #2


    Code:
    {
        "output": "extend",
        "selectHosts": "extend"
    }
    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

    • karzer
      Member
      • Mar 2010
      • 61

      #3
      Thank you for your help it was really helpful.

      Comment

      Working...