contrib-munin/plugins/sensors/ipmi_therm

104 lines
3.0 KiB
Plaintext
Raw Normal View History

2010-12-07 10:17:25 +01:00
#! /usr/bin/perl -w
#
# This plugin will graph the chassis temp sensors 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-therm /etc/munin/plugins/ipmi-therm
#
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
#
# [ipmi_therm]
2010-12-23 19:47:23 +01:00
# user - User that has permissions to run ipmi-sensors
2010-12-07 10:17:25 +01:00
# env.category sensors
#
# Parameters:
#
# config
# autoconf
#
# Author: Alexx Roche <munin-ipmi-plugin@alexx.net>
# Built on the work of Justin Shepherd <galstrom21@gmail.com>
# Revision: 1.3 2011/01/10
2010-12-07 10:17:25 +01:00
#
#%# 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|grep Temp";
my @result = `$cmd`;
my (%val, $index);
$index=0;
2010-12-23 19:47:23 +01:00
my $count=0;
2010-12-07 10:17:25 +01:00
#Four of these seem to be unlabled, I'm going to guess that they are the CPU(s) and HDD(s)
2010-12-23 19:47:23 +01:00
my @unknown = ('CPU0','CPU1','HDD0','HDD1');
2010-12-07 10:17:25 +01:00
foreach my $line (@result) {
$line =~ s/\s+/ /g;
$line =~ s/\s$//g;
next if ($line eq "");
my ($list, $field, $value, $state) = split(/\: /, $line);
#print "L: $list F: $field V: $value S: $state\n";
if($field=~m/^(Temp|Ambient|Planar|Riser)/) {
my $f=$1;
if($f eq 'Temp'){
2010-12-23 19:47:23 +01:00
$f = $unknown[$count];
$count++;
2010-12-07 10:17:25 +01:00
}
my @data = split / /, $value;
$data[2]=~s/^\(//;
$data[2]=~s/\)$//;
if($f){
my($warn,$crit) = split/\//, $data[2];
2010-12-23 19:47:23 +01:00
unless($warn=~m/\d+/){ $warn = 0; }
unless($crit=~m/\d+/){ $crit = 200; }
2010-12-07 10:17:25 +01:00
$val{$index}{'Probe Name'} = "$f";
$val{$index}{'Reading'} = "$data[0]";
2010-12-23 19:47:23 +01:00
$val{$index}{'Warning Threshold'} = ($crit - $warn);
2010-12-07 10:17:25 +01:00
$val{$index}{'Critical Threshold'} = "$crit";
$index++;
}
}
}
if ($ARGV[0] && $ARGV[0] eq "config") {
print "graph_title IPMI sensors - Temperature Probes\n";
print "graph_args --base 1000 -l 0\n";
print "graph_vlabel Temperature in Celsius\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";
2010-12-07 10:17:25 +01:00
}
}else{
foreach my $j (sort keys %val) {
if($val{$j}{'Reading'}){
print "probe_$j.value $val{$j}{'Reading'}\n";
}
}
}
}
exit(0);