]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/munin/files/default/plugins/hpasmcli_temp
Add a bunch more cookbooks
[chef.git] / cookbooks / munin / files / default / plugins / hpasmcli_temp
diff --git a/cookbooks/munin/files/default/plugins/hpasmcli_temp b/cookbooks/munin/files/default/plugins/hpasmcli_temp
new file mode 100755 (executable)
index 0000000..0884bb1
--- /dev/null
@@ -0,0 +1,61 @@
+#! /usr/bin/perl -w
+#
+# Graph temperature on Proliant Servers 
+# 
+
+use strict;
+
+my $hpasmcli = "/sbin/hpasmcli";
+my $cmd = "$hpasmcli -s \"show temp\"";
+# C/F : graph temp in celsius or fahrenheit
+my $degree = "C";
+
+my @result = `$cmd`;
+my %val;
+
+#(-f $hpasmcli) || exit(1);
+
+foreach my $line (@result) {
+
+    if ($line =~ /^#/) {
+        $line =~ s/\s+/ /g;
+        $line =~ s/^\s//g;
+        my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
+        next if ($temp eq "-");
+        $loc =~ s/\/|#//g;
+        $temp = $degree eq "C" ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
+        $temp =~ s/C|F//g;
+        $threshold = $degree eq "C" ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
+        $threshold =~ s/C|F//g;
+        
+        $sensor =~s/#//g;
+        $val{$sensor} = {location => lc($loc),
+                         temp     => $temp,
+                         threshold => $threshold
+                         };
+     }
+    
+}
+
+
+if ($ARGV[0] && $ARGV[0] eq "config") {
+
+    print "graph_title Temperature\n";
+    print "graph_vlabel temperature in °$degree\n";
+    print "graph_category sensors\n";
+    while (my ($k, $hashref) = each (%val)) {
+        print "$hashref->{location}.label $hashref->{location}\n";
+        print "$hashref->{location}.warning ".($hashref->{threshold} - 5) ."\n";
+        print "$hashref->{location}.critical $hashref->{threshold}\n";
+    }
+
+}
+else {
+    while (my ($k, $hashref) = each (%val)) {
+        print "$hashref->{location}.value $hashref->{temp}\n";    
+    }
+}
+exit(0);
+
+
+