From 888f1b8376ea4dd2a04feb40bfd325a25a8166e7 Mon Sep 17 00:00:00 2001 From: Alexx Roche Date: Thu, 23 Dec 2010 19:55:28 +0100 Subject: [PATCH] Initial version --- plugins/other/ipmi_fans | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100755 plugins/other/ipmi_fans diff --git a/plugins/other/ipmi_fans b/plugins/other/ipmi_fans new file mode 100755 index 00000000..ca48502f --- /dev/null +++ b/plugins/other/ipmi_fans @@ -0,0 +1,114 @@ +#! /usr/bin/perl -w +# +# This plugin will graph the chassis fan speed on a Dell PowerEdge Server +# via the ipmi-sensors tool. It has been tested on the following chassis: +# +# PE1850 +# +# To enable: +# +# ln -s /usr/share/munin/plugins/ipmi-fans /etc/munin/plugins/ipmi-fans +# +# Configuration parameters for /etc/munin/plugin-conf.d/munin-node +# +# [ipmi_fans] +# user - User that has permissions to run ipmi-sensors +# env.category sensors +# +# Parameters: +# +# config +# autoconf +# +# Author: Alexx Roche +# Built on the work of Justin Shepherd +# Revision: 2.0 2010/11/06 +# +#%# family=auto +#%# capabilities=autoconf + +use strict; + +my $IPMI; +if(-f "/usr/sbin/ipmi-sensors"){ $IPMI='/usr/sbin/ipmi-sensors'; } +unless($IPMI){ + $IPMI = `which ipmi-sensors 2>/dev/null|sed 's/.*no ipmi-sensors//'`; + #$IPMI = `echo -n \$(which ipmi-sensors)`; +} +chomp($IPMI); +unless($IPMI){ exit 1; } + +if ($ARGV[0] && $ARGV[0] eq "autoconf"){ + if (-f $IPMI){ + print "yes\n"; + }else{ + print "no ($IPMI does not exist)\n"; + exit(1); + } +}else{ + my $cmd = "$IPMI --verbose --sensors=\"\$(echo \$($IPMI |grep FAN|sed 's/:.*//'))\""; + #if ($ARGV[0] eq 'cmd'){ print $cmd; exit;}; + my @result = `$cmd`; + my (%val, $index); + $index=0; + my $count=0; + #Four of these seem to be unlabled, I'm going to guess that they are the CPU(s) and HDD(s) + my @unknown = ('HDD0','HDD1','CPU0','CPU1'); + foreach my $line (@result) { + $line =~ s/\s+/ /g; + $line =~ s/\s$//g; + if(!$line || $line eq ""){ + $index++; + next; + } + my ($key, $val) = split(/\: /, $line); + unless($key){ + # $index++; + # next; + } + if($key eq 'Sensor Name'){ + if($val eq 'Temp'){ + $val = $unknown[$count]; + $count++; + } + #my @data = split / /, $val; + #$data[2]=~s/^\(//; + #$data[2]=~s/\)$//; + #my($warn,$crit) = split/\//, $data[2]; + $val{$index}{'Probe Name'} = "$val"; + }elsif($key eq 'Upper Critical Threshold'){ + $val=~s/ .*$//; + next unless $val=~m/^\d+\.\d+$/; + $val{$index}{'Critical Threshold'} = "$val"; + }elsif($key eq 'Normal Max.'){ + $val=~s/ .*//; + $val{$index}{'Warning Threshold'} = $val; + }elsif($key eq 'Sensor Reading'){ + $val=~s/ .*//; + $val{$index}{'Reading'} = $val; + }elsif($key eq 'Sensor Max. Reading' && !$val{$index}{'Critical Threshold'}){ + $val=~s/ .*$//; + $val{$index}{'Critical Threshold'} = "$val"; + } + } + + if ($ARGV[0] && $ARGV[0] eq "config") { + print "graph_title IPMI - Fan Speeds\n"; + print "graph_args --base 1000 -l 0\n"; + print "graph_vlabel Speed in RPM\n"; + print "graph_category Sensors\n"; + foreach my $j (sort keys %val) { + print "probe_$j.label $val{$j}{'Probe Name'}\n"; + print "probe_$j.warning $val{$j}{'Warning Threshold'}\n"; + print "probe_$j.critical $val{$j}{'Critical Threshold'}\n"; + } + }else{ + foreach my $j (sort keys %val) { + if($val{$j}{'Reading'}){ + print "probe_$j.value $val{$j}{'Reading'}\n"; + } + } + } +} +exit(0); +