ports/129733: net-mgmt/nagios-geom: incorrect GEOM status report from check_geom nagios plugin
Eygene Ryabinkin
rea-fbsd at codelabs.ru
Mon Dec 22 14:00:09 UTC 2008
The following reply was made to PR ports/129733; it has been noted by GNATS.
From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
To: bug-followup at FreeBSD.org
Cc:
Subject: Re: ports/129733: net-mgmt/nagios-geom: incorrect GEOM status
report from check_geom nagios plugin
Date: Mon, 22 Dec 2008 16:50:55 +0300
Update to 1.3 is ready -- it fixes the mentioned problem and some
other things. Andriy and others: if you'll be able to test the
new version -- it will be very good.
PS: it is better to apply the patch with '-p3 -E' ;))
--- update-to-1.3.diff begins here ---
=46rom 73e003703b43cac8e83e8c9491adeabe5249e664 Mon Sep 17 00:00:00 2001
=46rom: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
Date: Mon, 22 Dec 2008 16:10:50 +0300
Subject: [PATCH] net-mgmt/nagios-geom: update port to version 1.3
Since original author removes the old packages from the download
site, I implanted the plugin sources right into the port.
Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
---
net-mgmt/nagios-geom/Makefile | 9 +-
net-mgmt/nagios-geom/distinfo | 3 -
net-mgmt/nagios-geom/files/check_geom.in | 132 +++++++++++++++++=
++++
net-mgmt/nagios-geom/files/patch-add-perfdata | 27 ++++
net-mgmt/nagios-geom/files/patch-check_geom | 38 ------
net-mgmt/nagios-geom/files/patch-fix-class-logics | 29 +++++
6 files changed, 194 insertions(+), 44 deletions(-)
delete mode 100644 net-mgmt/nagios-geom/distinfo
create mode 100755 net-mgmt/nagios-geom/files/check_geom.in
create mode 100644 net-mgmt/nagios-geom/files/patch-add-perfdata
delete mode 100644 net-mgmt/nagios-geom/files/patch-check_geom
create mode 100644 net-mgmt/nagios-geom/files/patch-fix-class-logics
diff --git a/net-mgmt/nagios-geom/Makefile b/net-mgmt/nagios-geom/Makefile
index 8e95a41..1413df2 100644
--- a/net-mgmt/nagios-geom/Makefile
+++ b/net-mgmt/nagios-geom/Makefile
@@ -6,11 +6,10 @@
#
=20
PORTNAME=3D geom
-PORTVERSION=3D 1.0
+PORTVERSION=3D 1.3
CATEGORIES=3D net-mgmt
-MASTER_SITES=3D http://www.geocities.com/ntb4real/proj/
PKGNAMEPREFIX=3D nagios-
-DISTNAME=3D check_geom
+DISTFILES=3D
=20
MAINTAINER=3D rea-fbsd at codelabs.ru
COMMENT=3D Nagios plug-in to get geom(8) components status
@@ -18,6 +17,10 @@ COMMENT=3D Nagios plug-in to get geom(8) components stat=
us
USE_PERL5=3D yes
NO_WRKSUBDIR=3D yes
NO_BUILD=3D yes
+PATCH_STRIP=3D -p1
+
+post-extract:
+ @${CP} ${FILESDIR}/check_geom.in ${WRKSRC}/check_geom
=20
do-install:
@${MKDIR} ${PREFIX}/libexec/nagios
diff --git a/net-mgmt/nagios-geom/distinfo b/net-mgmt/nagios-geom/distinfo
deleted file mode 100644
index e78bca1..0000000
--- a/net-mgmt/nagios-geom/distinfo
+++ /dev/null
@@ -1,3 +0,0 @@
-SIZE (check_geom.tar.gz) =3D 1545
-MD5 (check_geom.tar.gz) =3D ec6aa5d69b0693a71cf0129016507d0f
-SHA256 (check_geom.tar.gz) =3D ba787de1ac1df400151f8bde5b3db15af4ca2f3a3e8=
ec4f48c30052091f30444
diff --git a/net-mgmt/nagios-geom/files/check_geom.in b/net-mgmt/nagios-geo=
m/files/check_geom.in
new file mode 100755
index 0000000..e35be05
--- /dev/null
+++ b/net-mgmt/nagios-geom/files/check_geom.in
@@ -0,0 +1,132 @@
+#!/usr/bin/perl -w
+
+# Copyright (c) 2007, 2008=20
+# Written by Nathan Butcher
+#
+# Released under the GNU Public License
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Version: 1.3
+# This plugin currently supports :=20
+# "mirror", "stripe", "raid3", "concat", and "shsec" GEOM classes.
+# With a bit of fondling, it could be expanded to recognize other classes
+#
+# Usage: check_geom <geom class> <volume>
+# Example: check_geom mirror gm0
+# WARNING gm0 DEGRADED, { ad0 , ad1 (32%) }
+
+use strict;
+
+my %ERRORS=3D('DEPENDENT'=3D>4,'UNKNOWN'=3D>3,'OK'=3D>0,'WARNING'=3D>1,'CR=
ITICAL'=3D>2);
+my $state=3D"UNKNOWN";
+my $msg=3D"FAILURE";
+
+if ($#ARGV < 1) {
+ print "Not enough arguments!\nUsage: $0 <class> <device>\n";
+ exit $ERRORS{$state};
+}
+
+if ($^O ne 'freebsd') {
+ print "This plugin is only applicable on FreeBSD.\n";
+ exit $ERRORS{$state};
+}
+
+my $class=3D$ARGV[0];
+my $volume=3D$ARGV[1];
+my $statcommand=3D"geom $class status";
+
+if (! open STAT, "$statcommand|") {
+ print ("$state $statcommand returns no result!");
+ exit $ERRORS{$state};
+}
+
+my $found=3D0;
+my $unit=3D0;
+my $status=3D"";
+my $name=3D"";
+my $compo=3D"";
+
+while(<STAT>) {
+
+ chomp;
+ if ($found) {
+ if (/^\s*$class\//) {
+ last;
+ } else {
+ my ($vgh) =3D /\s+(.*)/;
+ $compo=3D"$compo , $vgh";
+ $found++;
+ }
+ }
+
+ if (/^\s*$class\/$volume\s/) {
+ ($name, $status, $compo) =3D /(\S+)\s+(\S+)\s+(.*)$/;
+ $found=3D1;
+ }
+=09
+}
+
+close(STAT);
+
+if (! $found ) {
+ $state =3D "CRITICAL";
+ $msg =3D sprintf "%s/%s does not exist and/or is not responding!\n", $cla=
ss, $volume;
+ print $state, " ", $msg;
+ exit ($ERRORS{$state});
+}
+
+if (($class eq "mirror" || $class eq "raid3") && $status =3D~ /COMPLETE/ )=
{
+ $state =3D "OK";
+}
+
+if ($class eq "stripe" || $class eq "concat" || $class eq "shsec" && $stat=
us =3D~ /UP/) {
+ $state =3D "OK";
+}
+
+if ($state ne "OK") {
+
+ if ($class eq "mirror" && $found >=3D 2 ) {
+ $state =3D "WARNING";
+ } else {
+ $state =3D "CRITICAL";
+ }
+
+ if ($class eq "raid3") {
+=09
+ $statcommand=3D"geom $class list $volume";
+ =09
+ if (! open STAT, "$statcommand|") {
+ print ("$state $statcommand returns no result!");
+ exit $ERRORS{$state};
+ }
+
+ while (<STAT>) {
+ next unless (/Components:/);
+ ($unit) =3D /([0-9]+)$/;
+ next;
+ }
+
+ if ($found =3D=3D $unit) {
+ $state =3D "WARNING";
+ }
+
+ }
+}
+
+#goats away!
+$msg =3D sprintf "%s/%s %s { %s }\n", $class, $volume, $status, $compo;
+print $state, " ", $msg;
+exit ($ERRORS{$state});
diff --git a/net-mgmt/nagios-geom/files/patch-add-perfdata b/net-mgmt/nagio=
s-geom/files/patch-add-perfdata
new file mode 100644
index 0000000..8a4adb5
--- /dev/null
+++ b/net-mgmt/nagios-geom/files/patch-add-perfdata
@@ -0,0 +1,27 @@
+From 744414f51abef503f3a8abc5e7c1eca7d0e5bb64 Mon Sep 17 00:00:00 2001
+From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+Date: Mon, 22 Dec 2008 16:01:37 +0300
+Subject: [PATCH] Add performance data to the plugin output
+
+Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+---
+ check_geom | 4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/check_geom b/check_geom
+index e7c776c..d8c1402 100755
+--- a/check_geom
++++ b/check_geom
+@@ -127,6 +127,8 @@ if ($state ne "OK") {
+ }
+=20
+ #goats away!
+-$msg =3D sprintf "%s/%s %s { %s }\n", $class, $volume, $status, $compo;
++my $perfdata =3D sprintf "%s=3D%d;;;0;", "geom_" . $class, $found;
++$msg =3D sprintf "%s/%s %s { %s }|%s\n", $class, $volume, $status, $compo,
++ $perfdata;
+ print $state, " ", $msg;
+ exit ($ERRORS{$state});
+--=20
+1.6.0.4
+
diff --git a/net-mgmt/nagios-geom/files/patch-check_geom b/net-mgmt/nagios-=
geom/files/patch-check_geom
deleted file mode 100644
index 39d54aa..0000000
--- a/net-mgmt/nagios-geom/files/patch-check_geom
+++ /dev/null
@@ -1,38 +0,0 @@
---- check_geom.orig 2007-07-03 15:55:27.000000000 +0400
-+++ check_geom 2008-08-20 15:30:57.000000000 +0400
-@@ -33,6 +33,7 @@
- my %ERRORS=3D('DEPENDENT'=3D>4,'UNKNOWN'=3D>3,'OK'=3D>0,'WARNING'=3D>1,'C=
RITICAL'=3D>2);
- my $state=3D"UNKNOWN";
- my $msg=3D"FAILURE";
-+my $perfdata=3D"";
-=20
- if ($#ARGV < 1) {
- print "Not enough arguments!\nUsage: $0 <class> <device>\n";
-@@ -63,7 +64,7 @@
-=20
- chomp;
- if ($found) {
-- if (/^$class\//) {
-+ if (/^\s*$class\//) {
- last;
- } else {
- my ($vgh) =3D /\s+(.*)/;
-@@ -72,7 +73,7 @@
- }
- }
-=20
-- if (/$class\/$volume/) {
-+ if (/^\s*$class\/$volume/) {
- ($name, $status, $compo) =3D /(\S+)\s+(\S+)\s+(.*)$/;
- $found=3D1;
- }
-@@ -127,6 +128,7 @@
- }
-=20
- #goats away!
--$msg =3D sprintf "%s/%s %s { %s }\n", $class, $volume, $status, $compo;
--print $state, " ", $msg;
-+$msg =3D sprintf "%s/%s %s { %s }", $class, $volume, $status, $compo;
-+$perfdata =3D sprintf "%s=3D%d;;;0;", "geom_" . $class, $found;
-+print $state, " ", $msg, "|", $perfdata, "\n";
- exit ($ERRORS{$state});
diff --git a/net-mgmt/nagios-geom/files/patch-fix-class-logics b/net-mgmt/n=
agios-geom/files/patch-fix-class-logics
new file mode 100644
index 0000000..37f6f00
--- /dev/null
+++ b/net-mgmt/nagios-geom/files/patch-fix-class-logics
@@ -0,0 +1,29 @@
+From 11298f4b29f7efcb653fb8c7ea4e00bc5bfc1935 Mon Sep 17 00:00:00 2001
+From: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+Date: Mon, 22 Dec 2008 15:59:40 +0300
+Subject: [PATCH] Fix plugin logics: add extra braces
+
+The idea was to check that the provider belongs to the set of classes
+and look for the 'OK' status.
+
+Signed-off-by: Eygene Ryabinkin <rea-fbsd at codelabs.ru>
+---
+ check_geom | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/check_geom b/check_geom
+index e35be05..e7c776c 100755
+--- a/check_geom
++++ b/check_geom
+@@ -92,7 +92,7 @@ if (($class eq "mirror" || $class eq "raid3") && $status=
=3D~ /COMPLETE/ ) {
+ $state =3D "OK";
+ }
+=20
+-if ($class eq "stripe" || $class eq "concat" || $class eq "shsec" && $sta=
tus =3D~ /UP/) {
++if (($class eq "stripe" || $class eq "concat" || $class eq "shsec") && $s=
tatus =3D~ /UP/) {
+ $state =3D "OK";
+ }
+=20
+--=20
+1.6.0.4
+
--=20
1.6.0.4
--- update-to-1.3.diff ends here ---
--=20
Eygene
_ ___ _.--. #
\`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard
/ ' ` , __.--' # to read the on-line manual =20
)/' _/ \ `-_, / # while single-stepping the kernel.
`-'" `"\_ ,_.-;_.-\_ ', fsc/as #
_.-'_./ {_.' ; / # -- FreeBSD Developers handbook=20
{_.-``-' {_/ #
More information about the freebsd-ports-bugs
mailing list