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