monitoringzabbix

How do I get IP address with Zabbix?


I'm new to Zabbix so question might look like a real newbie one.

I have a task where VM has hardcoded IP address of external service and this address wants to be monitored. Once DNS have different IP address than on VM - it should make alert as VM problem.

For example, amazon.com IP address 205.251.242.103 hardcoded into VM. Once amazon.com has 205.251.242.104 that differs from hardcoded one - Zabbix should alert on that change.


Solution

  • You can use the Zabbix key net.dns.record[<ip>,name,<type>,<timeout>,<count>,<protocol>] to check how the host is resolving the name.

    You can use a trigger to compare strings since Zabbix version 5.0, for example:

    {host1:vfs.file.contents[/etc/os-release].last()}<>{host2:vfs.file.contents[/etc/os-release].last()}

    Depending on how the value is hardcoded, you will use different keys to extract the value. For example use vfs.file.contents[] if the hardcoded value is inside a file (like the hosts file).

    don't hardcode values if you can avoid it...

    See: https://www.zabbix.com/documentation/current/en/manual/config/items/itemtypes/zabbix_agent#net.dnsipnametypetimeoutcountprotocol