Debian Codegraph @

check_hpasm/src/plugins-scripts/check_hpasm.pl

raw
1 #! /usr/bin/perl
2
3 use strict;
4
5 my $CELSIUS = 1;
6 my $PERFDATA = 1;
7 my $EXTENDEDINFO = 1;
8 my $HWINFO = 1;
9 my $HPACUCLI = 1;
10 my $NOINSTLEVEL = 'unknown';
11
12 use constant OK => 0;
13 use constant WARNING => 1;
14 use constant CRITICAL => 2;
15 use constant UNKNOWN => 3;
16 use constant DEPENDENT => 4;
17
18 my $plugin = Nagios::MiniPlugin->new(
19 shortname => '',
20 usage => 'Usage: %s [ -v|--verbose ] [ -t <timeout> ] '.
21 '--hostname <proliant> --community <snmp-community>'.
22 ' ...]',
23 version => '4.0',
24 blurb => 'This plugin checks the hardware of hp/compaq proliant servers',
25 url => 'http://labs.consol.de/nagios/check_hpasm',
26 timeout => 60,
27 shortname => '',
28 );
29 $plugin->add_arg(
30 spec => 'blacklist|b=s',
31 help => '--blacklist
32 Blacklist some (missing/failed) components',
33 required => 0,
34 default => '',
35 );
36 $plugin->add_arg(
37 spec => 'ignore-dimms|i',
38 help => '--ignore-dimms
39 Ignore "N/A"-DIMM status on misc. servers (e.g. older DL320)',
40 required => 0,
41 );
42 $plugin->add_arg(
43 spec => 'ignore-fan-redundancy',
44 help => '--ignore-fan-redundancy
45 Ignore missing redundancy partners',
46 required => 0,
47 );
48 $plugin->add_arg(
49 spec => 'customthresholds|c=s',
50 help => '--customthresholds
51 Use custom thresholds for certain temperatures',
52 required => 0,
53 );
54 $plugin->add_arg(
55 spec => 'eventrange=s',
56 help => '--eventrange=<warningrange>/<criticalrange>
57 Period of time before critical IML events respecively become warnings or vanish
58 A range is descibed as a number and a unit (s, m, h, d), e.g. --eventrange 1h/20m',
59 required => 0,
60 );
61 $plugin->add_arg(
62 spec => 'perfdata=s',
63 help => '--perfdata=[short]
64 Output performance data. If your performance data string becomes
65 too long and is truncated by Nagios, then you can use --perfdata=short
66 instead. This will output temperature tags without location information',
67 required => 0,
68 );
69 $plugin->add_arg(
70 spec => 'hostname|H=s',
71 help => '--hostname
72 Hostname or IP-address of the server (SNMP mode only)',
73 required => 0,
74 );
75 $plugin->add_arg(
76 spec => 'port=i',
77 help => '--port
78 The SNMP port to use (default: 161)',
79 required => 0,
80 default => 161,
81 );
82 $plugin->add_arg(
83 spec => 'protocol|P=s',
84 help => '--protocol
85 The SNMP protocol to use (default: 2c, other possibilities: 1,3)',
86 required => 0,
87 default => '2c',
88 );
89 $plugin->add_arg(
90 spec => 'domain|d=s',
91 help => '--domain
92 The transport protocol to use (default: udp, other possibilities: tcp)',
93 required => 0,
94 default => 'udp',
95 );
96 $plugin->add_arg(
97 spec => 'community|C=s',
98 help => '--community
99 SNMP community of the server (SNMP v1/2 only)',
100 required => 0,
101 default => 'public',
102 );
103 $plugin->add_arg(
104 spec => 'username=s',
105 help => '--username
106 The securityName for the USM security model (SNMPv3 only)',
107 required => 0,
108 );
109 $plugin->add_arg(
110 spec => 'authpassword=s',
111 help => '--authpassword
112 The authentication password for SNMPv3',
113 required => 0,
114 );
115 $plugin->add_arg(
116 spec => 'authprotocol=s',
117 help => '--authprotocol
118 The authentication protocol for SNMPv3 (md5|sha)',
119 required => 0,
120 );
121 $plugin->add_arg(
122 spec => 'privpassword=s',
123 help => '--privpassword
124 The password for authPriv security level',
125 required => 0,
126 );
127 $plugin->add_arg(
128 spec => 'privprotocol=s',
129 help => '--privprotocol
130 The private protocol for SNMPv3 (des|aes|aes128|3des|3desde)',
131 required => 0,
132 );
133 $plugin->add_arg(
134 spec => 'snmpwalk=s',
135 help => '--snmpwalk
136 A file with the output of snmpwalk 1.3.6.1.4.1.232',
137 required => 0,
138 );
139 $plugin->add_arg(
140 spec => 'hpasmcli=s',
141 help => '--hpasmcli
142 A file with the output of hpasmcli',
143 required => 0,
144 );
145 $plugin->add_arg(
146 spec => 'servertype=s',
147 help => '--servertype
148 The type of the server: proliant (default) or bladesystem',
149 required => 0,
150 );
151 $plugin->add_arg(
152 spec => 'eval-nics',
153 help => '--eval-nics
154 Check network interfaces (and groups). Try it and report me whyt you think about it. I need to build up some know how on this subject. If get an error and you think, it is not justified for your configuration, please tell me about it. (alwasy send the output of "snmpwalk -On .... 1.3.6.1.4.1.232" and a description how you setup your nics and why it is correct opposed to the plugins error message',
155 required => 0,
156 );
157
158 $plugin->getopts();
159 if (! $PERFDATA && $plugin->opts->get('perfdata')) {
160 $PERFDATA = 1;
161 }
162 if ($PERFDATA && $plugin->opts->get('perfdata') &&
163 ($plugin->opts->get('perfdata') eq 'short')) {
164 $PERFDATA = 2;
165 }
166 $plugin->{messages}->{unknown} = []; # wg. add_message(UNKNOWN,...)
167
168 $plugin->{info} = []; # gefrickel
169
170 $SIG{'ALRM'} = sub {
171 printf "UNKNOWN - check_hpasm timed out after %d seconds\n",
172 $plugin->opts->get('timeout');
173 exit $ERRORS{UNKNOWN};
174 };
175 alarm($plugin->opts->get('timeout'));
176
177 my $server = HP::Server->new( runtime => {
178 plugin => $plugin,
179 options => {
180 servertype => $plugin->opts->get('servertype'),
181 verbose => $plugin->opts->get('verbose'),
182 scrapiron => 0,
183 ignore_fan_redundancy => $plugin->opts->get('ignore-fan-redundancy'),
184 ignore_dimms => $plugin->opts->get('ignore-dimms'),
185 customthresholds => $plugin->opts->get('customthresholds'),
186 eventrange => $plugin->opts->get('eventrange'),
187 blacklist => $plugin->opts->get('blacklist'),
188 celsius => $CELSIUS,
189 perfdata => $PERFDATA,
190 extendedinfo => $EXTENDEDINFO,
191 hwinfo => $HWINFO,
192 hpacucli => $HPACUCLI,
193 noinstlevel => $NOINSTLEVEL,
194 },
195 },);
196 if (! $plugin->check_messages()) {
197 $server->init();
198 $plugin->add_message(OK, $server->identify()) if $HWINFO;
199 if (! $plugin->check_messages()) {
200 $plugin->add_message(OK, 'hardware working fine');
201 $plugin->add_message(OK, $server->get_summary())
202 if $server->get_summary();
203 $plugin->add_message(OK, $server->get_extendedinfo())
204 if $server->get_extendedinfo();
205 }
206 } else {
207 $plugin->add_message(CRITICAL, 'wrong device');
208 }
209
210 my ($code, $message) = $plugin->check_messages(join => ', ', join_all => ', ');
211 $message .= sprintf "\n%s\n", join("\n", @{$plugin->{info}})
212 if $plugin->opts->get('verbose') >= 1;
213 #printf "%s\n", Data::Dumper::Dumper($plugin->{info});
214 $plugin->nagios_exit($code, $message);
215