/[nagios-plugins-perl]/trunk/plugins/check_netapp_health.pl
ViewVC logotype

Contents of /trunk/plugins/check_netapp_health.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 193 - (show annotations) (download)
Mon Dec 18 14:45:38 2017 UTC (2 years, 11 months ago) by racvision
File MIME type: text/plain
File size: 4079 byte(s)
Remise en ordre XH 201712
1 #!/usr/bin/perl -w
2 # $Id: check_netapp_health.pl 1216 2008-04-24 12:51:18Z wpreston $
3
4 =pod
5
6 =head1 COPYRIGHT
7
8
9 This software is Copyright (c) 2008 NETWAYS GmbH, William Preston
10 <support@netways.de>
11
12 (Except where explicitly superseded by other copyright notices)
13
14 =head1 LICENSE
15
16 This work is made available to you under the terms of Version 2 of
17 the GNU General Public License. A copy of that license should have
18 been provided with this software, but in any event can be snarfed
19 from http://www.fsf.org.
20
21 This work is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 02110-1301 or visit their web page on the internet at
30 http://www.fsf.org.
31
32
33 CONTRIBUTION SUBMISSION POLICY:
34
35 (The following paragraph is not intended to limit the rights granted
36 to you to modify and distribute this software under the terms of
37 the GNU General Public License and is only of importance to you if
38 you choose to contribute your changes and enhancements to the
39 community by submitting them to NETWAYS GmbH.)
40
41 By intentionally submitting any modifications, corrections or
42 derivatives to this work, or any other work intended for use with
43 this Software, to NETWAYS GmbH, you confirm that
44 you are the copyright holder for those contributions and you grant
45 NETWAYS GmbH a nonexclusive, worldwide, irrevocable,
46 royalty-free, perpetual, license to use, copy, create derivative
47 works based on those contributions, and sublicense and distribute
48 those contributions and any derivatives thereof.
49
50 Nagios and the Nagios logo are registered trademarks of Ethan Galstad.
51
52 =head1 NAME
53
54 check_netapp_health
55
56 =head1 SYNOPSIS
57
58 Retrieves the status of a NetApp and converts the resulting error code
59
60 =head1 OPTIONS
61
62 check_netapp_health [options] <hostname> <SNMP community>
63
64 =over
65
66 =item B<--warning>
67
68 warning level (not used)
69
70 =item B<--critical>
71
72 critical level (not used)
73
74 =item B<--timeout>
75
76 how long to wait for the reply (default 30s)
77
78 =back
79
80 =head1 DESCRIPTION
81
82 This plugin checks the status of a NetApp Appliance using SNMP
83
84 It doesn't require the NETWORK-APPLIANCE-MIB (the OID is
85 hardcoded into the script)
86
87
88 =cut
89
90 use Getopt::Long;
91 use Pod::Usage;
92 # use lib '/usr/nagios/libexec/';
93 use lib '/usr/lib/nagios/plugins/';
94 use utils qw(%ERRORS);
95 use Net::SNMP;
96
97 sub nagexit($$);
98
99 $warning = 40;
100 $critical = 20;
101
102 my %OIDS = ( miscGlobalStatus.0 => '.1.3.6.1.4.1.789.1.2.2.4.0',
103 miscGlobalStatusMessage.0 => '.1.3.6.1.4.1.789.1.2.2.25.0');
104
105
106 my %ErrorMap = ( 1 => 'WARNING',
107 2 => 'UNKNOWN',
108 3 => 'OK',
109 4 => 'WARNING',
110 5 => 'CRITICAL',
111 6 => 'CRITICAL');
112
113 # check the command line options
114 GetOptions('help|?' => \$help,
115 't|timeout=i' => \$tout,
116 'w|warn|warning=i' => \$warning,
117 'c|crit|critical=i' => \$critical);
118
119 if ($#ARGV!=1) {$help=1;} # wrong number of command line options
120 # pod2usage( -verbose => 99, -sections => "NAME|COPYRIGHT|SYNOPSIS|OPTIONS") if $help;
121 pod2usage(1) if $help;
122
123 my $tout = 15 if (!defined($tout));
124 my $host = shift;
125 my $community = shift;
126
127 $SIG{'ALRM'} = sub { nagexit('CRITICAL', "Timeout trying to reach device $host") };
128
129 alarm($tout);
130
131 my ($session, $error) = Net::SNMP->session(
132 -hostname => $host,
133 -community => $community);
134 if (!defined($session)) { nagexit('CRITICAL', "Failed to reach device $host") };
135
136
137 my $result = $session->get_request(
138 -varbindlist => [$OIDS{miscGlobalStatus.0},$OIDS{miscGlobalStatusMessage.0}]);
139 if (!defined($result)) { nagexit('CRITICAL', "Failed to query device $host") };
140
141 nagexit($ErrorMap{$result->{$OIDS{miscGlobalStatus.0}}}, $result->{$OIDS{miscGlobalStatusMessage.0}});
142
143
144 sub nagexit($$) {
145 my $errlevel = shift;
146 my $string = shift;
147
148 print "$errlevel: $string\n";
149 exit $ERRORS{$errlevel};
150 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.8