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
Problem parsing a perl command from GUi
Problem parsing a perl command from GUi
You do not have the required permissions to view the files attached to this post.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Problem parsing a perl command from GUi
It took me a while to get this right but, I got it.
With exerything else how you described, lets make
It really doesn't like the double quote so we needed to change to single quote and escape it.
With exerything else how you described, lets make
Code: Select all
$ARG2$ = '\'E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\\' COPE ITF 90000'Re: Problem parsing a perl command from GUi
Hi Scott, unfortunately that doesnt command seem to work for me. I tested from both the GUI and the command line and neither provided a good return code. From the command line the response I got was as if the command hadn't completed. See examples below:
Example from command line:
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '\'E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\\' COPE ITF 90000'
>
Response from GUI:
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
Kind regards
DB
Example from command line:
./check_nrpe -H 10.215.222.35 -c check_filename_age.pl -a '\'E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\\' COPE ITF 90000'
>
Response from GUI:
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
Kind regards
DB
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Problem parsing a perl command from GUi
Can you post what you have in your check command on the windows client?
I tested this on a Linux machine, so my file path and nrpe client were a little different.
I tested this on a Linux machine, so my file path and nrpe client were a little different.
Re: Problem parsing a perl command from GUi
The shell can interpret the \ character as a line break, and it look like it's doing that in your test above. I'd play around with the single quotes and escaping any characters that appear to be interpreted by the shell. It's probably very close to working, it's just a matter of being escaped properly. I'd try wrapping everything after -a in single quotes and see what happens.
Re: Problem parsing a perl command from GUi
Try this one and let us know if it changes anything:
Code: Select all
\''E:\\SchenkerEDI\\SAMSUNG\\CARRIER\\COPE\\ReturnsManifest\\Archive\\'\'' COPE ITF 90000'-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Problem parsing a perl command from GUi
I've dug into these deeper and believe I have the solution for you...
First, edit the top of the check_filename_age.pl and just under use strict; add
no warnings 'all';
Then, lets make your $ARG2$ read
That should do it...
First, edit the top of the check_filename_age.pl and just under use strict; add
no warnings 'all';
Then, lets make your $ARG2$ read
Code: Select all
'E:/SchenkerEDI/SAMSUNG/CARRIER/COPE/ReturnsManifest/Archive/ COPE ITF 90000'
Re: Problem parsing a perl command from GUi
Hi all,
Thanks for your help, we finally got there with Scott's last suggestion of adding "no warnings "all";" to the perl script.
My colleague who is a perl developer has also now located the Nagios config guide for perl scripting so hopefully that will be able to consult that first off and not ask too many other questions.
Happy to close off this issue.
Many thanks
DB
Thanks for your help, we finally got there with Scott's last suggestion of adding "no warnings "all";" to the perl script.
My colleague who is a perl developer has also now located the Nagios config guide for perl scripting so hopefully that will be able to consult that first off and not ask too many other questions.
Happy to close off this issue.
Many thanks
DB