Davide
(Davide)
October 27, 2022, 9:08am
1
Hi All,
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 = []
if $_HOSTADDRESSES_4_1$:
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"])]
return args
special_agent_info["custom_check"] = custom_check_arguments
Thanks!
ChristianM
(Christian Michaelski)
October 27, 2022, 10:39am
2
Hi.
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?
Rg, Christian
Davide
(Davide)
October 27, 2022, 11:30am
3
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$”
ChristianM
(Christian Michaelski)
October 27, 2022, 1:58pm
4
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.
Davide
(Davide)
October 27, 2022, 2:36pm
5
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”