From a5f8da6aa09e1a7e15adadd29df70cb1ce9c7a32 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 10 Jul 2014 12:55:14 +0200 Subject: [PATCH] Support LLD discovery for MegaRAID controllers --- zabbix_conf/raid_megaraid.conf | 5 ++++- zabbix_scripts/disco_raid_megaraid_sudo | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 zabbix_scripts/disco_raid_megaraid_sudo diff --git a/zabbix_conf/raid_megaraid.conf b/zabbix_conf/raid_megaraid.conf index 8fa0bf6..4222f48 100644 --- a/zabbix_conf/raid_megaraid.conf +++ b/zabbix_conf/raid_megaraid.conf @@ -9,4 +9,7 @@ # You can add a simple trigger on this check like: # { hostname:raid.mega.status.str( OK ) }=0 -UserParameter=raid.mega.status,/usr/bin/sudo /var/lib/zabbix/bin/check_raid_megaraid_sudo +UserParameter=raid.mega.status[*],/usr/bin/sudo /var/lib/zabbix/bin/check_raid_megaraid_sudo -s $1 -o $2 -m $3 + +# Discover if there's a controller to check +UserParameter=raid.mega.discovery,/usr/bin/sudo /var/lib/zabbix/bin/disco_raid_megaraid_sudo diff --git a/zabbix_scripts/disco_raid_megaraid_sudo b/zabbix_scripts/disco_raid_megaraid_sudo new file mode 100644 index 0000000..ce1f7be --- /dev/null +++ b/zabbix_scripts/disco_raid_megaraid_sudo @@ -0,0 +1,40 @@ +#!/usr/bin/perl -w + +use strict; +use JSON; + +my $json; +@{$json->{data}} = (); + +my $megacli = undef; + +if (-x '/opt/MegaRAID/MegaCli/MegaCli64'){ + $megacli = '/opt/MegaRAID/MegaCli/MegaCli64'; +} +elsif (-x '/opt/MegaRAID/MegaCli/MegaCli'){ + $megacli = '/opt/MegaRAID/MegaCli/MegaCli'; +} + +unless($megacli){ + print to_json($json); + exit(0); +} + +my $adapters = 0; +open (ADPCOUNT, "$megacli -adpCount -NoLog |") + || die "error: Could not execute MegaCli -adpCount"; + +while () { + if ( m/Controller Count:\s*(\d+)/ ) { + $adapters = $1; + last; + } +} +close ADPCOUNT; + +if ($adapters > 0){ + push @{$json->{data}}, {"{#CONTROLLERNO}" => $adapters}; +} + +print to_json($json); +exit(0);