check_file_age 2.1.4 fails to find files
Posted: Tue Jan 10, 2017 2:39 pm
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:
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:
Installed packages with "nagios" or "perl" in the package name:
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
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
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