Ad Widget

Collapse

Possible to just return host names from the API?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sandra
    Junior Member
    • Jun 2020
    • 10

    #1

    Possible to just return host names from the API?

    Dear all =)

    With the below NodeJS PoC, it returns all hosts with all their meta data.

    Is it possible to just return the hostname using the Zabbix API, or should that be filtered out afterwards?

    Hugs
    Sandra =)

    Code:
    const Zabbix = require('zabbix-promise')
    
    const zabbix = new Zabbix({
    url: 'https://example.com/api_jsonrpc.php',
    user: '',
    password: ''
    })
    
    const main = async () => {
    try {
    await zabbix.login()
    const host = await zabbix.request('host.get', {
    // selectInterfaces: 'extend',
    })
    console.log(JSON.stringify(host, null, 2))
    zabbix.logout()
    } catch (error) {
    console.error(error)
    }
    }
    main()
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    just add
    Code:
    "params": {  "output": ["host"] }

    Comment

    • Sandra
      Junior Member
      • Jun 2020
      • 10

      #3
      Thank you so much! =)

      Where can I see which `params` there are available?

      Comment

    Working...