Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / other / ipmi_fans @ 2d6bc2dd

Historique | Voir | Annoter | Télécharger (3,36 ko)

1
#! /usr/bin/perl -w
2
#
3
# This plugin will graph the chassis fan speed on a Dell PowerEdge Server
4
# via the ipmi-sensors tool. It has been tested on the following chassis:
5
# 
6
#   PE1850
7
#
8
# To enable: 
9
#
10
#   ln -s /usr/share/munin/plugins/ipmi-fans /etc/munin/plugins/ipmi-fans
11
#
12
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
13
#
14
# [ipmi_fans]
15
#   user 	 - User that has permissions to run the omreport binary
16
#   env.omreport - Path to the omreport binary
17
#
18
# Parameters:
19
#
20
#   config
21
#   autoconf
22
#
23
# Author: Alexx Roche <munin-ipmi-plugin@alexx.net>
24
# Built on the work of Justin Shepherd <galstrom21@gmail.com>
25
# Revision: 2.1  2011/01/10
26
#
27
#%# family=auto
28
#%# capabilities=autoconf
29

    
30
use strict;
31

    
32
my $IPMI;
33
if(-f "/usr/sbin/ipmi-sensors"){ $IPMI='/usr/sbin/ipmi-sensors'; }
34
unless($IPMI){
35
   $IPMI = `which ipmi-sensors 2>/dev/null|sed 's/.*no ipmi-sensors//'`; 
36
   #$IPMI = `echo -n \$(which ipmi-sensors)`;
37
}
38
chomp($IPMI);
39
unless($IPMI){ exit 1; }
40

    
41
if ($ARGV[0] && $ARGV[0] eq "autoconf"){
42
    if (-f $IPMI){
43
	print "yes\n";
44
    }else{
45
	print "no ($IPMI does not exist)\n";
46
	exit(1);
47
    }
48
}else{
49
        my $cmd = "$IPMI --verbose --sensors=\"\$(echo \$($IPMI |grep FAN|sed 's/:.*//'))\"";
50
	#if ($ARGV[0] eq 'cmd'){ print $cmd; exit;};
51
        my @result = `$cmd`;
52
        my (%val, $index);
53
	$index=0;
54
	my $count=0;
55
	#Four of these seem to be unlabled, I'm going to guess that they are the CPU(s) and HDD(s)
56
	my @unknown = ('HDD0','HDD1','CPU0','CPU1');
57
        foreach my $line (@result) {
58
                $line =~ s/\s+/ /g;
59
                $line =~ s/\s$//g;
60
                if(!$line || $line eq ""){
61
			$index++;
62
			next;
63
		}
64
                my ($key, $val) = split(/\: /, $line);
65
		unless($key){
66
		#	$index++;
67
	#		next;
68
		}
69
                if($key eq 'Sensor Name'){
70
		    if($val eq 'Temp'){
71
			$val = $unknown[$count];
72
			$count++;
73
		    }
74
                    #my @data = split / /, $val;
75
		    #$data[2]=~s/^\(//;
76
		    #$data[2]=~s/\)$//;
77
		    	#my($warn,$crit) = split/\//, $data[2];
78
                   $val{$index}{'Probe Name'} = "$val";
79
		}elsif($key eq 'Upper Critical Threshold'){
80
		    $val=~s/ .*$//;
81
		    next unless $val=~m/^\d+\.\d+$/;
82
                    $val{$index}{'Critical Threshold'} = "$val";
83
		}elsif($key eq 'Normal Max.'){
84
		    $val=~s/ .*//;
85
                    $val{$index}{'Warning Threshold'} = $val;
86
                }elsif($key eq 'Sensor Reading'){
87
		    $val=~s/ .*//;
88
                    $val{$index}{'Reading'} = $val;
89
		}elsif($key eq 'Sensor Max. Reading' && !$val{$index}{'Critical Threshold'}){
90
		    $val=~s/ .*$//;
91
                    $val{$index}{'Critical Threshold'} = "$val";
92
		}
93
        }
94

    
95
        if ($ARGV[0] && $ARGV[0] eq "config") {
96
                print "graph_title IPMI - Fan Speeds\n";
97
                print "graph_args --base 1000 -l 0\n";
98
                print "graph_vlabel Speed in RPM\n";
99
                print "graph_category Sensors\n";
100
                foreach my $j (sort keys %val) {
101
                        print "probe_$j\.label $val{$j}{'Probe Name'}\n";
102
                        print "probe_$j\.warning $val{$j}{'Warning Threshold'}\n";
103
                        print "probe_$j\.critical $val{$j}{'Critical Threshold'}\n";
104
                }
105
        }else{
106
             foreach my $j (sort keys %val) {
107
                if($val{$j}{'Reading'}){
108
		   print "probe_$j.value $val{$j}{'Reading'}\n";
109
		}
110
             }
111
        }
112
}
113
exit(0);
114