Page 1 of 1

Execute plugin based on MACRO content?

Posted: Wed Jan 06, 2021 4:46 am
by LillianNest
All,

I have some plugins that must be running depending of MACRO value.

For example:

IF $_HOST_APP_VERSION$ is 4.14.4, run the plugin $USER1$/app.py

BUT if $_HOST_APP_VERSION$ is 4.14SLA, run the plugin $USER1$/especiacommand.py

Unfortunately our automation the hostgroup for the HOSTS are always hostgroup-app-4.14. So, I cannot switch it by service definition. In the past, I have passing the __APP_VERSION macro at the command line and switch it inside the plugin. But now, the plugins are completely different with different actions.

Is there any way that I can configure Nagios services or commands to run different plugins based on Macro value?

Thank you,

Re: Execute plugin based on MACRO content?

Posted: Wed Jan 06, 2021 6:18 pm
by benjaminsmith
Hi Lillain,

Welcome to the Nagios Community Forum. And a happy new year!
Is there any way that I can configure Nagios services or commands to run different plugins based on Macro value?
The usual course of action in this situation would be to write a wrapper script for the plugin that would check the condition and then call the appropriate plugin.

You can store host variables that can be called by the wrapper script using the custom variables.

Custom Object Variables

Hope that helps.

--Benjamin