summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Hesse2015-06-29 09:38:57 +0200
committerChristian Hesse2015-06-29 09:38:57 +0200
commit45c086e831a96ba873af9dedc4e20bd6f058866a (patch)
tree5e04da23af6b2fb6788fc47da599eb6709b91de9
downloadaur-45c086e831a96ba873af9dedc4e20bd6f058866a.tar.gz
initial import of check_md_raid 0.7.2-8
-rw-r--r--.SRCINFO26
-rw-r--r--0001-use-python2.patch23
-rw-r--r--0002-strip-whitespace-from-state.patch25
-rw-r--r--0003-use-sudo-when-running-as-non-root-user.patch56
-rw-r--r--0004-make-checking-a-clean-state.patch26
-rw-r--r--PKGBUILD39
-rw-r--r--sudo2
7 files changed, 197 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..9c312f277f46
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,26 @@
+pkgbase = check_md_raid
+ pkgdesc = Linux Software RAID Monitoring Plugin for Nagios
+ pkgver = 0.7.2
+ pkgrel = 8
+ url = http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/Linux-Software-Raid-Plugin-for-32-2Dbit-and-64-2Dbit-systems/details
+ arch = any
+ license = GPL
+ depends = nagios
+ depends = python2
+ depends = mdadm
+ optdepends = sudo: check with non-root user
+ source = check_md_raid-0.7.2.py::http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=782&cf_id=24
+ source = 0001-use-python2.patch
+ source = 0002-strip-whitespace-from-state.patch
+ source = 0003-use-sudo-when-running-as-non-root-user.patch
+ source = 0004-make-checking-a-clean-state.patch
+ source = sudo
+ sha256sums = b85f0a77215870839cb18a74d9e38b594eaeda5c44ddc88aff8d2c2246f506f7
+ sha256sums = 9721c32d4b8124f2db54f41574008018a605567e50a59eb9ffcd98e99ba8db98
+ sha256sums = 527d98535f4cda98a468ea69f6a3cfb3a53e27ecbd2affc553985be70e29125a
+ sha256sums = 6267ecf8aff1da308216675f94e9e91f91349ed3b1054b8c8c1dc4d08ef632ad
+ sha256sums = 542d756357f4e8afd16962015428efccabb9f4410c873556a2b8d6e0cc37ca69
+ sha256sums = 4ffbd86b293665cd39a468257e3bf3fe35ce3cd429d7df576ef330762ad727d7
+
+pkgname = check_md_raid
+
diff --git a/0001-use-python2.patch b/0001-use-python2.patch
new file mode 100644
index 000000000000..cdfd425d211d
--- /dev/null
+++ b/0001-use-python2.patch
@@ -0,0 +1,23 @@
+From e91bf7547df083c705bb536d444d8dffb8d04006 Mon Sep 17 00:00:00 2001
+From: Christian Hesse <mail@eworm.de>
+Date: Wed, 30 Oct 2013 09:55:32 +0100
+Subject: [PATCH 1/4] use python2
+
+Signed-off-by: Christian Hesse <mail@eworm.de>
+---
+ check_md_raid | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/check_md_raid b/check_md_raid
+index 5788da4..999553f 100644
+--- a/check_md_raid
++++ b/check_md_raid
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/env python2
+ #
+ # Copyright Hari Sekhon 2007
+ #
+--
+2.4.3
+
diff --git a/0002-strip-whitespace-from-state.patch b/0002-strip-whitespace-from-state.patch
new file mode 100644
index 000000000000..ce561920c036
--- /dev/null
+++ b/0002-strip-whitespace-from-state.patch
@@ -0,0 +1,25 @@
+From dd3ebab3c41069ddd9420606fdbfe044fd11342a Mon Sep 17 00:00:00 2001
+From: Christian Hesse <mail@eworm.de>
+Date: Wed, 30 Oct 2013 09:56:19 +0100
+Subject: [PATCH 2/4] strip whitespace from state
+
+Signed-off-by: Christian Hesse <mail@eworm.de>
+---
+ check_md_raid | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/check_md_raid b/check_md_raid
+index 999553f..c29b6a2 100644
+--- a/check_md_raid
++++ b/check_md_raid
+@@ -109,6 +109,7 @@ def test_raid(verbosity):
+ for line in detailed_output:
+ if "State :" in line:
+ state = line.split(":")[-1][1:-1]
++ state = state.strip()
+ re_clean = re.compile('^clean(, no-errors)?$')
+ if not re_clean.match(state) and state != "active":
+ arrays_not_ok += 1
+--
+2.4.3
+
diff --git a/0003-use-sudo-when-running-as-non-root-user.patch b/0003-use-sudo-when-running-as-non-root-user.patch
new file mode 100644
index 000000000000..deea43d7715a
--- /dev/null
+++ b/0003-use-sudo-when-running-as-non-root-user.patch
@@ -0,0 +1,56 @@
+From cbbd2fb720e0974b3fea0fc2e1da297e72d07b34 Mon Sep 17 00:00:00 2001
+From: Christian Hesse <mail@eworm.de>
+Date: Wed, 30 Oct 2013 10:06:52 +0100
+Subject: [PATCH 3/4] use sudo when running as non-root user
+
+Signed-off-by: Christian Hesse <mail@eworm.de>
+---
+ check_md_raid | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
+
+diff --git a/check_md_raid b/check_md_raid
+index c29b6a2..3e2d55f 100644
+--- a/check_md_raid
++++ b/check_md_raid
+@@ -34,7 +34,8 @@ CRITICAL = 2
+ UNKNOWN = 3
+
+ # Full path to the mdadm utility check on the Raid state
+-BIN = "/sbin/mdadm"
++MDADM = "/usr/bin/mdadm"
++SUDO = "/usr/bin/sudo"
+
+ def end(status, message):
+ """exits the plugin with first arg as the return code and the second
+@@ -53,16 +54,22 @@ def end(status, message):
+ print "UNKNOWN: %s" % message
+ sys.exit(UNKNOWN)
+
++if not os.path.exists(MDADM):
++ end(UNKNOWN, "Raid utility '%s' cannot be found" % MDADM)
+
+-if os.geteuid() != 0:
+- end(UNKNOWN, "You must be root to run this plugin")
++if not os.access(MDADM, os.X_OK):
++ end(UNKNOWN, "Raid utility '%s' is not executable" % MDADM)
+
+-if not os.path.exists(BIN):
+- end(UNKNOWN, "Raid utility '%s' cannot be found" % BIN)
++if os.geteuid() != 0:
++ if not os.path.exists(SUDO):
++ end(UNKNOWN, "sudo is required if not running as root")
+
+-if not os.access(BIN, os.X_OK):
+- end(UNKNOWN, "Raid utility '%s' is not executable" % BIN)
++ if not os.access(SUDO, os.X_OK):
++ end(UNKNOWN, "sudo is not executable")
+
++ BIN = "%s %s" % (SUDO, MDADM)
++else:
++ BIN = MDADM
+
+ def find_arrays(verbosity):
+ """finds all MD arrays on local machine using mdadm and returns a list of
+--
+2.4.3
+
diff --git a/0004-make-checking-a-clean-state.patch b/0004-make-checking-a-clean-state.patch
new file mode 100644
index 000000000000..f122998cc6dc
--- /dev/null
+++ b/0004-make-checking-a-clean-state.patch
@@ -0,0 +1,26 @@
+From aa645b7441c68dde8c355b2fe16aef1d81635009 Mon Sep 17 00:00:00 2001
+From: Christian Hesse <mail@eworm.de>
+Date: Tue, 16 Jun 2015 10:47:52 +0200
+Subject: [PATCH 4/4] make checking a clean state
+
+Signed-off-by: Christian Hesse <mail@eworm.de>
+---
+ check_md_raid | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/check_md_raid b/check_md_raid
+index 3e2d55f..8ea23d3 100644
+--- a/check_md_raid
++++ b/check_md_raid
+@@ -117,7 +117,7 @@ def test_raid(verbosity):
+ if "State :" in line:
+ state = line.split(":")[-1][1:-1]
+ state = state.strip()
+- re_clean = re.compile('^clean(, no-errors)?$')
++ re_clean = re.compile('^clean(, (checking|no-errors))?$')
+ if not re_clean.match(state) and state != "active":
+ arrays_not_ok += 1
+ raidlevel = detailed_output[3].split()[-1]
+--
+2.4.3
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..6aaf2242d232
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,39 @@
+# Maintainer: Christian Hesse <mail@eworm.de>
+
+pkgname=check_md_raid
+pkgver=0.7.2
+pkgrel=8
+pkgdesc="Linux Software RAID Monitoring Plugin for Nagios"
+arch=('any')
+url="http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/Linux-Software-Raid-Plugin-for-32-2Dbit-and-64-2Dbit-systems/details"
+license=('GPL')
+depends=('nagios' 'python2' 'mdadm')
+optdepends=('sudo: check with non-root user')
+source=("${pkgname}-${pkgver}.py::http://exchange.nagios.org/components/com_mtree/attachment.php?link_id=782&cf_id=24"
+ '0001-use-python2.patch'
+ '0002-strip-whitespace-from-state.patch'
+ '0003-use-sudo-when-running-as-non-root-user.patch'
+ '0004-make-checking-a-clean-state.patch'
+ 'sudo')
+sha256sums=('b85f0a77215870839cb18a74d9e38b594eaeda5c44ddc88aff8d2c2246f506f7'
+ '9721c32d4b8124f2db54f41574008018a605567e50a59eb9ffcd98e99ba8db98'
+ '527d98535f4cda98a468ea69f6a3cfb3a53e27ecbd2affc553985be70e29125a'
+ '6267ecf8aff1da308216675f94e9e91f91349ed3b1054b8c8c1dc4d08ef632ad'
+ '542d756357f4e8afd16962015428efccabb9f4410c873556a2b8d6e0cc37ca69'
+ '4ffbd86b293665cd39a468257e3bf3fe35ce3cd429d7df576ef330762ad727d7')
+
+build() {
+ cp ${pkgname}-${pkgver}.py ${pkgname}
+ patch -Np1 < ${srcdir}/0001-use-python2.patch
+ patch -Np1 < ${srcdir}/0002-strip-whitespace-from-state.patch
+ patch -Np1 < ${srcdir}/0003-use-sudo-when-running-as-non-root-user.patch
+ patch -Np1 < ${srcdir}/0004-make-checking-a-clean-state.patch
+}
+
+package() {
+ install -D -m 0755 ${srcdir}/${pkgname} ${pkgdir}/usr/lib/monitoring-plugins/${pkgname}
+
+ install -d -m 0750 ${pkgdir}/etc/sudoers.d
+ install -D -m 0440 ${srcdir}/sudo ${pkgdir}/etc/sudoers.d/check_md_raid
+}
+
diff --git a/sudo b/sudo
new file mode 100644
index 000000000000..0301781d7347
--- /dev/null
+++ b/sudo
@@ -0,0 +1,2 @@
+nagios ALL = NOPASSWD: /usr/bin/mdadm --detail --scan
+nagios ALL = NOPASSWD: /usr/bin/mdadm --detail /dev/md*