2011-04-18 11:14:39 +02:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
#
|
|
|
|
# Munin plugin for MegaRAID
|
|
|
|
# This plugin can graph:- Currently Drive Temperature and Error Count
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
#---------------------
|
2011-05-22 16:28:07 +02:00
|
|
|
# Examples
|
2014-01-30 03:23:12 +01:00
|
|
|
# Create a symbolic link to MegaRaid_<AdapterNumber>_<temp|error|other|predictive>
|
2011-04-18 11:14:39 +02:00
|
|
|
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_temp
|
2011-05-22 16:28:07 +02:00
|
|
|
# graph temperature on adapter 0
|
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_error
|
2011-05-22 16:28:07 +02:00
|
|
|
# graph media errors on adapter 0
|
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_1_temp
|
2011-05-22 16:28:07 +02:00
|
|
|
# graph temperature on adapter 1
|
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
#---------------------
|
2011-05-22 16:28:07 +02:00
|
|
|
# Log
|
2011-04-18 11:14:39 +02:00
|
|
|
# Revision 0.1 2011/04/16 idobson
|
|
|
|
# -First version only basic support of the MegaRaid controller
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# Revision 0.2 2011/04/17 fkatzenb
|
|
|
|
# -Added bash statement to remove the log file created each time MegaCli64 is ran
|
|
|
|
# -Added a few comments and visual changes
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# Revision 1.0 2011/04/17 fkatzenb
|
|
|
|
# -Revamped Code to symbolic link for sensor type and future growth
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# Revision 1.1 2011/04/17 fkatzenb
|
|
|
|
# -Revised scalling
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
|
|
|
# Revision 1.2 2011/04/28 fkatzenb
|
|
|
|
# -Added support for graph_info support
|
|
|
|
# -Added warning & critical alerts support
|
|
|
|
# -Added data info
|
|
|
|
#
|
|
|
|
# Revision 2.0 2011/04/29 fkatzenb
|
|
|
|
# -Added remaining support for SMART Errors
|
|
|
|
#
|
|
|
|
# Revision 2.1 2011/04/29 fkatzenb
|
|
|
|
# -Added version information for in the graph description
|
|
|
|
#
|
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
#---------------------
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# Add the following to your /etc/munin/plugin-conf.d/munin-node:
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# [MegaRaid_*]
|
|
|
|
# user root
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
#---------------------
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
# Magic markers (optional - used by munin-config and installation scripts):
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
2011-04-18 11:14:39 +02:00
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
2011-05-22 16:28:07 +02:00
|
|
|
#
|
|
|
|
my $DisplayVer=2.1;
|
2011-04-18 11:14:39 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my $DevID=0; #Device Number found
|
|
|
|
my $DevData=0; #Device Data found
|
|
|
|
|
|
|
|
# Parse out Adapter number and parameter desired from file name and remove whitespace
|
|
|
|
my $Parameters=`basename $0 | sed 's/^MegaRaid_//g' | tr '_' '-'` ;
|
|
|
|
chomp $Parameters;
|
|
|
|
my ($Adapter,$Type)=split(/-/,$Parameters);
|
|
|
|
|
|
|
|
# Locate MegaCli64 application and remove whitespace
|
|
|
|
my $Command=`which MegaCli64`;
|
|
|
|
chomp $Command;
|
|
|
|
|
|
|
|
# Use this to define future parameters to monitor
|
|
|
|
my %config = (
|
|
|
|
temp => {
|
|
|
|
lookfor => 'Drive Temperature :',
|
2011-05-22 16:28:07 +02:00
|
|
|
label => 'Temp',
|
2011-04-18 11:14:39 +02:00
|
|
|
title => "MegaRAID Adapter $Adapter: Drive Temperatures",
|
2012-08-23 17:56:01 +02:00
|
|
|
vlabel => 'Celsius',
|
2011-05-22 16:28:07 +02:00
|
|
|
graph_args => '--base 1000 -l 0',
|
|
|
|
warning => '55',
|
|
|
|
critical => '65',
|
|
|
|
info_tag => "Temperature (C)",
|
|
|
|
description => "Internal Temperatures for drives on Adapter $Adapter."
|
2011-04-18 11:14:39 +02:00
|
|
|
},
|
|
|
|
error => {
|
|
|
|
lookfor => 'Media Error Count: ',
|
2011-05-22 16:28:07 +02:00
|
|
|
label => 'Media Err',
|
|
|
|
title => "MegaRAID Adapter $Adapter: Media Errors (SMART)",
|
2012-08-23 17:56:01 +02:00
|
|
|
vlabel => 'Number of Errors',
|
2011-05-22 16:28:07 +02:00
|
|
|
graph_args => '--base 1000 -l 0',
|
|
|
|
warning => '',
|
|
|
|
critical => '',
|
|
|
|
info_tag => "Media Errors (SMART)",
|
|
|
|
description => "Number of SMART errors related to the drive's media on Adapter $Adapter."
|
|
|
|
},
|
|
|
|
other => {
|
|
|
|
lookfor => 'Other Error Count: ',
|
|
|
|
label => 'Other Err',
|
|
|
|
title => "MegaRAID Adapter $Adapter: Others Errors (SMART)",
|
2012-08-23 17:56:01 +02:00
|
|
|
vlabel => 'Number of Errors',
|
2011-05-22 16:28:07 +02:00
|
|
|
graph_args => '--base 1000 -l 0',
|
|
|
|
warning => '',
|
|
|
|
critical => '',
|
|
|
|
info_tag => "Other Errors (SMART)",
|
|
|
|
description => "Number of SMART errors not related to the drive's media on Adapter $Adapter."
|
2011-04-18 11:14:39 +02:00
|
|
|
},
|
2011-05-22 16:28:07 +02:00
|
|
|
predictive => {
|
|
|
|
lookfor => 'Predictive Failure Count: ',
|
|
|
|
label => 'Predictive Err',
|
|
|
|
title => "MegaRAID Adapter $Adapter: Predictive Errors (SMART)",
|
2012-08-23 17:56:01 +02:00
|
|
|
vlabel => 'Number of Errors',
|
2011-05-22 16:28:07 +02:00
|
|
|
graph_args => '--base 1000 -l 0',
|
|
|
|
warning => '',
|
|
|
|
critical => '',
|
|
|
|
info_tag => "Predictive Errors (SMART)",
|
|
|
|
description => "Number of SMART errors for each drive on Adapter $Adapter."
|
|
|
|
}
|
2011-04-18 11:14:39 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
#Auto config options
|
|
|
|
if ($ARGV[0] and $ARGV[0] eq "autoconf" ) {
|
|
|
|
if (-e $Command ) {
|
|
|
|
print "yes\n";
|
|
|
|
exit 0;
|
|
|
|
} else {
|
|
|
|
print "no\n";
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Read Output of MegaRaid command
|
|
|
|
$Command.=" -PDList -a".$Adapter;
|
|
|
|
my @Output=qx($Command);
|
|
|
|
|
|
|
|
#Munin Config Options
|
|
|
|
if ($ARGV[0] and $ARGV[0] eq "config"){
|
|
|
|
print "graph_title $config{$Type}->{title}\n";
|
2012-08-23 17:56:01 +02:00
|
|
|
print "graph_vlabel $config{$Type}->{vlabel}\n";
|
2011-04-18 11:14:39 +02:00
|
|
|
print "graph_args $config{$Type}->{graph_args}\n";
|
|
|
|
print "graph_scale yes\n";
|
|
|
|
print "graph_category disk\n";
|
2011-05-22 16:28:07 +02:00
|
|
|
print "graph_info $config{$Type}->{description} <br />Generated by MegaRaid_, Version $DisplayVer<br />\n";
|
2011-04-18 11:14:39 +02:00
|
|
|
|
|
|
|
foreach my $Line (@Output) {
|
|
|
|
$Line=~ s/\r//g;
|
|
|
|
$Line=~ s/\n//g;
|
|
|
|
|
|
|
|
#Find the device ID
|
|
|
|
if ( $Line=~ m/Slot Number: /i ) {
|
|
|
|
$DevID=$Line;
|
|
|
|
$DevID=~ s/Slot Number: //;
|
2011-05-22 16:28:07 +02:00
|
|
|
print "A".$Adapter."_D".$DevID."_$Type.label A$Adapter:D$DevID $config{$Type}->{label}\n";
|
|
|
|
print "A".$Adapter."_D".$DevID."_$Type.info Adapter: $Adapter / Drive: $DevID - $config{$Type}->{info_tag}\n";
|
|
|
|
if ($config{$Type}->{warning} ne '' ) {
|
|
|
|
print "A".$Adapter."_D".$DevID."_$Type.warning $config{$Type}->{warning}\n";
|
|
|
|
}
|
|
|
|
if ($config{$Type}->{critical} ne '') {
|
|
|
|
print "A".$Adapter."_D".$DevID."_$Type.critical $config{$Type}->{critical}\n";
|
|
|
|
}
|
2011-04-18 11:14:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#Actually dump the data
|
|
|
|
foreach my $Line (@Output) {
|
|
|
|
$Line=~ s/\r//g;
|
|
|
|
$Line=~ s/\n//g;
|
|
|
|
|
|
|
|
#Find the device ID
|
|
|
|
if ( $Line=~ m/Slot Number: /i ) { $DevID=$Line; $DevID=~ s/Slot Number: //; chomp $DevID; }
|
|
|
|
|
|
|
|
#Find the data and print it out
|
|
|
|
if ( $Line=~ m/$config{$Type}->{lookfor}/i ) {
|
|
|
|
$DevData=$Line;
|
|
|
|
$DevData=~s/$config{$Type}->{lookfor}//;
|
|
|
|
$DevData=~s/C.*//;
|
|
|
|
chomp $DevData;
|
|
|
|
print "A".$Adapter."_D".$DevID."_$Type.value $DevData\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#Remove log file created by running MegaCli
|
|
|
|
unlink "MegaSAS.log";
|
|
|
|
|
|
|
|
exit 0;
|