Projet

Général

Profil

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

root / plugins / sensors / omreport_temp @ e5ce7492

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

1
#! /usr/bin/perl -w
2
#
3
# Copyright (C) 2008 Rackspace US, Inc. <http://www.rackspace.com>
4
#
5
# This program is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License
7
# as published by the Free Software Foundation; version 2 dated June,
8
# 1991.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
17
# 
18
#
19
# This plugin will graph the chassis temp sensors on a Dell PowerEdge Server
20
# via the omreport tool. It has been tested on the following chassis:
21
# 
22
#   PE2650/6650
23
#   PE2850/6850
24
#   PE2950
25
#
26
# To enable, link omreport_temps to this file. E.g.
27
#
28
#   ln -s /usr/share/node/node/plugins/omreport_temps /etc/munin/plugins/omreport_temps
29
#
30
# Configuration parameters for /etc/munin/plugin-conf.d/munin-node
31
#
32
# [omreport_*]
33
#   user 	 - User that has permissions to run the omreport binary
34
#   env.omreport - Path to the omreport binary
35
#
36
# Parameters:
37
#
38
#   config
39
#   autoconf
40
#
41
# Author: Justin Shepherd <galstrom21@gmail.com>
42
# Revision: 1.5  2008/10/22
43
#
44
#%# family=auto
45
#%# capabilities=autoconf
46

    
47
use strict;
48

    
49
my $omreport = $ENV{"omreport"} || "/usr/bin/omreport";
50

    
51
if ($ARGV[0] && $ARGV[0] eq "autoconf") {
52
        if (-f $omreport) {
53
                print "yes\n";
54
        } # end if
55
        else {
56
                print "no ($omreport does not exist)\n";
57
                exit(1);
58
        } # end else
59
} # end if
60
else {
61
        my $cmd = "$omreport chassis temps";
62
        my @result = `$cmd`;
63
        my (%val, $index);
64
        foreach my $line (@result) {
65
                $line =~ s/\s+/ /g;
66
                $line =~ s/\s$//g;
67
                next if ($line eq "");
68
                my ($field, $value) = split(/ \: /, $line);
69
                if ($field eq "Index") {
70
                        $val{$value} = {};
71
                        $index = $value;
72
                } # end if
73
                elsif ($field eq "Probe Name") {
74
                        $value =~ s/ Temp//g;
75
                        $val{$index}{$field} = "$value";
76
                } # end elsif
77
                elsif ($field eq "Reading") {
78
                        $value =~ s/ C//g;
79
                        $val{$index}{"$field"} = "$value";
80
                } # end elsif
81
                elsif ($field eq "Maximum Warning Threshold") {
82
                        $value =~ s/ C//g;
83
                        $val{$index}{"Warning Threshold"} = "$value";
84
                } # end elsif
85
                elsif ($field eq "Maximum Failure Threshold") {
86
                        $value =~ s/ C//g;
87
                        $val{$index}{"Critical Threshold"} = "$value";
88
                } # end elsif
89
        } # end foreach
90

    
91
        if ($ARGV[0] && $ARGV[0] eq "config") {
92
                print "graph_title OpenManage - Temperature Probes\n";
93
                print "graph_args --base 1000 -l 0\n";
94
                print "graph_vlabel Temperature in Celsius\n";
95
                print "graph_category Sensors\n";
96
                foreach my $j (sort keys %val) {
97
                        print "probe_$j.label $val{$j}{\"Probe Name\"}\n";
98
                        print "probe_$j.warning $val{$j}{\"Warning Threshold\"}\n";
99
                        print "probe_$j.critical $val{$j}{\"Critical Threshold\"}\n";
100
                } # end foreach
101
        } # end if
102
        else {
103
                foreach my $j (sort keys %val) {
104
                        print "probe_$j.value $val{$j}{\"Reading\"}\n";
105
                } # end foreach
106
        } # end else
107
} # end else
108
exit(0);
109