#! /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);