The method allows to retrieve hosts according to the given parameters.

    This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See for more information.

    Parameters

    (object) Parameters defining the desired output.

    The method supports the following parameters.

    (integer/array) Returns either:

    • an array of objects;

    • the count of retrieved objects, if the countOutput parameter has been used.

    Examples

    Retrieving data by name

    Retrieve all data about two hosts named “Zabbix server” and “Linux server”.

    Request:

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "maintenances": [],
    6. "hostid": "10160",
    7. "proxy_hostid": "0",
    8. "host": "Zabbix server",
    9. "status": "0",
    10. "disable_until": "0",
    11. "error": "",
    12. "available": "0",
    13. "errors_from": "0",
    14. "lastaccess": "0",
    15. "ipmi_authtype": "-1",
    16. "ipmi_privilege": "2",
    17. "ipmi_username": "",
    18. "ipmi_password": "",
    19. "ipmi_disable_until": "0",
    20. "ipmi_available": "0",
    21. "snmp_disable_until": "0",
    22. "snmp_available": "0",
    23. "maintenanceid": "0",
    24. "maintenance_status": "0",
    25. "maintenance_type": "0",
    26. "maintenance_from": "0",
    27. "ipmi_errors_from": "0",
    28. "snmp_errors_from": "0",
    29. "ipmi_error": "",
    30. "snmp_error": "",
    31. "jmx_disable_until": "0",
    32. "jmx_available": "0",
    33. "jmx_errors_from": "0",
    34. "jmx_error": "",
    35. "name": "Zabbix server",
    36. "description": "The Zabbix monitoring server.",
    37. "tls_connect": "1",
    38. "tls_accept": "1",
    39. "tls_issuer": "",
    40. "tls_subject": "",
    41. "tls_psk_identity": "",
    42. "tls_psk": ""
    43. },
    44. {
    45. "maintenances": [],
    46. "hostid": "10167",
    47. "proxy_hostid": "0",
    48. "host": "Linux server",
    49. "status": "0",
    50. "disable_until": "0",
    51. "error": "",
    52. "available": "0",
    53. "errors_from": "0",
    54. "lastaccess": "0",
    55. "ipmi_privilege": "2",
    56. "ipmi_username": "",
    57. "ipmi_password": "",
    58. "ipmi_disable_until": "0",
    59. "ipmi_available": "0",
    60. "snmp_disable_until": "0",
    61. "snmp_available": "0",
    62. "maintenanceid": "0",
    63. "maintenance_status": "0",
    64. "maintenance_type": "0",
    65. "maintenance_from": "0",
    66. "ipmi_errors_from": "0",
    67. "snmp_errors_from": "0",
    68. "ipmi_error": "",
    69. "snmp_error": "",
    70. "jmx_disable_until": "0",
    71. "jmx_available": "0",
    72. "jmx_errors_from": "0",
    73. "jmx_error": "",
    74. "name": "Linux server",
    75. "description": "",
    76. "tls_connect": "1",
    77. "tls_accept": "1",
    78. "tls_issuer": "",
    79. "tls_subject": "",
    80. "tls_psk_identity": "",
    81. "tls_psk": ""
    82. }
    83. ],
    84. "id": 1
    85. }

    Retrieving host groups

    Retrieve names of the groups host “Zabbix server” is member of, but no host details themselves.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "method": "host.get",
    4. "params": {
    5. "output": ["hostid"],
    6. "selectGroups": "extend",
    7. "host": [
    8. "Zabbix server"
    9. ]
    10. }
    11. },
    12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
    13. "id": 2
    14. }
    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10085",
    6. "groups": [
    7. {
    8. "groupid": "2",
    9. "name": "Linux servers",
    10. "internal": "0",
    11. "flags": "0"
    12. },
    13. {
    14. "groupid": "4",
    15. "name": "Zabbix servers",
    16. "internal": "0",
    17. "flags": "0"
    18. }
    19. ]
    20. }
    21. ],
    22. "id": 2
    23. }

    Retrieving linked templates

    Retrieve the IDs and names of templates linked to host “10084”.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "method": "host.get",
    4. "params": {
    5. "output": ["hostid"],
    6. "selectParentTemplates": [
    7. "templateid",
    8. "name"
    9. ],
    10. "hostids": "10084"
    11. },
    12. "id": 1,
    13. "auth": "70785d2b494a7302309b48afcdb3a401"
    14. }

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10084",
    6. "parentTemplates": [
    7. {
    8. "name": "Linux",
    9. "templateid": "10001"
    10. },
    11. {
    12. "name": "Zabbix Server",
    13. "templateid": "10047"
    14. }
    15. ]
    16. }
    17. ],
    18. "id": 1
    19. }

    Searching by host inventory data

    Retrieve hosts that contain “Linux” in the host inventory “OS” field.

    Request:

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10084",
    6. "host": "Zabbix server",
    7. "inventory": {
    8. "os": "Linux Ubuntu"
    9. }
    10. },
    11. {
    12. "hostid": "10107",
    13. "host": "Linux server",
    14. "inventory": {
    15. "os": "Linux Mint"
    16. }
    17. }
    18. ],
    19. "id": 1
    20. }

    Searching by host tags

    Retrieve hosts that have tag “Host name” equal to “Linux server”.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "params": {
    4. "output": ["hostid"],
    5. "selectTags": "extend",
    6. "evaltype": 0,
    7. "tags": [
    8. {
    9. "tag": "Host name",
    10. "value": "Linux server",
    11. "operator": 1
    12. }
    13. ]
    14. },
    15. "auth": "7f9e00124c75e8f25facd5c093f3e9a0",
    16. "id": 1
    17. }

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10085",
    6. {
    7. "tag": "Host name",
    8. "value": "Linux server"
    9. },
    10. {
    11. "tag": "OS",
    12. "value": "RHEL 7"
    13. }
    14. ]
    15. }
    16. ],
    17. "id": 1
    18. }

    Retrieve hosts that have these tags not only on host level but also in their linked parent templates.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "method": "host.get",
    4. "params": {
    5. "output": ["name"],
    6. "tags": [{"tag": "A", "value": "1", "operator": "0"}],
    7. "inheritedTags": true
    8. },
    9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
    10. "id": 1
    11. }

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10623",
    6. "name": "PC room 1"
    7. },
    8. {
    9. "hostid": "10601",
    10. "name": "Office"
    11. }
    12. ],
    13. "id": 1
    14. }

    Searching host with tags and template tags

    Request:

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10502",
    6. "name": "Desktop",
    7. "tags": [
    8. {
    9. "tag": "A",
    10. "value": "1"
    11. }
    12. ],
    13. "inheritedTags": [
    14. {
    15. "tag": "B",
    16. "value": "2"
    17. }
    18. ]
    19. }
    20. ],
    21. "id": 1
    22. }

    Searching hosts by problem severity

    Retrieve hosts that have “Disaster” problems.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "method": "host.get",
    4. "params": {
    5. "output": ["name"],
    6. "severities": 5
    7. },
    8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
    9. "id": 1
    10. }

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "10160",
    6. "name": "Zabbix server"
    7. }
    8. ],
    9. "id": 1
    10. }

    Retrieve hosts that have “Average” and “High” problems.

    Request:

    1. {
    2. "jsonrpc": "2.0",
    3. "method": "host.get",
    4. "params": {
    5. "output": ["name"],
    6. "severities": [3, 4]
    7. },
    8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
    9. "id": 1
    10. }

    Response:

    1. {
    2. "jsonrpc": "2.0",
    3. "result": [
    4. {
    5. "hostid": "20170",
    6. "name": "Database"
    7. },
    8. {
    9. "hostid": "20183",
    10. "name": "workstation"
    11. }
    12. ],
    13. "id": 1

    Source