]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/files/default/plugins/hpasmcli_temp
Manage ipmi_power munin plugin on 14.04 machines
[chef.git] / cookbooks / munin / files / default / plugins / hpasmcli_temp
1 #! /usr/bin/perl -w
2 #
3 # Graph temperature on Proliant Servers 
4
5
6 use strict;
7
8 my $hpasmcli = "/sbin/hpasmcli";
9 my $cmd = "$hpasmcli -s \"show temp\"";
10 # C/F : graph temp in celsius or fahrenheit
11 my $degree = "C";
12
13 my @result = `$cmd`;
14 my %val;
15
16 #(-f $hpasmcli) || exit(1);
17
18 foreach my $line (@result) {
19
20     if ($line =~ /^#/) {
21         $line =~ s/\s+/ /g;
22         $line =~ s/^\s//g;
23         my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
24         next if ($temp eq "-");
25         $loc =~ s/\/|#//g;
26         $temp = $degree eq "C" ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
27         $temp =~ s/C|F//g;
28         $threshold = $degree eq "C" ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
29         $threshold =~ s/C|F//g;
30         
31         $sensor =~s/#//g;
32         $val{$sensor} = {location => lc($loc),
33                          temp     => $temp,
34                          threshold => $threshold
35                          };
36      }
37     
38 }
39
40
41 if ($ARGV[0] && $ARGV[0] eq "config") {
42
43     print "graph_title Temperature\n";
44     print "graph_vlabel temperature in °$degree\n";
45     print "graph_category sensors\n";
46     while (my ($k, $hashref) = each (%val)) {
47         print "$hashref->{location}.label $hashref->{location}\n";
48         print "$hashref->{location}.warning ".($hashref->{threshold} - 5) ."\n";
49         print "$hashref->{location}.critical $hashref->{threshold}\n";
50     }
51
52 }
53 else {
54     while (my ($k, $hashref) = each (%val)) {
55         print "$hashref->{location}.value $hashref->{temp}\n";    
56     }
57 }
58 exit(0);
59
60
61