From d21824d09f29c96f7ac328c021aafcf1143dcf6b Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 9 Jul 2014 16:30:41 +0200 Subject: [PATCH] Add discovery script for mdadm based RAID devices --- zabbix_conf/raid_mdadm.conf | 2 +- zabbix_scripts/disco_raid_mdadm | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 zabbix_scripts/disco_raid_mdadm diff --git a/zabbix_conf/raid_mdadm.conf b/zabbix_conf/raid_mdadm.conf index 09b4c8f..8f75437 100644 --- a/zabbix_conf/raid_mdadm.conf +++ b/zabbix_conf/raid_mdadm.conf @@ -9,4 +9,4 @@ # You can add a simple trigger on this check like: # { hostname:raid.sw.status.str( OK ) }=0 -UserParameter=raid.sw.status,/var/lib/zabbix/bin/check_raid_mdadm +UserParameter=raid.sw.status[*],/var/lib/zabbix/bin/check_raid_mdadm --device=$1 diff --git a/zabbix_scripts/disco_raid_mdadm b/zabbix_scripts/disco_raid_mdadm new file mode 100644 index 0000000..2a9b47a --- /dev/null +++ b/zabbix_scripts/disco_raid_mdadm @@ -0,0 +1,16 @@ +#!/usr/bin/perl -w + +use strict; +use JSON; + +my $json; +@{$json->{data}} = (); + +open FILE, "< /proc/mdstat" or die "Can't open /proc/mdadm : $!"; +foreach my $line () { + next unless ($line =~ m/^(md\d+)+\s*:/); + my ($md,undef,$status,$level) = split(/\ /, $line); + push @{$json->{data}}, {"{#DEVICE}" => $md, "{#STATUS}" => $status, "{#LEVEL}" => $level}; +} +print to_json($json); +exit(0);