Error with check_file_age in nagios-plugins 2.1.4

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
cherdt
Posts: 5
Joined: Mon Nov 30, 2015 12:08 pm
Contact:

Error with check_file_age in nagios-plugins 2.1.4

Post by cherdt »

I recently updated from nagios-plugins 2.1.3 to 2.1.4 and I am now getting erroneous "file not found" errors when using check_file_age:

Code: Select all

# /usr/lib64/nagios/plugins/check_file_age -w 300 -c 900 /etc/motd
FILE_AGE CRITICAL: File not found - "/etc/motd"

# ls -l /etc/motd
-rw-r--r--. 1 root root 0 Jan 12  2010 /etc/motd
I reviewed the changes from 2.1.3 to 2.1.4 and it looks to me like it is looking for the file name with quotes:

Code: Select all

$opt_f = '"' . $opt_f . '"';
This is on a CentOS 6.8 system. I tried the same on a CentOS 7 system and it worked as expected. Maybe due to a difference in Perl versions?

CentOS 6 Perl v5.10.1
CentOS 7 Perl v5.16.3
cherdt
Posts: 5
Joined: Mon Nov 30, 2015 12:08 pm
Contact:

Re: Error with check_file_age in nagios-plugins 2.1.4

Post by cherdt »

This definitely looks like a compatibility issue for Perl versions < 5.16. From perldelta - what is new for perl v5.16.0 - The glob operator :
On OSes other than VMS, Perl's glob operator (and the <...> form) use File::Glob underneath. File::Glob splits the pattern into words, before feeding each word to its bsd_glob function.

There were several inconsistencies in the way the split was done. Now quotation marks (' and ") are always treated as shell-style word delimiters (that allow whitespace as part of a word) and backslashes are always preserved, unless they exist to escape quotation marks. Before, those would only sometimes be the case, depending on whether the pattern contained whitespace. Also, escaped whitespace at the end of the pattern is no longer stripped [perl #40470].
One possible solution would be to quote the string only if it contains whitespace, e.g.:

Code: Select all

$opt_f = '"' . $opt_f '"' if ($opt_f =~ m/\s/);
cherdt
Posts: 5
Joined: Mon Nov 30, 2015 12:08 pm
Contact:

Re: Error with check_file_age in nagios-plugins 2.1.4

Post by cherdt »

Looks like a fix has been proposed and a pull-request submitted for this:
https://github.com/pmkane/nagios-plugin ... d347d0fcb0
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Error with check_file_age in nagios-plugins 2.1.4

Post by rkennedy »

Just getting to this for the day - looks like you were able to resolve it!

Did you have any further questions at this point?
Former Nagios Employee
Locked