Search code examples
macroszabbix

How to list Zabbix macro values for a host


I've a Zabbix item which I can't get to work using a Zabbix macro.

The item key I start with looks like this:

web.page.regexp[10.0.0.100,/path,"(.*)",, \1]

And testing it with the following command also shows me nice results:

$ sudo zabbix_agentd -t 'web.page.regexp[10.0.0.100,/path,80,"(.*)",, \1]' --print
web.page.regexp[10.0.0.100,/path,80,"(.*)",, \1] [s|works]

But of course using the IP hardcoded isn't nice, that's why I want to use the predefined macros within the key, like this:

web.page.regexp[{HOST.IP1},/path,"(.*)",, \1]

But unfortunately this macro doesn't resolve to anything and the result looks like this:

web.page.regexp[10.0.0.100,/path,80,"(.*)",, \1] [s|]

Therefore I'd love to know if there's any way to list all the macro values for a specific host in Zabbix. Or is there a better way to use the {HOST.*} macros?

Using localhostis not an option for me - I want to test the public interface and I want to understand why the macros don't work as I expect it.

Cheers


Solution

  • Macro {HOST.IP1} should be expanded correctly for passive agent items (although it is suggested to just use {HOST.IP}). However, if your item is an active agent item, then {HOST.IP1} will expand to *UNKNOWN*, because an item is not attached to an interface in that case.

    As for macro list for a host, it was implemented for user macros under ZBXNEXT-210 and is already available in pre-2.5.0 trunk (which is not ready for production yet).