[Pkg-nagios-devel] Bug#865021: check_backuppc: does host limits all wrong

Peter Palfrader weasel at debian.org
Sun Jun 18 19:17:12 UTC 2017


Package: nagios-plugins-contrib
Version: 21.20170222
Severity: normal
Tags: patch

check_backuppc takes an option to limit the check to only a named host:

| root at ajax:~# sudo -u backuppc /usr/lib/nagios/plugins/check_backuppc --hostname anguilla
| BACKUPPC OK - (0/1) failures

Unfortunately, this limit operation takes each hostname from the list of hosts
as a regex to match against the provided argument.  This results in the check
for host marmorata to fail because host orata fails:

| root at ajax:~# sudo -u backuppc /usr/lib/nagios/plugins/check_backuppc --hostname marmorata
| BACKUPPC CRITICAL - (1/2) failures, 1 critical

| root at ajax:~# sudo -u backuppc /usr/lib/nagios/plugins/check_backuppc --hostname marmorata --verbose  --verbose  --verbose
| Host marmorata state Status_idle with error: 
| Host orata state Status_idle with error: no ping response
| BACKUPPC CRITICAL - (orata (no ping response), ) critical


--- /usr/lib/nagios/plugins/check_backuppc	2017-06-04 20:52:07.342331799 +0200
+++ /tmp/check_backuppc	2017-06-18 21:11:55.713091252 +0200
@@ -150,7 +150,7 @@
 
 foreach my $host (@hostsDesired, @hostsExcluded)
 {
-	if (not grep {/$host/} keys(%Status))
+	if (not grep {$_ eq $host} keys(%Status))
 	{
 		print("BACKUPPC UNKNOWN - Unknown host ($host)\n");
 		exit $ERRORS{'UNKNOWN'};
@@ -161,8 +161,8 @@
 foreach my $host (sort(keys(%Status)))
 {
 	next if $host =~ /^ /;
-	next if (@hostsDesired and not grep {/$host/} @hostsDesired);
-	next if (@hostsExcluded and grep {/$host/} @hostsExcluded);
+	next if (@hostsDesired and not grep {$_ eq $host} @hostsDesired);
+	next if (@hostsExcluded and grep {$_ eq $host} @hostsExcluded);
 	next if ($backupOnly and $Status{$host}{'type'} eq 'archive');
 	next if ($archiveOnly and $Status{$host}{'type'} ne 'archive');
 	$hostCount++;

| root at ajax:~# sudo -u backuppc /tmp/check_backuppc  --hostname marmorata
| BACKUPPC OK - (0/1) failures
| root at ajax:~# sudo -u backuppc /tmp/check_backuppc  --hostname marmorata --verbose --verbose --verbose
| Host marmorata state Status_idle with error: 
| BACKUPPC OK - (0/1) failures
| root at ajax:~#

Cheers,
-- 
                            |  .''`.       ** Debian **
      Peter Palfrader       | : :' :      The  universal
 https://www.palfrader.org/ | `. `'      Operating System
                            |   `-    https://www.debian.org/



More information about the Pkg-nagios-devel mailing list