3 # Plugin to monitor Proliant server health status using hpasmcli.
6 # user root -- requrired by hpasmcli
7 # env.hpasmcli -- path to hpasmcli executable (optional)
8 # env.degree -- Unit of temperatures (C or F / default value is C)
11 # Author: Tsuyoshi Wada <mail@tuyo.jp>
13 # v1.0 2007/12/08 - First version
15 # Copyright (c) 2007 Tsuyoshi Wada
16 # All rights reserved.
18 # Redistribution and use in source and binary forms, with or without
19 # modification, are permitted provided that the following conditions
21 # 1. Redistributions of source code must retain the above copyright
22 # notice, this list of conditions and the following disclaimer.
23 # 2. Redistributions in binary form must reproduce the above copyright
24 # notice, this list of conditions and the following disclaimer in the
25 # documentation and/or other materials provided with the distribution.
27 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
28 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
29 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
30 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
31 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
32 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
36 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #%# capabilities=autoconf suggest
44 my $hpasmcli = exists $ENV{hpasmcli} ? $ENV{hpasmcli} : undef;
45 $hpasmcli = `which hpasmcli` unless $hpasmcli;
47 $hpasmcli = undef unless -x $hpasmcli;
48 my @dirs = qw(/usr/bin /usr/sbin /usr/local/bin /usr/local/sbin);
49 until ($hpasmcli or @dirs == 0) {
50 my $dir = shift @dirs;
51 my $path = $dir.'/hpasmcli';
52 $hpasmcli = $path if -x $path;
54 my $degree = exists $ENV{degree} ? $ENV{degree} : 'C';
55 my $deg_name = $degree eq 'C' ? "Celsius": "Fahrenheit";
57 if (defined($ARGV[0])) {
58 if ($ARGV[0] eq 'autoconf') {
59 if ($hpasmcli and -x $hpasmcli) {
60 my @chk_result = `$hpasmcli -s \"help\"`;
65 my $reason = 'Unknown error';
66 foreach my $line (@chk_result) {
67 if ($line =~ /^ERROR/i) {
73 print "no ($reason)\n";
77 print "no (hpasmcli not found)\n";
80 } elsif ($ARGV[0] eq 'suggest') {
86 $0 =~ /hpasmcli2_(.+)*$/;
88 my @show_result = `$hpasmcli -s \"show $show_target\"`;
91 if (defined($show_target) and $show_target eq 'temp') {
92 foreach my $line (@show_result) {
96 my ($sensor, $loc, $temp, $threshold) = split(/\s/, $line);
97 next if ($temp eq "-");
99 $temp = $degree eq 'C' ? (split(/\//, $temp))[0] : (split(/\//, $temp))[1];
101 $threshold = $degree eq 'C' ? (split(/\//, $threshold))[0] : (split(/\//, $threshold))[1];
102 $threshold =~ s/C|F//g;
105 'location' => lc($loc),
107 'threshold' => $threshold
111 if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
112 print "graph_title hpasm: Temperature\n";
113 print "graph_args --base 1000 -l 0\n";
114 print "graph_vlabel Degrees in $deg_name\n";
115 print "graph_category sensors\n";
116 print "graph_info This graph shows the temperatures as reported by hpasmcli.\n";
117 foreach my $key (sort keys %output) {
118 print "temp$key.label $output{$key}->{'location'}\n";
119 print "temp$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
120 print "temp$key.critical $output{$key}->{'threshold'}\n";
123 foreach my $key (sort keys %output) {
124 print "temp$key.value $output{$key}->{'temp'}\n";
127 } elsif (defined($show_target) and $show_target eq 'fans') {
128 foreach my $line (@show_result) {
132 my ($fan, $loc, $present, $speed, $rate, $redundant, $partner, $pluggable) = split(/\s/, $line);
133 next if ($present ne "Yes");
136 my $threshold = '100';
139 'location' => lc($loc),
141 'threshold' => $threshold
145 if (defined($ARGV[0]) and $ARGV[0] eq 'config') {
146 print "graph_title hpasm: Fans\n";
147 print "graph_args --base 1000 -l 0\n";
148 print "graph_vlabel of max (%)\n";
149 print "graph_category sensors\n";
150 print "graph_info This graph shows the info of fans as reported by hpasmcli.\n";
151 foreach my $key (sort keys %output) {
152 print "fan$key.label FAN$key $output{$key}->{'location'}\n";
153 print "fan$key.warning " . ($output{$key}->{'threshold'} * 0.75) . "\n";
154 print "fan$key.critical $output{$key}->{'threshold'}\n";
157 foreach my $key (sort keys %output) {
158 print "fan$key.value $output{$key}->{'rate'}\n";
162 die "Unknown target specified ($show_target)\n";