I am writing a Python plugin to integrate my own monitoring system into Nagios. I am having trouble in having Nagios executing my script using the correct parameters that I am trying to pass.
So first of all here are my command.cfg and localhost.cfg extracts controlling my script:
>>>>> /usr/local/nagios/etc/commands.cfg
Code: Select all
define command {
command_name teapinagios01
command_line $USER1$/te-plugins/te-api-nagios01.py gen-data -t $ARG1$
}Code: Select all
define service {
use generic-service
host_name localhost
service_description Check Latency-Network Test-testId: 28936
check_command teapinagios01!get-data! -t 28936
}Code: Select all
parser = optparse.OptionParser()
parser.add_option('-t', '--testid', action='store', type="int", help='Test ID to monitor')
(options, args) = parser.parse_args()
if (args[0] == 'gen-data'):
<...SNIP..>I tried a zillion of combinations between command{} and service{} configurations, but I was never able to make NagiosXI run the command understanding the meaning of the command line parameters. On NagiosXI console my script works fine:
Code: Select all
[root@localhost]# ./te-api-nagios01.py -help
Usage: te-api-nagios01.py [options]
Options:
-h, --help show this help message and exit
-t TESTID, --testid=TESTID Test ID to monitor
[root@localhost te-plugins]# ./te-api-nagios01.py gen-data -t 28936
(options, args) from Python optparse:
options: {'testid': 28936}
args: ['gen-data']
SCRIPT OUTPUT >>> OK - Average Latency is 241I am getting desperate after so much time spent on this..any help please?
Thanks,
Wally