Module: check_mk
Branch: master
Commit: 949d50cacfb121d0c427d43a0c2e8afe2755305c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=949d50cacfb121…
Author: Markus Lengler <ml(a)lengler-it.de>
Date: Tue Jan 24 16:14:43 2012 +0100
new check: check for linux dmraid (bios supported)
Signed-off-by: Florian Heigl <fh(a)mathias-kettner.de>
---
agents/plugins/dmraid | 19 ++++++++++
checkman/dmraid.ldisks | 20 +++++++++++
checkman/dmraid.pdisks | 20 +++++++++++
checks/dmraid | 88 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 147 insertions(+), 0 deletions(-)
diff --git a/agents/plugins/dmraid b/agents/plugins/dmraid
new file mode 100755
index 0000000..5bcec9b
--- /dev/null
+++ b/agents/plugins/dmraid
@@ -0,0 +1,19 @@
+#!/bin/sh
+echo '<<<dmraid>>>'
+
+STATUS=$(dmraid -r)
+if [ $? != 0 ]; then
+ exit 1
+fi
+
+# Name und Status ausgeben
+dmraid -s | grep -e ^name -e ^status
+
+# Diskname der Raidplatten ausgeben
+DISKS=$(echo "$STATUS" | cut -f1 -d\:)
+
+for disk in $DISKS ; do
+ device=$(cat /sys/block/$(basename $disk)/device/model )
+ status=$(echo "$STATUS" | grep ^${disk})
+ echo "$status Model: $device"
+done
diff --git a/checkman/dmraid.ldisks b/checkman/dmraid.ldisks
new file mode 100644
index 0000000..3d6fac1
--- /dev/null
+++ b/checkman/dmraid.ldisks
@@ -0,0 +1,20 @@
+title: Check state of logical disks of DMRaid
+agents: linux
+author: Markus Lengler <ml(a)lengler-it.de>
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the state of logical disks (RAID arrays) of a BIOS-controlled
software raid,
+ that is managed using the dmraid utility. The types of supported arrays can be listed
using {dmraid -l}.
+ The Linux agent detects such array if the {dmraid} command line utility is found in the
shell
+ search path.
+
+ The utility {dmraid} is available/installable in all linux distributions.
+
+ The check will return CRITICAL if the raid is inconsitent or WARNING if the array if
currently rebuilding. An OK status will be returned as OK.
+
+item:
+ One item is generated per logical disk found on the system.
+
+inventory:
+ All logical disks are automatically inventorized.
diff --git a/checkman/dmraid.pdisks b/checkman/dmraid.pdisks
new file mode 100644
index 0000000..41806f9
--- /dev/null
+++ b/checkman/dmraid.pdisks
@@ -0,0 +1,20 @@
+title: Check state of phyiscal disks of DMRaid
+agents: linux
+author: Markus Lengler <ml(a)lengler-it.de>
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the state of physical disks (RAID arrays) of a BIOS-controlled
software raid,
+ that is managed using the dmraid utility. The types of supported arrays can be listed
using {dmraid -l}.
+ The Linux agent detects such array if the {dmraid} command line utility is found in the
shell
+ search path.
+
+ The utility {dmraid} is available/installable in all linux distributions.
+
+ The check will return CRITICAL if a disk is failed or missing/removed. Otherwise it will
return OK.
+
+item:
+ One item is generated per physical disk found in a DM array.
+
+inventory:
+ All logical disks are automatically inventorized.
diff --git a/checks/dmraid b/checks/dmraid
new file mode 100644
index 0000000..dbdafb3
--- /dev/null
+++ b/checks/dmraid
@@ -0,0 +1,88 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+#
+# check_mk 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 in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# Author: Markus Lengler <ml(a)lengler-it.de>
+
+
+# Example outputs from agent:
+#
+#<<<dmraid>>>
+#name : isw_ebdabbedfh_system
+#status : ok
+#/dev/sda: isw, "isw_ebdabbedfh", GROUP, ok, 976773166 sectors, data@ 0 Model:
WDC WD5002ABYS-5
+#/dev/sdb: isw, "isw_ebdabbedfh", GROUP, ok, 976773166 sectors, data@ 0 Model:
WDC WD5002ABYS-5
+
+
+def inventory_dmraid(checkname, info):
+ inventory=[]
+ for line in info:
+ if checkname == "dmraid.ldisks" and line[0] == "name":
+ inventory.append((line[2], None))
+ elif checkname == "dmraid.pdisks" and
line[0].startswith("/dev/sd"):
+ item = line[0].split(":")[0]
+ inventory.append((item, None))
+ return inventory
+
+
+def check_dmraid_pdisks(item, _no_params, info):
+ for line in info:
+ if line[0].startswith("/dev/sd"):
+ disk = line[0].split(":")[0]
+ if disk == item:
+ status = line[4].split(",")[0]
+ if status == "ok":
+ pos=line.index("Model:")
+ model=" ".join(line[pos+1:])
+ return (0, "OK - Online (%s)" % model)
+ else:
+ return (2, "CRIT - Error on disk!!")
+ return (2, "CRIT - Missing disk!!")
+
+
+def check_dmraid_ldisks(item, _no_params, info):
+ LDISK_FOUND=False
+ for line in info:
+ if LDISK_FOUND:
+ if line[0] == "status":
+ status = line[2]
+ if status == "ok":
+ return(0, "OK - state is %s" % status)
+ else:
+ return(2, "CRIT - %s" % status)
+ if line[0] == "name" and line[2] == item:
+ LDISK_FOUND=True
+
+ return (3, "UNKNOWN - incomplete data from agent")
+
+
+check_info['dmraid.pdisks'] = \
+ (check_dmraid_pdisks, "RAID PDisk %s", 0, inventory_dmraid)
+
+
+check_info['dmraid.ldisks'] = \
+ (check_dmraid_ldisks, "RAID LDisk %s", 0, inventory_dmraid)