check_file_age 2.1.4 fails to find files

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
User avatar
drcentner
Posts: 20
Joined: Tue Jun 14, 2016 11:39 am
Location: Virginia, USA

check_file_age 2.1.4 fails to find files

Post by drcentner »

The check_file_age script began failing on one of our servers when check_file_age was updated to version 2.1.4 via yum update. I have isolated the failure to line 80 of the check_file_age script:

Code: Select all

 73 $opt_f = shift unless ($opt_f);
 74
 75 if (! $opt_f) {
 76         print "FILE_AGE UNKNOWN: No file specified\n";
 77         exit $ERRORS{'UNKNOWN'};
 78 }
 79
 80 $opt_f = '"' . $opt_f . '"';
 81
 82 # Check that file(s) exists (can be directory or link)
 83 $perfdata = "";
 84 $output = "";
 85 @filelist = glob($opt_f);
 86
 87 foreach $filename (@filelist) {
 88         unless (-e $filename) {
 89                 if ($opt_i) {
 90                         $result = 'OK';
 91                         print "FILE_AGE $result: $filename doesn't exist, but ignore-missing was set\n";
 92                         exit $ERRORS{$result};
 93
 94                 } else {
 95                         print "FILE_AGE CRITICAL: File not found - $filename\n";
 96                         exit $ERRORS{'CRITICAL'};
 97                 }
 98         }

Code: Select all

[root@hostname plugins]# ./check_file_age -f /tmp
FILE_AGE CRITICAL: File not found - "/tmp"
[root@hostname plugins]# ls -ld /tmp
drwxrwxrwt. 7 root root 4096 Jan 10 14:27 /tmp
It appears that the "unless (-e $filename)" is failing to find the file when quotation marks are injected into $opt_f. This same exact script works fine on one of our RHEL 7 systems, but not on one of our RHEL 6.8 systems. Verified the contents of each script are identical by running a diff against them. As a temporary workaround, I have commented out line 80 on the affected system, and the script is working. However, this would be likely to break on a future yum update if the cause of this issue is not resolved. All updates available to the affected system via yum have been installed, and it was rebooted after the kernel upgrade. Please advise.

Details of the affected system:

Code: Select all

[root@hostname plugins]# cat /etc/*release
Red Hat Enterprise Linux Server release 6.8 (Santiago)
Red Hat Enterprise Linux Server release 6.8 (Santiago)
[root@hostname plugins]# uname -a
Linux hostname.domain.com 2.6.32-642.11.1.el6.x86_64 #1 SMP Wed Oct 26 10:25:23 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
Installed packages with "nagios" or "perl" in the package name:

Code: Select all

[root@hostname plugins]# yum list installed | grep -e nagios -e perl
nagios-common.x86_64             3.5.1-1.el6               @epel-limited
nagios-plugins.x86_64            2.1.4-2.el6               @epel-limited
nagios-plugins-disk.x86_64       2.1.4-2.el6               @epel-limited
nagios-plugins-file_age.x86_64   2.1.4-2.el6               @epel-limited
nagios-plugins-load.x86_64       2.1.4-2.el6               @epel-limited
nagios-plugins-log.x86_64        2.1.4-2.el6               @epel-limited
nagios-plugins-perl.x86_64       2.1.4-2.el6               @epel-limited
nagios-plugins-procs.x86_64      2.1.4-2.el6               @epel-limited
nagios-plugins-swap.x86_64       2.1.4-2.el6               @epel-limited
nagios-plugins-users.x86_64      2.1.4-2.el6               @epel-limited
perl.x86_64                      4:5.10.1-141.el6_7.1      @rhel-x86_64-server-6
perl-Digest-HMAC.noarch          1.01-22.el6               @rhel-x86_64-server-6
perl-Digest-SHA1.x86_64          2.12-2.el6                @rhel-x86_64-server-6
perl-IO-Socket-SSL.noarch        1.31-3.el6_8.2            @rhel-x86_64-server-6
perl-Module-Pluggable.x86_64     1:3.90-141.el6_7.1        @rhel-x86_64-server-6
perl-Net-LibIDN.x86_64           0.12-3.el6                @rhel-x86_64-server-6
perl-Net-SMTP-TLS.noarch         0.12-1.el6.rf             @rpmforge
perl-Net-SSLeay.x86_64           1.35-10.el6_8.1           @rhel-x86_64-server-6
perl-Pod-Escapes.x86_64          1:1.04-141.el6_7.1        @rhel-x86_64-server-6
perl-Pod-Simple.x86_64           1:3.13-141.el6_7.1        @rhel-x86_64-server-6
perl-Time-HiRes.x86_64           4:1.9721-141.el6_7.1      @rhel-x86_64-server-6
perl-libs.x86_64                 4:5.10.1-141.el6_7.1      @rhel-x86_64-server-6
perl-parent.x86_64               1:0.221-141.el6_7.1       @rhel-x86_64-server-6
perl-version.x86_64              3:0.77-141.el6_7.1        @rhel-x86_64-server-6
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: check_file_age 2.1.4 fails to find files

Post by dwhitfield »

First off, thanks for posting the fix.

Unfortunately, we are not the package maintainers. We are working to correct that.

If you'd like a fix that yum won't break, you could install the plugins from source. There are instructions toward the bottom of https://support.nagios.com/kb/article.php?id=96
User avatar
drcentner
Posts: 20
Joined: Tue Jun 14, 2016 11:39 am
Location: Virginia, USA

Re: check_file_age 2.1.4 fails to find files

Post by drcentner »

You're welcome.


dwhitfield wrote:Unfortunately, we are not the package maintainers. We are working to correct that.

If you'd like a fix that yum won't break, you could install the plugins from source. There are instructions toward the bottom of https://support.nagios.com/kb/article.php?id=96
Understood. We only use that script on 2 servers in our environment, and it's only failing on one server. Due to the limited scope of the failure, and my existing internal yum-dependent automations, I'd probably just stick with yum and the occasional annoyance of having to comment it out again. However, what can I (or you) do to inform the package maintainers of this issue?
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: check_file_age 2.1.4 fails to find files

Post by mcapra »

Here's the info page for the Nagios Plugins package provided by the EPEL repos:
https://admin.fedoraproject.org/pkgdb/p ... s-plugins/

You can file a bug report for file_age here:
https://apps.fedoraproject.org/packages ... s-file_age
Former Nagios employee
https://www.mcapra.com/
User avatar
drcentner
Posts: 20
Joined: Tue Jun 14, 2016 11:39 am
Location: Virginia, USA

Re: check_file_age 2.1.4 fails to find files

Post by drcentner »

Thanks for the info. https://bugzilla.redhat.com/show_bug.cgi?id=1410039 was already submitted, and the fix is already in github https://github.com/nagios-plugins/nagio ... f80cbb03c5. This thread can be closed.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_file_age 2.1.4 fails to find files

Post by rkennedy »

Sounds good! /closed
Former Nagios Employee
Locked