Ad Widget

Collapse

Get host name through the API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Stephen Wood
    Member
    • Feb 2012
    • 43

    #1

    Get host name through the API

    I'm able to get the hostid from the API, but I'm so far unable to figure out a way to get the hostname as it would appear in zabbix. Is this possible through the API?

    I need this information because it's being used to sort hosts that have been taken offline.
  • Stephen Wood
    Member
    • Feb 2012
    • 43

    #2
    For anyone wondering, I don't think this is possible through the API. In order to get this information, I added a zabbix mysql user with specific read-only privileges on the zabbix DB, then I run this command:

    Code:
    mysql -u zabbix DATABASE -e 'select name from hosts where status != 3;'
    Which gives me all of the names of hosts (minus the template names).

    I hate to go through mysql but I guess this is my only option at the moment.

    Comment

    • Pavels
      Member
      • Oct 2011
      • 83

      #3
      Of course it is possible. Just use output: ["name"] to get the visible name of the host or "output": ["host"] to get the technical name.

      Comment

      Working...