mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
Initial version
This commit is contained in:
parent
831916f727
commit
d025504545
136
plugins/other/megaraid-controller-information
Executable file
136
plugins/other/megaraid-controller-information
Executable file
@ -0,0 +1,136 @@
|
||||
#!/usr/bin/perl -w
|
||||
#
|
||||
# Munin plugin for MegaRAID
|
||||
# This plugin can graph:- Currently Drive Temperature and Error Count
|
||||
#
|
||||
#---------------------
|
||||
#
|
||||
# Create a symbolic link to MegaRaid_{AdapterNumber}_{temp|error}
|
||||
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_temp
|
||||
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_0_error
|
||||
# ln -s /usr/share/munin/plugins/MegaRaid_ /etc/munin/plugins/MegaRaid_1_temp
|
||||
#
|
||||
#---------------------
|
||||
#
|
||||
# $Log$
|
||||
# Revision 0.1 2011/04/16 idobson
|
||||
# -First version only basic support of the MegaRaid controller
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Revision 1.0 2011/04/17 fkatzenb
|
||||
# -Revamped Code to symbolic link for sensor type and future growth
|
||||
#
|
||||
# Revision 1.1 2011/04/17 fkatzenb
|
||||
# -Revised scalling
|
||||
#
|
||||
#---------------------
|
||||
#
|
||||
# Add the following to your /etc/munin/plugin-conf.d/munin-node:
|
||||
#
|
||||
# [MegaRaid_*]
|
||||
# user root
|
||||
#
|
||||
#---------------------
|
||||
#
|
||||
#
|
||||
# Magic markers (optional - used by munin-config and installation scripts):
|
||||
#
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf
|
||||
#
|
||||
|
||||
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 :',
|
||||
label => 'Drive Temp',
|
||||
title => "MegaRAID Adapter $Adapter: Drive Temperatures",
|
||||
vtitle => 'Celsius',
|
||||
graph_args => '--base 1000 -l 0'
|
||||
},
|
||||
error => {
|
||||
lookfor => 'Media Error Count: ',
|
||||
label => 'Drive Media Err',
|
||||
title => "MegaRAID Adapter $Adapter: Media Errors",
|
||||
vtitle => 'Number of Errors',
|
||||
graph_args => '--base 1000 -l 0'
|
||||
},
|
||||
);
|
||||
|
||||
#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";
|
||||
print "graph_vtitle $config{$Type}->{vtitle}\n";
|
||||
print "graph_args $config{$Type}->{graph_args}\n";
|
||||
print "graph_scale yes\n";
|
||||
print "graph_category disk\n";
|
||||
|
||||
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: //;
|
||||
print "A".$Adapter."_D".$DevID."_$Type.label Adapter:$Adapter/Disk:$DevID $config{$Type}->{label}\n";
|
||||
}
|
||||
}
|
||||
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;
|
Loading…
Reference in New Issue
Block a user