2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/other/ipmi_therm
2011-12-18 15:10:31 +01:00

100 lines
2.9 KiB
Perl
Executable File

#! /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]
# user - User that has permissions to run the omreport binary
# 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.0 2010/01/28
#
#%# 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;
#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;
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'){
$f = $unknown[$index];
}
my @data = split / /, $value;
$data[2]=~s/^\(//;
$data[2]=~s/\)$//;
if($f){
my($warn,$crit) = split/\//, $data[2];
$val{$index}{'Probe Name'} = "$f";
$val{$index}{'Reading'} = "$data[0]";
$val{$index}{'Warning Threshold'} = "$warn";
$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";
}
}else{
foreach my $j (sort keys %val) {
if($val{$j}{'Reading'}){
print "probe_$j.value $val{$j}{'Reading'}\n";
}
}
}
}
exit(0);