Page 1 of 1

Error with check_file_age in nagios-plugins 2.1.4

Posted: Thu Jan 05, 2017 1:14 pm
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

Re: Error with check_file_age in nagios-plugins 2.1.4

Posted: Thu Jan 05, 2017 2:20 pm
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/);

Re: Error with check_file_age in nagios-plugins 2.1.4

Posted: Thu Jan 05, 2017 2:32 pm
by cherdt
Looks like a fix has been proposed and a pull-request submitted for this:
https://github.com/pmkane/nagios-plugin ... d347d0fcb0

Re: Error with check_file_age in nagios-plugins 2.1.4

Posted: Thu Jan 05, 2017 5:00 pm
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?