Optional parameters in plugins
Posted: Fri Jan 23, 2015 1:45 pm
Hi all,
We've written a nagios plugin using a bash shell script. It works fine, takes a few arguments, and we'd like to allow for optional parameters. I'm not sure a good way to do it however?
The plugin definition looks like this in nagios_command.cfg:
Right now a sample call to the plugin call looks like this:
...so we have 5 parameters. What if a sixth or seventh parameter is optional, is there a way to pass a 'blank' value in there in some circumstances?
Is it ok to define $ARG6 and $ARG7 in the define command above and call the plugin like this?
Worst case I suppose I can create another command definition and call it my_nagios_plugin_2 or something and pass those optional arguments to it, but wondered if there's a way to do it as described above.
Thanks!
We've written a nagios plugin using a bash shell script. It works fine, takes a few arguments, and we'd like to allow for optional parameters. I'm not sure a good way to do it however?
The plugin definition looks like this in nagios_command.cfg:
Code: Select all
define command {
command_line /usr/lib/my_shell_script.sh -H $ARG1$ -P $ARG2$ -I $ARG3$ -T $ARG4$ -W $ARG5$
command_name my_nagios_plugin
}
Code: Select all
my_nagios_plugin!a-server-name!9200!/a/server/path!250!150
Is it ok to define $ARG6 and $ARG7 in the define command above and call the plugin like this?
Code: Select all
my_nagios_plugin!a-server-name!9200!/a/server/path!250!150!!
Thanks!