-
Notifications
You must be signed in to change notification settings - Fork 0
/
hp_temp
executable file
·100 lines (71 loc) · 1.77 KB
/
hp_temp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env perl
# -*- perl -*-
=head1 NAME
hp_temp - Munin plugin to monitor temperatures on a HP Proliant server
=head1 CONFIGURATION
The plugin uses hplog, found in the hp-health package, to graph the temperature
of several hardware sensors which are present in every HP Proliant server.
You can configure the unit you want to display the temperatures with (C or F).
Default value is C (celsius).
[hp-temp]
env.unit F
Put it in a file in /etc/munin/plugin-conf.d/ and restart the munin-node.
=head1 USAGE
Link this plugin to /etc/munin/plugins/ and restart the munin-node.
=head1 MAGIC MARKERS
#%# family=contrib
#%# capabilities=
=head1 VERSION
0.1
=head1 AUTHOR
Remi Paulmier
=head1 LICENSE
GPLv2
=cut
use strict;
use warnings;
use lib $ENV{'MUNIN_LIBDIR'};
use Munin::Plugin;
my $VERSION = "0.1";
my $hplog_t = 'hplog -t |';
#my $hplog_t = '</tmp/hplog.txt';
my $unit = 'C';
if ( defined($ARGV[0]) and $ARGV[0] eq "autoconf" ) {
print "no\n";
exit 0;
}
if (defined $ENV{'unit'}) {
if ($ENV{'unit'} eq 'C' ||$ENV{'unit'} eq 'F') {
$unit = $ENV{'unit'};
}
}
open HPLOG, $hplog_t or die "can't open hplog\n";
if ( defined($ARGV[0]) and $ARGV[0] eq "config" ) {
print <<EOF
graph_title temperatures
graph_category HP
graph_vlabel T in °$unit
EOF
}
while (<HPLOG>) {
chomp;
next if /^ID/;
if (my ($id, $location, $status, $curF, $curC, $thrF, $thrC) =
m/^\ +(\d+)\ +Basic\ Sensor\ +(.+)\ +(\S+)\ +(\d+)F\/\ (\d+)C\ +(\d+)F\/\ (\d+)C/) {
if ( defined($ARGV[0]) and $ARGV[0] eq "config" ) {
my $thr = ($unit eq "C" ) ? $thrC: $thrF;
print <<EOF
temp$id.label $location
temp$id.type GAUGE
temp$id.draw LINE2
temp$id.critical $thr
EOF
} else {
# values
my $cur = ($unit eq "C" ) ? $curC: $curF;
print <<EOF
temp$id.value $cur
EOF
}
}
}