Execute plugin based on MACRO content?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
LillianNest
Posts: 1
Joined: Wed Jan 06, 2021 4:41 am

Execute plugin based on MACRO content?

Post 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,
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: Execute plugin based on MACRO content?

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked