mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
115 lines
3.4 KiB
Perl
Executable File
115 lines
3.4 KiB
Perl
Executable File
#! /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 the omreport binary
|
|
# env.omreport - Path to the omreport binary
|
|
#
|
|
# Parameters:
|
|
#
|
|
# config
|
|
# autoconf
|
|
#
|
|
# Author: Alexx Roche <munin-ipmi-plugin@alexx.net>
|
|
# Built on the work of Justin Shepherd <galstrom21@gmail.com>
|
|
# Revision: 2.1 2011/01/10
|
|
#
|
|
#%# 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);
|
|
|