I’m writing a special agent and I’d like to know if there a way to use “Nagios macros” within a check.
Something like this:
def custom_check_arguments(params, hostname, ipaddress):
args = 
ipaddress = $_HOSTADDRESSES_4_1$
args += ["-i", ipaddress]
if "auth" in params:
args += ["-u", params["auth"]["user"]]
args += ["-p", passwordstore_get_cmdline("%s", params["auth"]["password"])]
special_agent_info["custom_check"] = custom_check_arguments
In your example, the ipaddress is given by the variable ipaddres in the function call. hy do you want to overwrite it with a macro?
Hi, thanks for reply!
I would like to check a “secondary” IP Address rather then “firs” IP.
The nagios macro for the first secondary IP (could be more than one) is “$_HOSTADDRESSES_4_1$”
I Think you can use custom host attributes as macros at this point. When you create a custom host attribute with name my_attr, you can use it as $_MY_ATTR$ in there.
Which is what I’d like to do, but I didn’t find yet a way to use these macro within a “special agent” check.
I know that it is possible with custom active checks or via “datasource command”