PluginCat: hpasmcli_temp

File hpasmcli_temp, 1.8 kB (added by andreas@inferno.nadir.org, 6 years ago)

graph temperature on HP Proliant Servers using 'hpasmcli'

Line 
1 #! /usr/bin/perl -w
2 #
3 # Graph temperature on Proliant Servers
4 #
5 # hpasmcli needs root privs. To run it via sudo, type 'visudo' and append something like the
6 # following line to your /etc/sudoers
7 #   nobody ALL = (root) NOPASSWD:/sbin/hpasmcli
8 #
9 # $Id: hpasmcli_temp,v 1.3 2006/04/06 12:13:48 putzoa Exp $
10
11 use strict;
12
13 my $hpasmcli = "/sbin/hpasmcli";
14 my $cmd = "sudo $hpasmcli -s \"show temp\"";
15 # C/F : graph temp in celsius or fahrenheit
16 my $degree = "C";
17
18 my @result = `$cmd`;
19 my %val;
20
21 #(-f $hpasmcli) || exit(1);
22
23 foreach my $line (@result) {
24
25     if ($line =~ /^#/) {
26         $line =~ s/\s+/ /g;
27         $line =~ s/^\s//g;
28         my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
29         next if ($temp eq "-");
30         $loc =~ s/\/|#//g;
31         $temp = $degree eq "C" ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
32         $temp =~ s/C|F//g;
33         $threshold = $degree eq "C" ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
34         $threshold =~ s/C|F//g;
35        
36         $sensor =~s/#//g;
37         $val{$sensor} = {location => lc($loc),
38                          temp     => $temp,
39                          threshold => $threshold
40                          };
41      }
42    
43 }
44
45
46 if ($ARGV[0] && $ARGV[0] eq "config") {
47
48     print "graph_title Temperature\n";
49     print "graph_vlabel temperature in °$degree\n";
50     print "graph_category Sensors\n";
51     while (my ($k, $hashref) = each (%val)) {
52         print "$hashref->{location}.label $hashref->{location}\n";
53         print "$hashref->{location}.warning ".($hashref->{threshold} - 5) ."\n";
54         print "$hashref->{location}.critical $hashref->{threshold}\n";
55     }
56
57 }
58 else {
59     while (my ($k, $hashref) = each (%val)) {
60         print "$hashref->{location}.value $hashref->{temp}\n";   
61     }
62 }
63 exit(0);