Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 31 additions & 29 deletions hpfan/hpfan
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ hpfan - Munin plugin to monitor HP server fans

=head1 CONFIGURATION

The plugin needs to be able to execute /sbin/hplog, which requires
The plugin needs to be able to execute /sbin/hplog -f, which requires
root permissions. The following configuration is needed:

[hpfan]
user=root

=head1 INTERPRETATION

The graph will show information about how many fans are ok and how
many are degratded.
It does not, currently, show the speed of the fans.
The graphs will show the fan speeds at different locations
in the server.

=head1 MAGIC MARKERS

Expand All @@ -60,37 +59,40 @@ if ( $ARGV[0] and $ARGV[0] eq "autoconf") {
exit(0);
}

if ( $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title HP Fans\n";
print "graph_category system\n";
print "ok.label Fans OK\n";
print "ok.type GAUGE\n";
print "ok.min 0\n";
print "degraded.label Fans degraded\n";
print "degraded.type GAUGE\n";
print "degraded.min 0\n";
print "degraded.critical 1\n";
exit(0);
}

my @sensors;
open(HPLOG, "/sbin/hplog -f |") || die "Could not run hplog\n";
my $ok=0;
my $degraded=0;

while (<HPLOG>) {
next if /^\s*$/;
next if /^\s*ID/;
if (/\s+(Normal|Nominal)\s+/) {
$ok++;
}
elsif (/\s+Absent\s+/) {
# unknown, we don't track that
next if /^ID/;
if (/^\s*(\d+)\s*Var\. Speed\s+(\w\w+)\s+.*\(\s?(\d+)\)/) {
print STDERR "regex match found: \$1:$1\n\$2:$2\n\$3:$3\n";
push @sensors, {
'id' => $1,
'location' => $2,
'fan_speed' => $3
};
}
else {
$degraded++;
warn "Could not parse line $_";
}
}
close(HPLOG);

print "ok.value $ok\n";
print "degraded.value $degraded\n";
if ( $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title HP fans\n";
print "graph_category sensors\n";
print "graph_vlabel % of Max\n";
for my $sensor (@sensors) {
print "s" . $sensor->{'id'} . ".label " . $sensor->{'location'} . "\n";
print "s" . $sensor->{'id'} . ".type GAUGE\n";
print "s" . $sensor->{'id'} . ".min 0\n";
print "s" . $sensor->{'id'} . ".max 100\n";
print "s" . $sensor->{'id'} . ".warning 10:90\n";
print "s" . $sensor->{'id'} . ".critical 0:100\n";
}
exit(0);
}

for my $sensor (@sensors) {
print "s" . $sensor->{'id'} . ".value " . $sensor->{'fan_speed'} . "\n";
}
7 changes: 4 additions & 3 deletions hptemp/hptemp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ open(HPLOG, "/sbin/hplog -t |") || die "Could not run hplog\n";
while (<HPLOG>) {
next if /^\s*$/;
next if /^ID/;
if (/^\s*(\d+)\s*Basic Sensor\s+(CPU \(\d+\)|Processor Zone|I\/O Zone)\s+(\S+)\s+\d+F\/\s*(\d+)C\s+\d+F\/\s*(\d+)C/) {
if (/^\s*(\d+)\s*Basic Sensor\s+(CPU \(\d+\)|Ambient|Processor Zone|Memory Board|Mem\. Brd\. \(\d+\)|System Board|Pwr\. Supply Bay|I\/O Zone|SCSI Backplane)\s+(\S+)\s+\d+F\/\s*(\d+)C\s+\d+F\/\s*(\d+)C/) {
push @sensors, {
'id' => $1,
'name' => $2,
Expand All @@ -74,14 +74,15 @@ while (<HPLOG>) {
};
}
else {
die "Could not parse line $_";
warn "Could not parse line $_";
}
}
close(HPLOG);

if ( $ARGV[0] and $ARGV[0] eq "config") {
print "graph_title HP temperature\n";
print "graph_category system\n";
print "graph_category sensors\n";
print "graph_vlabel Celsius\n";
for my $sensor (@sensors) {
print "s" . $sensor->{'id'} . ".label " . $sensor->{'name'} . "\n";
print "s" . $sensor->{'id'} . ".type GAUGE\n";
Expand Down