Problem parsing a perl command from GUi
Posted: Thu Jan 05, 2012 11:48 pm
Hi There,
I am having a problem getting the same results form the Nagios server command line to that when I am trying to parse the same command as a stored entry via the GUI.
A collague of mine has helped by editing the count_file.pl script which is available on the forum, and allowed me to parse extra information I.e. the start of a file name, the file extension and then the maximum number of seconds in which a file of this type should be in the directory.
The command which works from the command line is as follows:
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE2 ITF 90000'
Found a file within age 90000 secs.
I checked against a couple of different variables just to ensure validity I.e:
(minus last directory slashes)
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive" COPE2 ITF 90000'
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
(changed file name to lower case):
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" cope2 itf 90000'
No file(cope2*.itf) found within last 90000 secs.
All good up to here.
Now I come to create a new service via the GUI to replicate the above and I get an error which I cannot circumvent (from the servers services config file):
define service {
host_name SYDNAS1
service_description Monitor COPE Returns Manifest Files
display_name Monitor COPE Returns Manifest Files
check_command check_nrpe_directory_2!check_filename_age.pl!'"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE ITF 90000'!!!!!!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period File Age Checks
notification_interval 180
notification_period File Age Checks
contact_groups Test_Infrastructure
register 1
}
where - check_nrpe_directory_2 = $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
where - $ARG1$ = check_filename_age.pl
where - $ARG2$ = '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE ITF 90000'
All that I notice different is the 6 x exclamation marks following the command, is this possibly being passed to the perl script on the server or is it an internal working of the Nagios config itself?
Error from the Nagios GUI is as follows:
Usage: "Directory name" "File Name Start" "File Extension" "Age of files in secs"
examples: c:\\Perl\\scripts\\check_filename_age.pl <dir> RFNTRCU dat 90000
If I remove the trailing slashes from the directory path from the GUI I get the following error:
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
No file(COPE*.ITF) found within last 90000 secs.
Note the very bottom line is incorrect as the file is present as proven when running the same command from the command line, albeit with slightly different variables.
Can you please point me down the road as to where I might be going wrong, I have spent quite a lot of time chopping and changing the command but I can't get it to work correctly atall!
Many thanks
DB
I am having a problem getting the same results form the Nagios server command line to that when I am trying to parse the same command as a stored entry via the GUI.
A collague of mine has helped by editing the count_file.pl script which is available on the forum, and allowed me to parse extra information I.e. the start of a file name, the file extension and then the maximum number of seconds in which a file of this type should be in the directory.
The command which works from the command line is as follows:
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE2 ITF 90000'
Found a file within age 90000 secs.
I checked against a couple of different variables just to ensure validity I.e:
(minus last directory slashes)
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive" COPE2 ITF 90000'
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
(changed file name to lower case):
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" cope2 itf 90000'
No file(cope2*.itf) found within last 90000 secs.
All good up to here.
Now I come to create a new service via the GUI to replicate the above and I get an error which I cannot circumvent (from the servers services config file):
define service {
host_name SYDNAS1
service_description Monitor COPE Returns Manifest Files
display_name Monitor COPE Returns Manifest Files
check_command check_nrpe_directory_2!check_filename_age.pl!'"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE ITF 90000'!!!!!!
max_check_attempts 5
check_interval 5
retry_interval 1
check_period File Age Checks
notification_interval 180
notification_period File Age Checks
contact_groups Test_Infrastructure
register 1
}
where - check_nrpe_directory_2 = $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$
where - $ARG1$ = check_filename_age.pl
where - $ARG2$ = '"E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\" COPE ITF 90000'
All that I notice different is the 6 x exclamation marks following the command, is this possibly being passed to the perl script on the server or is it an internal working of the Nagios config itself?
Error from the Nagios GUI is as follows:
Usage: "Directory name" "File Name Start" "File Extension" "Age of files in secs"
examples: c:\\Perl\\scripts\\check_filename_age.pl <dir> RFNTRCU dat 90000
If I remove the trailing slashes from the directory path from the GUI I get the following error:
Use of uninitialized value in subtraction (-) at c:\Perl\scripts\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
Use of uninitialized value in subtraction (-) at c:\\Perl\\scripts\\check_filename_age.pl line 42.
No file(COPE*.ITF) found within last 90000 secs.
Note the very bottom line is incorrect as the file is present as proven when running the same command from the command line, albeit with slightly different variables.
Can you please point me down the road as to where I might be going wrong, I have spent quite a lot of time chopping and changing the command but I can't get it to work correctly atall!
Many thanks
DB