Ad Widget

Collapse

Zabbix API | Get List of Unreachable Machines

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • colwellkr
    Junior Member
    • Oct 2018
    • 2

    #1

    Zabbix API | Get List of Unreachable Machines

    In order to automate the remediation of problems, I am trying to use the Zabbix API to gather a list of computers that are unreachable via Zabbix Agent ping.

    So far I have created a tag on the "Zabbix agent on {HOST.NAME} is unreachable" trigger that is called "unpingable." Then I am using the problem.get method in the API to list all problems with the tag "unpingable". From here my problem has become, how do I coordinate the list of problems I get back, to a lists of hosts that are experiencing that problem? I was able to look up the specific trigger by using trigger.get to fetch a list of all triggers and comparing the "triggerid" field to the "objectid" field in the problem object. However, I cannot figure out from there how I might get a hostID or hostname (I can look up the host name if I could get the hostID).

    Anyone have any suggestions for how to fetch the hostID from a problem object or other ways I might go about getting a list of unreachable machines?

    Thanks!
  • colwellkr
    Junior Member
    • Oct 2018
    • 2

    #2
    UPDATE: It's a little messy, but I figured out that you can take the list of Problem Objects and use the "objectid" as a filter for the triggerid parameter of the "item.get" method and item object returns a hostID that can be looked up into a hostname.

    I think have a workable solution, but if anyone has a better suggestion, I'm open to ideas!

    Comment

    • omkar-bhujbal
      Junior Member
      • Mar 2020
      • 3

      #3
      You can refer in the below file
      GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.


      in this file please check the following function where I filtered host with there avaibility status
      def getAllHostWithStatus(self, available=2, onlyIp=False):
      If you want to explore some useful API please refer

      Comment

      Working...