New upstream version 2.0.0

This commit is contained in:
Jan Wagner 2016-12-04 11:31:25 +01:00
parent e8c75af4e8
commit e1ab4578a6
71 changed files with 20366 additions and 9590 deletions

109
plugins/Changelog Normal file
View file

@ -0,0 +1,109 @@
################################
Release 1.1.2 / Jun 2007 :
Scripts, actual CVS version and changelog :
check_snmp_mem.pl : 1.3
check_snmp_vrrp.pl : 1.3
check_snmp_linkproof_nhr.pl : 1.1
check_snmp_process.pl : 1.7
- Added option to select process with his parameter
- Added option for performance output
- Corrected negative CPU when process restarts
- Added delta option for cpu average (-d option)
check_snmp_boostedge.pl : 1.2
check_snmp_nsbox.pl : 1.2
check_snmp_css_main.pl : 1.1
check_snmp_cpfw.pl : 1.7
check_snmp_int.pl : 1.22
- Correct speed query for interface > 4 Gbps
- Reduced snmp queries to 2 instead of 3 when perf data is on
- Bad maximum in perfdata when in Bps
- Added option to make dormant state OK
check_snmp_storage.pl : 1.10
- Return an UNKNOWN status when size/used/alloc is not defined in snmp
- Patch from Alexander Greiner-B?r to remove the reserved disk space for superuser on ext2/3 FS.
New -R option for this
- Added -G (giga) option for output & levels in Gigabytes
check_snmp_win.pl : 0.6
check_snmp_css.pl : 1.3
check_snmp_env.pl : 1.8
- Added test to check existence of some OIDs
check_snmp_load.pl : 1.11
- Corrected bug in performance output
- Added SIG{ALRM} sub and % sign in output
################################
Release 1.1.1 / April 2007 :
Added documentation in doc/ directory : (html format).
Scripts, actual CVS version and changelog :
check_snmp_mem.pl : 1.3
check_snmp_vrrp.pl : 1.3
check_snmp_linkproof_nhr.pl : 1.1
check_snmp_process.pl : 1.5
Makina Corpus contribs : snmpv3 enhancements, msg size parameter (-o)
check_snmp_boostedge.pl : 1.2 (No major changes)
check_snmp_nsbox.pl : 1.2 (No major changes)
check_snmp_css_main.pl : 1.1
check_snmp_cpfw.pl : 1.7
Added active/backup detection with SecureXL
Added SIG{ALRM} sub and small bug
check_snmp_int.pl : 1.18
Added bigint module to take care of 64 bits counters
check usage of snmp v2c or v3 when you use 64 bit counters (-g)
Added SIG{ALRM} sub
Added warning and critical levels in performance output
Added labels before in, out speed and errors (M. Berger contrib)
Added highperf counters option (-g)
Added SNMP packet length option (-o)
Added warning/critical levels in Mbps, MBps, Gbps, GBps options (-M, -G)
Added warning/critical levels in % of interface speed (-u)
Added performance output interface speed option (-S)
Added performance output in Bps or bps (-Y)
Added performance output in % of interface speed (-y)
Added port for snmpv3 (R. Leroy contrib)
check_snmp_storage.pl : 1.6
Makina Corpus contribs : snmpv3 port parameter, msg size parameter (-o)
check_snmp_win.pl : 0.6
check_snmp_css.pl : 1.3
check_snmp_env.pl : 1.7
Added SIG{ALRM} sub
Added voltage & temp checks on Cisco
Added Foundry checks
check_snmp_load.pl : 1.9
Added SIG{ALRM} sub and % sign in output
Bug in performance output
################################
Release 1.1 :
Added scripts :
- check_snmp_css_main : to get all services name and OID one time, then check only one OID with check_snmp_css. Reduces css cpu.
Corrected bugs :
- install.sh (Net::snmp detection)
- corrected bugs in check_snmp_css
- Added ironport checks in check_snmp_env
- Added hpux in check_snmp_load
- Bugs in check_snmp_int (specially for Windows).
Scripts and versions :
check_snmp_mem.pl : 1.3
check_snmp_vrrp.pl : 1.3
check_snmp_linkproof_nhr.pl : 1.1
check_snmp_process.pl : 1.4
check_snmp_boostedge.pl : 1.1
check_snmp_nsbox.pl : 1.1
check_snmp_css_main.pl : 1.1
check_snmp_cpfw.pl : 1.4
check_snmp_int.pl : 1.10
check_snmp_storage.pl : 1.5
check_snmp_win.pl : 0.6
check_snmp_css.pl : 1.3
check_snmp_env.pl : 1.4
check_snmp_load.pl : 1.9
################################
Release 1.0 :
Initial file release.

15
plugins/INSTALL Normal file
View file

@ -0,0 +1,15 @@
Installation:
-------------
You can simply copy the .pl files to the Nagios Plugin directory if
- Nagios plugins and utils.pm file are in /usr/local/nagios/libexec.
- You are sure Net::SNMP is installed. (Getopt::Long is standard).
- perl is in /usr/bin/perl
- Temp files can be written by Nagios in /tmp
You can also use the "install.sh" script provided in this directory to install the plugins.
Type : "./install.sh" to install all the plugins or "./install.sh <plugin name>" for a specific one.
The script will check for dependencies and ask for Nagios and temp directories.
It will modify the scripts depending on these answers and install the scripts.

280
plugins/LICENSE Normal file
View file

@ -0,0 +1,280 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

50
plugins/README Normal file
View file

@ -0,0 +1,50 @@
Nagios SNMP plugins 1.1.2 README
------------------------------
Nagios SNMP plugins is a set of Nagios plugins to check hosts/devices using snmp protocol.
http://nagios.manubulon.com for more details.
Requirements:
-------------
- perl in /usr/bin/perl
- Net::SNMP and Getopt::Long
- File utils.pm in Nagios plugin directory (default /usr/local/nagios/libexec)
- Nagios user can write files in /tmp/ directory
Perl, default directory and temp files location can be changed using the install.sh script.
Installation:
-------------
Read INSTALL file
Help and support:
-----------------
Help files, config examples and FAQ in the doc/ directory
http://nagios.manubulon.com/
FAQ : http://nagios.manubulon.com/faq.html
Mailling list, forum : http://sourceforge.net/projects/nagios-snmp/
Legal stuff:
------------
Nagios SNMP plugins version 1.1.2, Copyright (C) 2004-2007 Patrick Proy (nagios at proy.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

371
plugins/check_snmp_boostedge.pl Executable file
View file

@ -0,0 +1,371 @@
#!/usr/bin/perl -w
############################## check_snmp_boostedge.pl #################
# Version : 1.0
# Date : Jan 16 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Changelog :
# Contributors :
#################################################################
#
# Help : ./check_snmp_boostedge.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $be_global_status = "1.3.6.1.4.1.4185.12.1.1.3.0"; # boostedge global status (stop(0), start(1))
my $be_service_number = "1.3.6.1.4.1.4185.12.1.5.1.0"; # beServiceNumber
my $be_service_table = "1.3.6.1.4.1.4185.12.1.5"; # beServices
my $be_service_name = "1.3.6.1.4.1.4185.12.1.5.2.1.2"; # beServiceName
my $be_service_status = "1.3.6.1.4.1.4185.12.1.5.2.1.4"; # status ("RUNNING")
my $be_service_mode = "1.3.6.1.4.1.4185.12.1.5.2.1.5"; # beServiceMode (disabled(0), enabled(1))
my $be_service_datain = "1.3.6.1.4.1.4185.12.1.5.2.1.6"; # beServiceDataIn (Not populated for now : HTTP/S - V5.2.16.0)
my $be_service_dataout
= "1.3.6.1.4.1.4185.12.1.5.2.1.7"; # beServiceDataOut (Not populated for now : HTTP/S - V5.2.16.0)
my $be_service_connect
= "1.3.6.1.4.1.4185.12.1.5.2.1.8"; # beServiceConnect (Not populated for now : HTTP/S - V5.2.16.0)
# Globals
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_timeout = undef; # Timeout (Default 5)
my $o_perf = undef; # Output performance data
my $o_version2 = undef; # use snmp v2c
# Specific
my $o_service = undef; # service regexp selection
my $o_nservice = undef; # service number expected
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_boostedge version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -s <service> -n <number> [-p <port>] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub set_status { # return worst status with this order : OK, unknwonw, warning, critical
my $new_status = shift;
my $cur_status = shift;
if (($cur_status == 0) || ($new_status == $cur_status)) { return $new_status; }
if ($new_status == 3) { return $cur_status; }
if ($new_status > $cur_status) { return $new_status; }
return $cur_status;
}
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
my $pat = shift;
if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings
return eval { "" =~ /$pat/; 1 } || 0;
}
sub help {
print "\nSNMP Boostedge service monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL License, (c)2006-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-s, --service=<service>
Regexp of service to select
-n, --number=<number>
Number of services selected that must be in running & enabled state
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-f, --perfparse, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf,
's:s' => \$o_service,
'service:s' => \$o_service,
'n:i' => \$o_nservice,
'number:i' => \$o_nservice
);
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (!defined($o_service) || !(is_pattern_valid($o_service))) {
print "Service selection must be set and be a valid regexp\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_nservice) || isnnum($o_nservice)) {
print "Service number must be set and be an integer\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
# Get global status
my @oidlist = ($be_global_status);
my $resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oidlist)
: $session->get_request(-varbindlist => \@oidlist);
if (!defined($resultat)) {
printf("ERROR: Gloabal status table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
if ($$resultat{$be_global_status} != 1) {
print "Global service is stopped (", $$resultat{$be_global_status}, ") : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
$resultat = undef;
# Get service table
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($be_service_table)
: $session->get_table(Baseoid => $be_service_table);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my $output = "";
my $output_perf = "";
my $global_status = 0;
my ($nservice, $nservice_ok) = (0, 0);
my (@found_service, @service_state) = undef;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if (($key =~ /$be_service_name\./) && ($$resultat{$key} =~ /$o_service/)) { # Get index of service with name
$found_service[$nservice] = $$resultat{$key};
$key =~ s/$be_service_name//;
$service_state[$nservice] = $$resultat{ $be_service_status . $key };
if (($service_state[$nservice] ne "RUNNING") || ($$resultat{ $be_service_mode . $key } != 1)) {
$service_state[$nservice] .= "(" . $$resultat{ $be_service_mode . $key } . ")";
$global_status = 2;
} else {
$nservice_ok++;
}
$nservice++;
verb("Found service $found_service[$nservice-1]");
}
}
if ($o_nservice > $nservice_ok) {
for (my $i = 0; $i < $nservice; $i++) {
if ($output ne "") { $output .= ", "; }
$output .= $found_service[$i] . ":" . $service_state[$i];
}
if ($output ne "") { $output .= ", "; }
$output .= ":" . $nservice_ok . " services OK < " . $o_nservice;
print $output, " : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
$output = $nservice_ok . " services OK";
if ($o_nservice < $nservice_ok) {
print $output, " > $o_nservice : WARNING\n";
exit $ERRORS{"WARNING"};
}
print $output, " : OK\n";
exit $ERRORS{"OK"};

604
plugins/check_snmp_cpfw.pl Executable file
View file

@ -0,0 +1,604 @@
#!/usr/bin/perl -w
############################## check_snmp_cpfw ##############
my $VERSION = "2.0.0";
# Date : Oct 20 2007
# Author : Patrick Proy (patrick at proy.org)
# Help : http://nagios.manubulon.com
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : StaGue
# TODO :
# - check sync method
#################################################################
#
# Help : ./check_snmp_cpfw.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
########### SNMP Datas ###########
###### FW data
my $policy_state = "1.3.6.1.4.1.2620.1.1.1.0"; # "Installed"
my $policy_name = "1.3.6.1.4.1.2620.1.1.2.0"; # Installed policy name
my $connections = "1.3.6.1.4.1.2620.1.1.25.3.0"; # number of connections
#my $connections_peak = "1.3.6.1.4.1.2620.1.1.25.4.0"; # peak number of connections
my @fw_checks = ($policy_state, $policy_name, $connections);
###### SVN data
my $svn_status = "1.3.6.1.4.1.2620.1.6.102.0"; # "OK" svn status
my %svn_checks = ($svn_status, "OK");
my %svn_checks_n = ($svn_status, "SVN status");
my @svn_checks_oid = ($svn_status);
###### HA data
my $ha_active = "1.3.6.1.4.1.2620.1.5.5.0"; # "yes"
my $ha_state = "1.3.6.1.4.1.2620.1.5.6.0"; # "active" / "standby"
my $ha_block_state = "1.3.6.1.4.1.2620.1.5.7.0"; #"OK" : ha blocking state
my $ha_status = "1.3.6.1.4.1.2620.1.5.102.0"; # "OK" : ha status
my %ha_checks = ($ha_active, "yes", $ha_state, "active", $ha_block_state, "OK", $ha_status, "OK");
my %ha_checks_stand = ($ha_active, "yes", $ha_state, "standby", $ha_block_state, "OK", $ha_status, "OK");
my %ha_checks_n
= ($ha_active, "HA active", $ha_state, "HA state", $ha_block_state, "HA block state", $ha_status, "ha_status");
my @ha_checks_oid = ($ha_active, $ha_state, $ha_block_state, $ha_status);
my $ha_mode = "1.3.6.1.4.1.2620.1.5.11.0"; # "Sync only"/"High Availability (Active Up)" : ha Working mode
my $ha_tables = "1.3.6.1.4.1.2620.1.5.13.1"; # ha status table
my $ha_tables_index = ".1";
my $ha_tables_name = ".2";
my $ha_tables_state = ".3"; # "OK"
my $ha_tables_prbdesc = ".6"; # Description if state is != "OK"
#my @ha_table_check = ("Synchronization","Filter","cphad","fwd"); # process to check
####### MGMT data
my $mgmt_status = "1.3.6.1.4.1.2620.1.7.5.0"; # "active" : management status
my $mgmt_alive = "1.3.6.1.4.1.2620.1.7.6.0"; # 1 : management is alive if 1
my $mgmt_stat_desc = "1.3.6.1.4.1.2620.1.7.102.0"; # Management status description
my $mgmt_stats_desc_l = "1.3.6.1.4.1.2620.1.7.103.0"; # Management status long description
my %mgmt_checks = ($mgmt_status, "active", $mgmt_alive, "1");
my %mgmt_checks_n = ($mgmt_status, "Mgmt status", $mgmt_alive, "Mgmt alive");
my @mgmt_checks_oid = ($mgmt_status, $mgmt_alive);
#################################### Globals ##############################""
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_version2 = undef; # Version 2
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_timeout = 5; # Default 5s Timeout
my $o_warn = undef; # Warning for connections
my $o_crit = undef; # Crit for connections
my $o_svn = undef; # Check for SVN status
my $o_fw = undef; # Check for FW status
my $o_ha = undef; # Check for HA status
my $o_mgmt = undef; # Check for management status
my $o_policy = undef; # Check for policy name
my $o_conn = undef; # Check for connexions
my $o_perf = undef; # Performance data output
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_cpfw version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-s] [-w [-p=pol_name] [-c=warn,crit]] [-m] [-a [standby] ] [-f] [-p <port>] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub help {
print "\nSNMP Checkpoint FW-1 Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL License, (c)2004-2007 - Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information (including interface list on the system)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-s, --svn
check for svn status
-w, --fw
check for fw status
-a, --ha[=standby]
check for ha status and node in "active" state
If using SecurePlatform and monitoring a standby unit, put "standby" too
-m, --mgmt
check for management status
-p, --policy=POLICY_NAME
check if installed policy is POLICY_NAME (must have -w)
-c, --connexions=WARN,CRIT
check warn and critical number of connexions (must have -w)
-f, --perfparse, --perfdata
performance data output (only works with -c)
-P, --port=PORT
SNMP port (Default 161)
-t, --timeout=INTEGER
timeout for SNMP (Default: Nagios default)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'P:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'2' => \$o_version2,
'v2c' => \$o_version2,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
's' => \$o_svn,
'svn' => \$o_svn,
'w' => \$o_fw,
'fw' => \$o_fw,
'a:s' => \$o_ha,
'ha:s' => \$o_ha,
'm' => \$o_mgmt,
'mgmt' => \$o_mgmt,
'p:s' => \$o_policy,
'policy:s' => \$o_policy,
'c:s' => \$o_conn,
'connexions:s' => \$o_conn,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check firewall options
if (defined($o_conn)) {
if (!defined($o_fw)) {
print "Cannot check connexions without checking fw\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @warncrit = split(/,/, $o_conn);
if ($#warncrit != 1) { print "Put warn,crit levels with -c option\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
($o_warn, $o_crit) = @warncrit;
if (isnnum($o_warn) || isnnum($o_crit)) {
print "Numeric values for warning and critical in -c options\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_warn >= $o_crit) { print "warning <= critical ! \n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
if (defined($o_policy)) {
if (!defined($o_fw)) {
print "Cannot check policy name without checking fw\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_policy eq "") { print "Put a policy name !\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
if (defined($o_perf) && !defined($o_conn)) {
print "Nothing selected for performance data output !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_fw) && !defined($o_ha) && !defined($o_mgmt) && !defined($o_svn)) {
print "Must select a product to check !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_ha) && ($o_ha ne "") && ($o_ha ne "standby")) {
print "-a option comes with 'standby' or nothing !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-port => $o_port,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-port => $o_port,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
########### Global checks #################
my $global_status = 0; # global status : 0=OK, 1=Warn, 2=Crit
my ($resultat, $key) = (undef, undef);
########## Check SVN status #############
my $svn_print = "";
my $svn_state = 0;
if (defined($o_svn)) {
$resultat = $session->get_request(Varbindlist => \@svn_checks_oid);
if (defined($resultat)) {
foreach $key (keys %svn_checks) {
verb("$svn_checks_n{$key} : $svn_checks{$key} / $$resultat{$key}");
if ($$resultat{$key} ne $svn_checks{$key}) {
$svn_print .= $svn_checks_n{$key} . ":" . $$resultat{$key} . " ";
$svn_state = 2;
}
}
} else {
$svn_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$svn_state = 2;
}
if ($svn_state == 0) {
$svn_print = "SVN: OK";
} else {
$svn_print = "SVN: " . $svn_print;
}
verb("$svn_print");
}
########## Check mgmt status #############
my $mgmt_state = 0;
my $mgmt_print = "";
if (defined($o_mgmt)) {
# Check all states
$resultat = undef;
$resultat = $session->get_request(Varbindlist => \@mgmt_checks_oid);
if (defined($resultat)) {
foreach $key (keys %mgmt_checks) {
verb("$mgmt_checks_n{$key} : $mgmt_checks{$key} / $$resultat{$key}");
if ($$resultat{$key} ne $mgmt_checks{$key}) {
$mgmt_print .= $mgmt_checks_n{$key} . ":" . $$resultat{$key} . " ";
$mgmt_state = 2;
}
}
} else {
$mgmt_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$mgmt_state = 2;
}
if ($mgmt_state == 0) {
$mgmt_print = "MGMT: OK";
} else {
$mgmt_print = "MGMT: " . $mgmt_print;
}
verb("$svn_print");
}
########### Check fw status ##############
my $fw_state = 0;
my $fw_print = "";
my $perf_conn = undef;
if (defined($o_fw)) {
# Check all states
$resultat = $session->get_request(Varbindlist => \@fw_checks);
if (defined($resultat)) {
verb("State : $$resultat{$policy_state}");
verb("Name : $$resultat{$policy_name}");
verb("connections : $$resultat{$connections}");
if ($$resultat{$policy_state} ne "Installed") {
$fw_state = 2;
$fw_print .= "Policy:" . $$resultat{$policy_state} . " ";
verb("Policy state not installed");
}
if (defined($o_policy)) {
if ($$resultat{$policy_name} ne $o_policy) {
$fw_state = 2;
$fw_print .= "Policy installed: $$resultat{$policy_name}";
}
}
if (defined($o_conn)) {
if ($$resultat{$connections} > $o_crit) {
$fw_state = 2;
$fw_print .= "Connexions : " . $$resultat{$connections} . " > " . $o_crit . " ";
} else {
if ($$resultat{$connections} > $o_warn) {
if ($fw_state != 2) { $fw_state = 1; }
$fw_print .= "Connexions : " . $$resultat{$connections} . " > " . $o_warn . " ";
}
}
$perf_conn = $$resultat{$connections};
}
} else {
$fw_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$fw_state = 2;
}
if ($fw_state == 0) {
$fw_print = "FW: OK";
} else {
$fw_print = "FW: " . $fw_print;
}
}
########### Check ha status ##############
my $ha_state_n = 0;
my $ha_print = "";
if (defined($o_ha)) {
# Check all states
$resultat = $session->get_request(Varbindlist => \@ha_checks_oid);
if (defined($resultat)) {
foreach $key (keys %ha_checks) {
verb("$ha_checks_n{$key} : $ha_checks{$key} / $$resultat{$key}");
if ($o_ha eq "standby") {
if ($$resultat{$key} ne $ha_checks_stand{$key}) {
$ha_print .= $ha_checks_n{$key} . ":" . $$resultat{$key} . " ";
$ha_state_n = 2;
}
} else {
if ($$resultat{$key} ne $ha_checks{$key}) {
$ha_print .= $ha_checks_n{$key} . ":" . $$resultat{$key} . " ";
$ha_state_n = 2;
}
}
}
#my $ha_mode = "1.3.6.1.4.1.2620.1.5.11.0"; # "Sync only" : ha Working mode
} else {
$ha_print .= "cannot find OIDs";
#Critical state if not found because it means soft is not activated
$ha_state_n = 2;
}
# get ha status table
$resultat = $session->get_table(Baseoid => $ha_tables);
my %status;
my (@index, @oid) = (undef, undef);
my $nindex = 0;
my $index_search = $ha_tables . $ha_tables_index;
if (defined($resultat)) {
foreach $key (keys %$resultat) {
if ($key =~ /$index_search/) {
@oid = split(/\./, $key);
pop(@oid);
$index[$nindex] = pop(@oid);
$nindex++;
}
}
} else {
$ha_print .= "cannot find OIDs" if ($ha_state_n == 0);
#Critical state if not found because it means soft is not activated
$ha_state_n = 2;
}
verb("found $nindex ha softs");
if ($nindex == 0) {
$ha_print .= " no ha soft found" if ($ha_state_n == 0);
$ha_state_n = 2;
} else {
my $ha_soft_name = undef;
for (my $i = 0; $i < $nindex; $i++) {
$key = $ha_tables . $ha_tables_name . "." . $index[$i] . ".0";
$ha_soft_name = $$resultat{$key};
$key = $ha_tables . $ha_tables_state . "." . $index[$i] . ".0";
if (($status{$ha_soft_name} = $$resultat{$key}) ne "OK") {
$key = $ha_tables . $ha_tables_prbdesc . "." . $index[$i] . ".0";
$status{$ha_soft_name} = $$resultat{$key};
$ha_print .= $ha_soft_name . ":" . $status{$ha_soft_name} . " ";
$ha_state_n = 2;
}
verb("$ha_soft_name : $status{$ha_soft_name}");
}
}
if ($ha_state_n == 0) {
$ha_print = "HA: OK";
} else {
$ha_print = "HA: " . $ha_print;
}
}
$session->close;
########## print results and exit
my $f_print = undef;
if (defined($o_fw)) { $f_print = $fw_print }
if (defined($o_svn)) { $f_print = (defined($f_print)) ? $f_print . " / " . $svn_print : $svn_print }
if (defined($o_ha)) { $f_print = (defined($f_print)) ? $f_print . " / " . $ha_print : $ha_print }
if (defined($o_mgmt)) { $f_print = (defined($f_print)) ? $f_print . " / " . $mgmt_print : $mgmt_print }
my $exit_status = undef;
$f_print .= " / CPFW Status: ";
if (($ha_state_n + $svn_state + $fw_state + $mgmt_state) == 0) {
$f_print .= 'OK' . ($perf_conn ? ', ' . $perf_conn . ' conn.' : '');
$exit_status = $ERRORS{"OK"};
} else {
if (($fw_state == 1) || ($ha_state_n == 1) || ($svn_state == 1) || ($mgmt_state == 1)) {
$f_print .= "WARNING";
$exit_status = $ERRORS{"WARNING"};
} else {
$f_print .= "CRITICAL";
$exit_status = $ERRORS{"CRITICAL"};
}
}
if (defined($o_perf) && defined($perf_conn)) {
$f_print .= " | fw_connexions=" . $perf_conn . ";" . $o_warn . ";" . $o_crit . ";0";
}
print "$f_print\n";
exit $exit_status;

551
plugins/check_snmp_css.pl Executable file
View file

@ -0,0 +1,551 @@
#!/usr/bin/perl -w
############################## check_snmp_css.pl #################
# Version : 1.0.1
# Date : 27 Sept 2006
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Changelog :
# Contributors :
#################################################################
#
# Help : ./check_snmp_css.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $css_svc_table = "1.3.6.1.4.1.9.9.368.1.15.2.1"; # Svc table
my $css_svc_name = "1.3.6.1.4.1.9.9.368.1.15.2.1.1"; # Service Name / apSvcName
my $css_svc_index = "1.3.6.1.4.1.9.9.368.1.15.2.1.2"; # apSvcIndex
my $css_svc_enable = "1.3.6.1.4.1.9.9.368.1.15.2.1.12"; # apSvcEnable
my $css_svc_state = "1.3.6.1.4.1.9.9.368.1.15.2.1.17"; # apSvcState : suspended(1), down(2), alive(4), dying(5)
my $css_svc_maxconn = "1.3.6.1.4.1.9.9.368.1.15.2.1.19"; # Max connexions / apSvcMaxConnections
my $css_svc_conn = "1.3.6.1.4.1.9.9.368.1.15.2.1.20"; # apSvcConnections
my $css_svc_avgresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.65"; # apSvcAvgResponseTime : average response time
my $css_svc_maxresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.66"; # apSvcPeakAvgResponseTime : peak response time
my @css_svc_state_txt = ("", "suspended", "down", "", "alive", "dying");
my @css_svc_state_nag = (3, 2, 2, 3, 0, 2);
# Globals
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_timeout = undef; # Timeout (Default 5)
my $o_perf = undef; # Output performance data
my $o_version2 = undef; # use snmp v2c
#Specific
my $o_dir = "/tmp/"; # Directory to store temp file in it.
my $o_dir_set = undef; # defined if names and index must be read form file.
my $o_name = undef; # service name (regexp)
my $o_warn_number = undef; # minimum number of service before warning
my $o_crit_number = undef; # minimum number of service before critical
my $o_warn_conn = undef; # % of max connexions for warning level
my $o_crit_conn = undef; # % of max connexions for critical level
my $o_warn_resp = undef; # average response time for warning level
my $o_crit_resp = undef; # average response time for critical level
my @o_levels = undef;
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_css version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -n <name> [-d directory] [-w <num>,<resp>,<conn> -c <num>,<resp>,<conn>] [-p <port>] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub set_status { # return worst status with this order : OK, unknwonw, warning, critical
my $new_status = shift;
my $cur_status = shift;
if (($cur_status == 0) || ($new_status == $cur_status)) { return $new_status; }
if ($new_status == 3) { return $cur_status; }
if ($new_status > $cur_status) { return $new_status; }
return $cur_status;
}
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
my $pat = shift;
if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings
return eval { "" =~ /$pat/; 1 } || 0;
}
sub round ($$) {
sprintf "%.$_[1]f", $_[0];
}
sub help {
print "\nSNMP Cisco CSS monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "(c)2004-2006 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-n, --name=<name>
regexp to select service
-w, --warning=<num>,<resp>,<conn>
Optional. Warning level for
- minimum number of active & alive service
- average response time
- number of connexions
For no warnings, put -1 (ex : -w5,-1,3).
When using negative numbers, dont put space after "-w"
-d, --dir=<directory to put file>
Directory where the temp file with index, created by check_snmp_css_main.pl, can be found
If no directory is set, /tmp will be used
-c, --critical=<num>,resp>,<conn>
Optional. Critical levels (-1 for no critical levels)
See warning levels.
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-f, --perfparse
Perfparse compatible output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'n:s' => \$o_name,
'name:s' => \$o_name,
'w:s' => \$o_warn_conn,
'warning:s' => \$o_warn_conn,
'c:s' => \$o_crit_conn,
'critical:s' => \$o_crit_conn,
'd:s' => \$o_dir_set,
'dir:s' => \$o_dir_set
);
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (!defined($o_name) || !(is_pattern_valid($o_name))) {
print "Need a service name!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_warn_conn)) {
@o_levels = split(/,/, $o_warn_conn);
if (defined($o_levels[0])) {
if (isnnum($o_levels[0])) { print "Need number for warning!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[0] != -1) { $o_warn_number = $o_levels[0]; }
}
if (defined($o_levels[1])) {
if (isnnum($o_levels[1])) { print "Need number for warning!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[1] != -1) { $o_warn_conn = $o_levels[1]; }
else { $o_warn_conn = undef; }
} else {
$o_warn_conn = undef;
}
if (defined($o_levels[2])) {
if (isnnum($o_levels[2])) { print "Need number for warning!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[2] != -1) { $o_warn_resp = $o_levels[2]; }
}
}
if (defined($o_crit_conn)) {
@o_levels = split(/,/, $o_crit_conn);
if (defined($o_levels[0])) {
if (isnnum($o_levels[0])) { print "Need number for critical!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[0] != -1) {
$o_crit_number = $o_levels[0];
if (defined($o_warn_number) && ($o_crit_number >= $o_warn_number)) {
print "critical must be < warning!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
}
if (defined($o_levels[1])) {
if (isnnum($o_levels[1])) { print "Need number for critical!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[1] != -1) {
$o_crit_conn = $o_levels[1];
if (defined($o_warn_conn) && ($o_warn_conn >= $o_crit_conn)) {
print "critical must be > warning!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
} else {
$o_crit_conn = undef;
}
} else {
$o_crit_conn = undef;
}
if (defined($o_levels[2])) {
if (isnnum($o_levels[2])) { print "Need number for critical!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if ($o_levels[2] != -1) {
$o_crit_resp = $o_levels[1];
if (defined($o_warn_resp) && ($o_warn_resp >= $o_crit_resp)) {
print "critical must be > warning!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
}
}
if (defined($o_dir_set)) {
if ($o_dir_set ne "") { $o_dir = $o_dir_set; }
verb("Tmp directory : $o_dir");
}
}
########## MAIN #######
check_options();
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
$session->max_msg_size(10000);
########### Cisco CSS checks ##############
my (@index, @svcname) = (undef, undef);
my ($numsvc, $numoid, $numoid2) = 0;
my (@oid, @oid_list, @oid_list2) = undef;
my $resultat = undef;
# Get load table by snmp or file
if (defined($o_dir_set)) {
my $file_name = $o_dir . "/Nagios_css_" . $o_host;
my $file_lock = $file_name . ".lock";
# Check for lock file during 3 seconds max and quit if sill here.
my $file_timeout = 0;
while (-e $file_lock) {
sleep(1);
if ($file_timeout == 3) {
print "Lock file remaining for more than 3 sec : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
$file_timeout++;
}
# Open file for reading.
open(FILE, "< " . $file_name);
while (<FILE>) {
my @file_line = split(/:/, $_);
if ((defined($file_line[1])) && ($file_line[1] =~ /$o_name/)) { # select service by name
chomp($file_line[1]);
$svcname[$numsvc] = $file_line[1];
my $key = $file_line[0];
verb("Found : $svcname[$numsvc]");
$index[$numsvc++] = $key;
# Build oid for snmpget
$oid_list[$numoid++] = $css_svc_enable . $key;
$oid_list[$numoid++] = $css_svc_state . $key;
$oid_list2[$numoid2++] = $css_svc_maxconn . $key;
$oid_list2[$numoid2++] = $css_svc_conn . $key;
$oid_list2[$numoid2++] = $css_svc_avgresp . $key;
}
}
close(FILE);
} else {
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($css_svc_name)
: $session->get_table(Baseoid => $css_svc_name);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
# Get name data & index
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($$resultat{$key} =~ /$o_name/) { # select service by name
$svcname[$numsvc] = $$resultat{$key};
$key =~ s/$css_svc_name//;
verb("Found : $svcname[$numsvc]");
$index[$numsvc++] = $key;
# Build oid for snmpget
$oid_list[$numoid++] = $css_svc_enable . $key;
$oid_list[$numoid++] = $css_svc_state . $key;
$oid_list2[$numoid2++] = $css_svc_maxconn . $key;
$oid_list2[$numoid2++] = $css_svc_conn . $key;
$oid_list2[$numoid2++] = $css_svc_avgresp . $key;
}
}
}
# Check if a least one service found
if ($numsvc == 0) {
print "No service matching ", $o_name, " found : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
$resultat = undef;
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oid_list)
: $session->get_request(-varbindlist => \@oid_list);
if (!defined($resultat)) {
printf("ERROR: Status get : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my $resultat2 = undef;
$resultat2
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oid_list2)
: $session->get_request(-varbindlist => \@oid_list2);
if (!defined($resultat2)) {
printf("ERROR: Conn get : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my $output = "";
my $output_perf = "";
my $numsvc_ok = 0;
my $output_done = 0;
my $global_status = 0;
for (my $i = 0; $i < $numsvc; $i++) {
my $key = $index[$i];
if ($$resultat{ $css_svc_enable . $key } == 0) {
# service disabled
if ($output ne "") { $output .= ", "; }
$output .= $svcname[$i] . " : Disabled";
} else {
if ($css_svc_state_nag[$$resultat{ $css_svc_state . $key }] != 0) {
# state not OK
if ($output ne "") { $output .= ", "; }
$output .= $svcname[$i] . " : " . $css_svc_state_txt[$$resultat{ $css_svc_state . $key }];
} else {
$numsvc_ok++;
$output_done = 0;
# state OK
my $prctconn
= round(($$resultat2{ $css_svc_conn . $key } / $$resultat2{ $css_svc_maxconn . $key }) * 100, 0);
my $resptime = $$resultat2{ $css_svc_avgresp . $key };
if (defined($o_warn_conn) && ($prctconn > $o_warn_conn)) {
if ($output ne "") { $output .= ", "; }
$output .= $svcname[$i] . ":" . $prctconn . "%, " . $resptime . "ms";
set_status(1, $global_status);
$output_done = 1;
}
if (defined($o_crit_conn) && ($prctconn > $o_crit_conn)) {
if ($output_done == 0) {
$output .= $svcname[$i] . ":" . $prctconn . "%, " . $resptime . "ms";
$output_done = 1;
}
set_status(2, $global_status);
}
if (defined($o_warn_resp) && ($prctconn > $o_warn_resp)) {
if ($output_done == 0) {
$output .= $svcname[$i] . ":" . $prctconn . "%, " . $resptime . "ms";
$output_done = 1;
}
set_status(1, $global_status);
}
if (defined($o_crit_resp) && ($prctconn > $o_crit_resp)) {
if ($output_done == 0) {
$output .= $svcname[$i] . ":" . $prctconn . "%, " . $resptime . "ms";
$output_done = 1;
}
set_status(2, $global_status);
}
}
}
}
$output .= " " . $numsvc_ok . "/" . $numsvc . " services OK";
if (($global_status == 2) || ((defined($o_crit_number)) && ($numsvc_ok <= $o_crit_number)) || ($numsvc_ok == 0)) {
print $output, " : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
if (($global_status == 1) || ((defined($o_warn_number)) && ($numsvc_ok <= $o_warn_number))) {
print $output, " : WARNING\n";
exit $ERRORS{"WARNING"};
}
print $output, " : OK\n";
exit $ERRORS{"OK"};

306
plugins/check_snmp_css_main.pl Executable file
View file

@ -0,0 +1,306 @@
#!/usr/bin/perl -w
############################## check_snmp_css_main.pl #################
# Version : 1.0
# Date : 27 Sept 2006
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Changelog :
# Contributors :
#################################################################
#
# Help : ./check_snmp_css.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $css_svc_table = "1.3.6.1.4.1.9.9.368.1.15.2.1"; # Svc table
my $css_svc_name = "1.3.6.1.4.1.9.9.368.1.15.2.1.1"; # Service Name / apSvcName
my $css_svc_index = "1.3.6.1.4.1.9.9.368.1.15.2.1.2"; # apSvcIndex
my $css_svc_enable = "1.3.6.1.4.1.9.9.368.1.15.2.1.12"; # apSvcEnable
my $css_svc_state = "1.3.6.1.4.1.9.9.368.1.15.2.1.17"; # apSvcState : suspended(1), down(2), alive(4), dying(5)
my $css_svc_maxconn = "1.3.6.1.4.1.9.9.368.1.15.2.1.19"; # Max connexions / apSvcMaxConnections
my $css_svc_conn = "1.3.6.1.4.1.9.9.368.1.15.2.1.20"; # apSvcConnections
my $css_svc_avgresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.65"; # apSvcAvgResponseTime : average response time
my $css_svc_maxresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.66"; # apSvcPeakAvgResponseTime : peak response time
my @css_svc_state_txt = ("", "suspended", "down", "", "alive", "dying");
my @css_svc_state_nag = (3, 2, 2, 3, 0, 2);
# Globals
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_timeout = undef; # Timeout (Default 5)
my $o_version2 = undef; # use snmp v2c
#Specific
my $o_dir = "/tmp/"; # Directory to store temp file in it.
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_css_main version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-d directory] [-p <port>] [-t <timeout>] [-V]\n";
}
sub help {
print "\nSNMP Cisco CSS monitor MAIN script for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL License, (c)2004-2006 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-d, --dir=<directory to put file>
Directory where temp file with index is written
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'd:s' => \$o_dir,
'dir:s' => \$o_dir
);
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (defined($o_dir)) {
verb("Tmp directory : $o_dir");
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
$session->max_msg_size(10000);
########### Cisco CSS checks ##############
# Get load table
my $resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($css_svc_name)
: $session->get_table(Baseoid => $css_svc_name);
if (!defined($resultat)) {
printf("ERROR: Name table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
# Get name data & index
my (@index, @svcname) = (undef, undef);
my $numsvc = 0;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
$svcname[$numsvc] = $$resultat{$key};
$key =~ s/$css_svc_name//;
verb("Found : $svcname[$numsvc]");
$index[$numsvc++] = $key;
}
# Write file
my $file_name = $o_dir . "/Nagios_css_" . $o_host;
my $file_lock = $file_name . ".lock";
# First, make a lock file
system("touch $file_lock");
# allow scripts to finish reading file
sleep(0.5);
# create the file
if (!open(FILE, "> " . $file_name)) {
print "Cannot write $file_name\n";
unlink($file_lock);
exit $ERRORS{"UNKNOWN"};
}
for (my $i = 0; $i < $numsvc; $i++) {
my $output = $index[$i] . ":" . $svcname[$i] . "\n";
print FILE $output;
}
close(FILE);
unlink($file_lock);
print "Found $numsvc services : OK\n";
exit $ERRORS{"OK"};

1111
plugins/check_snmp_env.pl Executable file

File diff suppressed because it is too large Load diff

1005
plugins/check_snmp_int.pl Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,363 @@
#!/usr/bin/perl -w
############################## check_snmp_linkproof_nhr #################
# Version : 1.0
# Date : Aug 24 2006
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Changelog :
# Contributors :
#################################################################
#
# Help : ./check_snmp_linkproof_nhr.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $lp_type = "1.3.6.1.4.1.89.35.1.38.1.1.13"; # node type (1=regular, 2=nhr).
my $lp_name = "1.3.6.1.4.1.89.35.1.38.1.1.2"; # nhr name
my $lp_users = "1.3.6.1.4.1.89.35.1.38.1.1.5"; # nhr users
my $lp_state = "1.3.6.1.4.1.89.35.1.38.1.1.3"; # state : 1=active, 2=Notinservice, 3= nonewsessions.
my $lp_port = "1.3.6.1.4.1.89.35.1.38.1.1.15"; # nhr users
# Globals
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
# specific
my $o_nhr_num = undef; # nhr number TODO
my $o_nhr_max = undef; # Maximum connexions TODO
my $o_timeout = undef; # Timeout (Default 5)
my $o_perf = undef; # Output performance data
my $o_version2 = undef; # use snmp v2c
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_linkproof_nhr version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub help {
print "\nSNMP Radware Linkproof NHR monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "(c)2004-2006 Patrick Proy\n\n";
print_usage();
print <<EOT;
The plugin will test all nhr configured and will return
OK if all nhr are active
WARNING if one nhr at least is in "no new session" or "inactive" mode.
CRITICAL if all nhr are inactive.
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-f, --perfparse, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf
);
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
my $exit_val = undef;
########### NHR checks ##############
my $nhr_num = 0; # nujmber of NHR
my @nhr_table = undef; # index of NHR
my $output = undef;
my $perf_output = "";
my @oids = undef;
my $inactive_nhr = 0;
my $global_status = 0;
# Get load table
my $resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($lp_type)
: $session->get_table(Baseoid => $lp_type);
if (!defined($resultat)) {
printf("ERROR: NHR table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my $oidindex = 0;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($$resultat{$key} == 2) { # found NHR
$key =~ s/$lp_type\.//;
$nhr_table[$nhr_num++] = $key;
$oids[$oidindex++] = $lp_name . "." . $key;
$oids[$oidindex++] = $lp_users . "." . $key;
$oids[$oidindex++] = $lp_state . "." . $key;
$oids[$oidindex++] = $lp_port . "." . $key;
verb("found nhr : $key");
}
}
if ($nhr_num == 0) {
print "No NHR found : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
my $result = undef;
if (version->parse(Net::SNMP->VERSION) < 4) {
$result = $session->get_request(@oids);
} else {
if ($session->version == 0) {
# snmpv1
$result = $session->get_request(-varbindlist => \@oids);
} else {
# snmp v2c or v3 : get_bulk_request is not really good for this, so do simple get
$result = $session->get_request(-varbindlist => \@oids);
}
}
if (!defined($result)) {
printf("ERROR: NHR table get : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my ($nhr_name, $nhr_state, $nhr_users) = (undef, undef, undef);
my @nhr_text_state = ("", "active", "Not in service", "No new session");
for (my $i = 0; $i < $nhr_num; $i++) {
if (defined($output)) { $output .= "; "; }
$nhr_name = $$result{ $lp_name . "." . $nhr_table[$i] };
$nhr_state = $$result{ $lp_state . "." . $nhr_table[$i] };
$nhr_users = $$result{ $lp_users . "." . $nhr_table[$i] };
$output .= $nhr_name . "(" . $nhr_users . "):" . $nhr_text_state[$nhr_state];
if ($nhr_state == 1) {
if (defined($o_perf)) {
if (defined($perf_output)) { $perf_output .= " "; }
$perf_output .= $nhr_name . "=" . $nhr_users;
}
} elsif ($nhr_state == 2) {
$inactive_nhr++;
$global_status = 1;
} else {
$global_status = 1;
}
}
$session->close;
if ($inactive_nhr == $nhr_num) {
$output .= " : CRITICAL";
if (defined($o_perf)) { $output .= " | " . $perf_output; }
print $output, "\n";
exit $ERRORS{"CRITICAL"};
}
if ($global_status == 1) {
$output .= " : WARNING";
if (defined($o_perf)) { $output .= " | " . $perf_output; }
print $output, "\n";
exit $ERRORS{"WARNING"};
}
$output .= " : OK";
if (defined($o_perf)) { $output .= " | " . $perf_output; }
print $output, "\n";
exit $ERRORS{"OK"};

900
plugins/check_snmp_load.pl Executable file
View file

@ -0,0 +1,900 @@
#!/usr/bin/perl -w
############################## check_snmp_load #################
my $VERSION = "2.0.0";
# Date : Oct 12 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://nagios.manubulon.com/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contributors : F. Lacroix and many others !!!
#################################################################
#
# Help : ./check_snmp_load.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
# Generic with host-ressource-mib
my $base_proc = "1.3.6.1.2.1.25.3.3.1"; # oid for all proc info
my $proc_id = "1.3.6.1.2.1.25.3.3.1.1"; # list of processors (product ID)
my $proc_load = "1.3.6.1.2.1.25.3.3.1.2"; # %time the proc was not idle over last minute
# Linux load
my $linload_table = "1.3.6.1.4.1.2021.10.1"; # net-snmp load table
my $linload_name = "1.3.6.1.4.1.2021.10.1.2"; # text 'Load-1','Load-5', 'Load-15'
my $linload_load = "1.3.6.1.4.1.2021.10.1.3"; # effective load table
# Cisco cpu/load
my $cisco_cpu_5m = "1.3.6.1.4.1.9.2.1.58.0"; # Cisco CPU load (5min %)
my $cisco_cpu_1m = "1.3.6.1.4.1.9.2.1.57.0"; # Cisco CPU load (1min %)
my $cisco_cpu_5s = "1.3.6.1.4.1.9.2.1.56.0"; # Cisco CPU load (5sec %)
# Cisco catalyst cpu/load
my $ciscocata_cpu_5m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.5.9"; # Cisco CPU load (5min %)
my $ciscocata_cpu_1m = ".1.3.6.1.4.1.9.9.109.1.1.1.1.3.9"; # Cisco CPU load (1min %)
my $ciscocata_cpu_5s = ".1.3.6.1.4.1.9.9.109.1.1.1.1.4.9"; # Cisco CPU load (5sec %)
# Netscreen cpu/load
my $nsc_cpu_5m = "1.3.6.1.4.1.3224.16.1.4.0"; # NS CPU load (5min %)
my $nsc_cpu_1m = "1.3.6.1.4.1.3224.16.1.2.0"; # NS CPU load (1min %)
my $nsc_cpu_5s = "1.3.6.1.4.1.3224.16.1.3.0"; # NS CPU load (5sec %)
# AS/400 CPU
my $as400_cpu = "1.3.6.1.4.1.2.6.4.5.1.0"; # AS400 CPU load (10000=100%);
# N5K CPU
my $n5k_cpu = "1.3.6.1.4.1.9.9.305.1.1.1.0"; # N5K CPU load (%)
# Net-SNMP CPU
my $ns_cpu_idle = "1.3.6.1.4.1.2021.11.11.0"; # Net-snmp cpu idle
my $ns_cpu_user = "1.3.6.1.4.1.2021.11.9.0"; # Net-snmp user cpu usage
my $ns_cpu_system = "1.3.6.1.4.1.2021.11.10.0"; # Net-snmp system cpu usage
# Procurve CPU
my $procurve_cpu = "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0"; # Procurve CPU Counter
# Nokia CPU
my $nokia_cpu = "1.3.6.1.4.1.94.1.21.1.7.1.0"; # Nokia CPU % usage
# Bluecoat Appliance
my $bluecoat_cpu = "1.3.6.1.4.1.3417.2.4.1.1.1.4.1"; # Bluecoat %cpu usage.
# Fortigate CPU
my $fortigate_cpu = ".1.3.6.1.4.1.12356.1.8.0"; # Fortigate CPU % usage
# Linkproof Appliance
my $linkproof_cpu = "1.3.6.1.4.1.89.35.1.55.0"; # CPU RE (Routing Engine Tasks)
# 1.3.6.1.4.1.89.35.1.53.0 : Ressource utilisation (%) Considers network utilization and internal CPU utilization
# 1.3.6.1.4.1.89.35.1.54 : CPU only (%)
# 1.3.6.1.4.1.89.35.1.55 : network only (%)
# HP-UX cpu usage (thanks to krizb for the OIDs).
my $hpux_load_1_min = "1.3.6.1.4.1.11.2.3.1.1.3.0";
my $hpux_load_5_min = "1.3.6.1.4.1.11.2.3.1.1.4.0";
my $hpux_load_15_min = "1.3.6.1.4.1.11.2.3.1.1.5.0";
# valid values
my @valid_types
= ("stand", "netsc", "netsl", "as400", "cisco", "cata", "nsc", "fg", "bc", "nokia", "hp", "lp", "hpux", "n5k");
# CPU OID array
my %cpu_oid = (
"netsc", $ns_cpu_idle, "as400", $as400_cpu, "bc", $bluecoat_cpu, "nokia", $nokia_cpu,
"hp", $procurve_cpu, "lp", $linkproof_cpu, "fg", $fortigate_cpu, "n5k", $n5k_cpu
);
# Globals
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_domain = 'udp/ipv4'; # protocol
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
# check type : stand | netsc | netsl | as400 | cisco | cata | nsc | fg | bc | nokia | hp | lp | hpux
my $o_check_type = "stand";
# End compatibility
my $o_warn = undef; # warning level
my @o_warnL = undef; # warning levels for Linux Load or Cisco CPU
my $o_crit = undef; # critical level
my @o_critL = undef; # critical level for Linux Load or Cisco CPU
my $o_timeout = undef; # Timeout (Default 5)
my $o_perf = undef; # Output performance data
my $o_version2 = undef; # use snmp v2c
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_load version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-P <protocol>] -w <warn level> -c <crit level> -T=[stand|netsl|netsc|as400|cisco|cata|nsc|fg|bc|nokia|hp|lp|hpux] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub help {
print "\nSNMP Load & CPU Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL license, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-p, --port=PORT
SNMP port (Default 161)
-P, --protocol=PROTOCOL
Network protocol to be used
['udp/ipv4'] : UDP over IPv4
'udp/ipv6' : UDP over IPv6
'tcp/ipv4' : TCP over IPv4
'tcp/ipv6' : TCP over IPv6
Network protocol (Default udp/ipv4)
-w, --warn=INTEGER | INT,INT,INT
1 value check : warning level for cpu in percent (on one minute)
3 value check : comma separated level for load or cpu for 1min, 5min, 15min
-c, --crit=INTEGER | INT,INT,INT
critical level for cpu in percent (on one minute)
1 value check : critical level for cpu in percent (on one minute)
3 value check : comma separated level for load or cpu for 1min, 5min, 15min
-T, --type=stand|netsl|netsc|as400|cisco|bc|nokia|hp|lp
CPU check :
stand : standard MIBII (works with Windows),
can handle multiple CPU.
netsl : linux load provided by Net SNMP (1,5 & 15 minutes values)
netsc : cpu usage given by net-snmp (100-idle)
as400 : as400 CPU usage
cisco : Cisco CPU usage
n5k : Cisco Nexus CPU Usage
cata : Cisco catalyst CPU usage
nsc : NetScreen CPU usage
fg : Fortigate CPU usage
bc : Bluecoat CPU usage
nokia : Nokia CPU usage
hp : HP procurve switch CPU usage
lp : Linkproof CPU usage
hpux : HP-UX load (1,5 & 15 minutes values)
-f, --perfparse, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'P:s' => \$o_domain,
'protocol:s' => \$o_domain,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'c:s' => \$o_crit,
'critical:s' => \$o_crit,
'w:s' => \$o_warn,
'warn:s' => \$o_warn,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf,
'T:s' => \$o_check_type,
'type:s' => \$o_check_type
);
# check the -T option
my $T_option_valid = 0;
foreach (@valid_types) {
if ($_ eq $o_check_type) { $T_option_valid = 1 }
}
if ($T_option_valid == 0) { print "Invalid check type (-T)!\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check warnings and critical
if (!defined($o_warn) || !defined($o_crit)) {
print "put warning and critical info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Get rid of % sign
$o_warn =~ s/\%//g;
$o_crit =~ s/\%//g;
# Check for multiple warning and crit in case of -L
if ( ($o_check_type eq "netsl")
|| ($o_check_type eq "cisco")
|| ($o_check_type eq "cata")
|| ($o_check_type eq "nsc")
|| ($o_check_type eq "hpux"))
{
@o_warnL = split(/,/, $o_warn);
@o_critL = split(/,/, $o_crit);
if (($#o_warnL != 2) || ($#o_critL != 2)) {
print "3 warnings and critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
for (my $i = 0; $i < 3; $i++) {
if (isnnum($o_warnL[$i]) || isnnum($o_critL[$i])) {
print "Numeric value for warning or critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_warnL[$i] > $o_critL[$i]) {
print "warning <= critical ! \n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
} else {
if (($o_warn =~ /,/) || ($o_crit =~ /,/)) {
{
print "Multiple warning/critical levels not available for this check\n";
print_usage();
exit $ERRORS{"UNKNOWN"}
}
}
if (isnnum($o_warn) || isnnum($o_crit)) {
print "Numeric value for warning or critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_warn > $o_crit) { print "warning <= critical ! \n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
}
# This is required to get around all of the silly historical methods of
# versioning with Net::SNMP.
sub is_legacy_snmp_version {
my $version = Net::SNMP->VERSION; #using a variable for easier testing
if ($version =~ /^\D*(\d)/ and $1 < 4) {
return 1;
} else {
return 0;
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout,
-domain => $o_domain
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
my $exit_val = undef;
########### Linux load check ##############
if ($o_check_type eq "netsl") {
verb("Checking linux load");
# Get number of CPUs
my $resultat
= (is_legacy_snmp_version())
? $session->get_table($proc_id)
: $session->get_table(Baseoid => $proc_id);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my $ncpu = keys %$resultat;
# Get load table
$resultat
= (is_legacy_snmp_version())
? $session->get_table($linload_table)
: $session->get_table(Baseoid => $linload_table);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my @load = undef;
my @iload = undef;
my @oid = undef;
my $exist = 0;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($key =~ /$linload_name/) {
@oid = split(/\./, $key);
$iload[0] = pop(@oid) if ($$resultat{$key} eq "Load-1");
$iload[1] = pop(@oid) if ($$resultat{$key} eq "Load-5");
$iload[2] = pop(@oid) if ($$resultat{$key} eq "Load-15");
$exist = 1;
}
}
if ($exist == 0) {
print "Can't find snmp information on load : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
for (my $i = 0; $i < 3; $i++) { $load[$i] = $$resultat{ $linload_load . "." . $iload[$i] } }
print "Load (CPUs: $ncpu) : $load[0] $load[1] $load[2] :";
$exit_val = $ERRORS{"OK"};
for (my $i = 0; $i < 3; $i++) {
# Multiply warning and critical levels by the number of CPUs
$o_warnL[$i] *= $ncpu;
$o_critL[$i] *= $ncpu;
if ($load[$i] > $o_critL[$i]) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
}
if ($load[$i] > $o_warnL[$i]) {
# output warn error only if no critical was found
if ($exit_val eq $ERRORS{"OK"}) {
print " $load[$i] > $o_warnL[$i] : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
}
print " OK" if ($exit_val eq $ERRORS{"OK"});
if (defined($o_perf)) {
print " | load_1_min=$load[0];$o_warnL[0];$o_critL[0] ";
print "load_5_min=$load[1];$o_warnL[1];$o_critL[1] ";
print "load_15_min=$load[2];$o_warnL[2];$o_critL[2]\n";
} else {
print "\n";
}
exit $exit_val;
}
############## Cisco CPU check ################
if ($o_check_type eq "cisco") {
my @oidlists = ($cisco_cpu_5m, $cisco_cpu_1m, $cisco_cpu_5s);
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlists)
: $session->get_request(-varbindlist => \@oidlists);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{$cisco_cpu_5s})) {
print "No CPU information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my @load = undef;
$load[0] = $$resultat{$cisco_cpu_5s};
$load[1] = $$resultat{$cisco_cpu_1m};
$load[2] = $$resultat{$cisco_cpu_5m};
print "CPU : $load[0] $load[1] $load[2] :";
$exit_val = $ERRORS{"OK"};
for (my $i = 0; $i < 3; $i++) {
if ($load[$i] > $o_critL[$i]) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
}
if ($load[$i] > $o_warnL[$i]) {
# output warn error only if no critical was found
if ($exit_val eq $ERRORS{"OK"}) {
print " $load[$i] > $o_warnL[$i] : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
}
print " OK" if ($exit_val eq $ERRORS{"OK"});
if (defined($o_perf)) {
print " | load_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";
print "load_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";
print "load_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";
} else {
print "\n";
}
exit $exit_val;
}
############## Cisco N5K CPU Check ###################
if ($o_check_type eq "n5k") {
my @oidlists = ($n5k_cpu);
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlists)
: $session->get_request(-varbindlist => \@oidlists);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{$n5k_cpu})) {
print "No CPU information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my $n5k_load = $$resultat{$n5k_cpu};
if ($n5k_load > $o_crit) {
print "$n5k_load% > $o_crit% : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
} elsif ($n5k_load > $o_warn) {
print "$n5k_load% > $o_warn% : WARNING";
$exit_val = $ERRORS{"WARNING"};
} else {
print "CPU: $n5k_load%";
$exit_val = $ERRORS{"OK"};
}
if (defined($o_perf)) {
print " | n5k_load=$n5k_load%";
}
print "\n";
exit $exit_val;
}
############## Cisco Catalyst CPU check ################
if ($o_check_type eq "cata") {
my @oidlists = ($ciscocata_cpu_5m, $ciscocata_cpu_1m, $ciscocata_cpu_5s);
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlists)
: $session->get_request(-varbindlist => \@oidlists);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{$ciscocata_cpu_5s})) {
print "No CPU information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my @load = undef;
$load[0] = $$resultat{$ciscocata_cpu_5s};
$load[1] = $$resultat{$ciscocata_cpu_1m};
$load[2] = $$resultat{$ciscocata_cpu_5m};
print "CPU : $load[0] $load[1] $load[2] :";
$exit_val = $ERRORS{"OK"};
for (my $i = 0; $i < 3; $i++) {
if ($load[$i] > $o_critL[$i]) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
}
if ($load[$i] > $o_warnL[$i]) {
# output warn error only if no critical was found
if ($exit_val eq $ERRORS{"OK"}) {
print " $load[$i] > $o_warnL[$i] : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
}
print " OK" if ($exit_val eq $ERRORS{"OK"});
if (defined($o_perf)) {
print " | load_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";
print "load_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";
print "load_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";
} else {
print "\n";
}
exit $exit_val;
}
############## Netscreen CPU check ################
if ($o_check_type eq "nsc") {
my @oidlists = ($nsc_cpu_5m, $nsc_cpu_1m, $nsc_cpu_5s);
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlists)
: $session->get_request(-varbindlist => \@oidlists);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{$nsc_cpu_5s})) {
print "No CPU information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my @load = undef;
$load[0] = $$resultat{$nsc_cpu_5s};
$load[1] = $$resultat{$nsc_cpu_1m};
$load[2] = $$resultat{$nsc_cpu_5m};
print "CPU : $load[0] $load[1] $load[2] :";
$exit_val = $ERRORS{"OK"};
for (my $i = 0; $i < 3; $i++) {
if ($load[$i] > $o_critL[$i]) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
}
if ($load[$i] > $o_warnL[$i]) {
# output warn error only if no critical was found
if ($exit_val eq $ERRORS{"OK"}) {
print " $load[$i] > $o_warnL[$i] : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
}
print " OK" if ($exit_val eq $ERRORS{"OK"});
if (defined($o_perf)) {
print " | cpu_5_sec=$load[0]%;$o_warnL[0];$o_critL[0] ";
print "cpu_1_min=$load[1]%;$o_warnL[1];$o_critL[1] ";
print "cpu_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";
} else {
print "\n";
}
exit $exit_val;
}
################## CPU for : AS/400 , Netsnmp, HP, Bluecoat, linkproof, fortigate ###########
if ($o_check_type =~ /netsc|as400|bc|nokia|^hp$|lp|fg/) {
# Get load table
my @oidlist = $cpu_oid{$o_check_type};
verb("Checking OID : @oidlist");
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlist)
: $session->get_request(-varbindlist => \@oidlist);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{ $cpu_oid{$o_check_type} })) {
print "No CPU information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my $load = $$resultat{ $cpu_oid{$o_check_type} };
verb("OID returned $load");
# for AS400, divide by 100
if ($o_check_type eq "as400") { $load /= 100; }
# for Net-snmp : oid returned idle time so load = 100-idle.
if ($o_check_type eq "netsc") { $load = 100 - $load; }
printf("CPU used %.1f%% (", $load);
$exit_val = $ERRORS{"OK"};
if ($load > $o_crit) {
print ">$o_crit) : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
} else {
if ($load > $o_warn) {
print ">$o_warn) : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
print "<$o_warn) : OK" if ($exit_val eq $ERRORS{"OK"});
(defined($o_perf))
? print " | cpu_prct_used=$load%;$o_warn;$o_crit\n"
: print "\n";
exit $exit_val;
}
##### Checking hpux load
if ($o_check_type eq "hpux") {
verb("Checking hpux load");
my @oidlists = ($hpux_load_1_min, $hpux_load_5_min, $hpux_load_15_min);
my $resultat
= (is_legacy_snmp_version())
? $session->get_request(@oidlists)
: $session->get_request(-varbindlist => \@oidlists);
if (!defined($resultat)) {
printf("ERROR: Load table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
if (!defined($$resultat{$hpux_load_1_min})) {
print "No Load information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my @load = undef;
$load[0] = $$resultat{$hpux_load_1_min} / 100;
$load[1] = $$resultat{$hpux_load_5_min} / 100;
$load[2] = $$resultat{$hpux_load_15_min} / 100;
print "Load : $load[0] $load[1] $load[2] :";
$exit_val = $ERRORS{"OK"};
for (my $i = 0; $i < 3; $i++) {
if ($load[$i] > $o_critL[$i]) {
print " $load[$i] > $o_critL[$i] : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
}
if ($load[$i] > $o_warnL[$i]) {
# output warn error only if no critical was found
if ($exit_val eq $ERRORS{"OK"}) {
print " $load[$i] > $o_warnL[$i] : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
}
print " OK" if ($exit_val eq $ERRORS{"OK"});
if (defined($o_perf)) {
print " | load_1_min=$load[0]%;$o_warnL[0];$o_critL[0] ";
print "load_5_min=$load[1]%;$o_warnL[1];$o_critL[1] ";
print "load_15_min=$load[2]%;$o_warnL[2];$o_critL[2]\n";
} else {
print "\n";
}
exit $exit_val;
}
########## Standard cpu usage check ############
# Get desctiption table
my $resultat
= (is_legacy_snmp_version())
? $session->get_table($base_proc)
: $session->get_table(Baseoid => $base_proc);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my ($cpu_used, $ncpu) = (0, 0);
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($key =~ /$proc_load/) {
$cpu_used += $$resultat{$key};
$ncpu++;
}
}
if ($ncpu == 0) {
print "Can't find CPU usage information : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
$cpu_used /= $ncpu;
print "$ncpu CPU, ", $ncpu == 1 ? "load" : "average load";
printf(" %.1f%%", $cpu_used);
$exit_val = $ERRORS{"OK"};
if ($cpu_used > $o_crit) {
print " > $o_crit% : CRITICAL";
$exit_val = $ERRORS{"CRITICAL"};
} else {
if ($cpu_used > $o_warn) {
print " > $o_warn% : WARNING";
$exit_val = $ERRORS{"WARNING"};
}
}
print " < $o_warn% : OK" if ($exit_val eq $ERRORS{"OK"});
(defined($o_perf))
? print " | cpu_prct_used=$cpu_used%;$o_warn;$o_crit\n"
: print "\n";
exit $exit_val;

626
plugins/check_snmp_mem.pl Executable file
View file

@ -0,0 +1,626 @@
#!/usr/bin/perl -w
############################## check_snmp_mem ##############
my $VERSION = "2.0.0";
# Date : 17 October 2007
# Author : Patrick Proy (nagios at proy.org)
# Help : http://nagios.manubulon.com/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : Jan Jungmann, Patrick Griffin
# TODO :
#################################################################
#
# Help : ./check_snmp_mem.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my $TIMEOUT = 15;
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
# Net-snmp memory
my $nets_ram_free = "1.3.6.1.4.1.2021.4.6.0"; # Real memory free
my $nets_ram_total = "1.3.6.1.4.1.2021.4.5.0"; # Real memory total
my $nets_ram_buffer = "1.3.6.1.4.1.2021.4.14.0"; # Real memory buffered
my $nets_ram_cache = "1.3.6.1.4.1.2021.4.15.0"; # Real memory cached
my $nets_swap_free = "1.3.6.1.4.1.2021.4.4.0"; # swap memory free
my $nets_swap_total = "1.3.6.1.4.1.2021.4.3.0"; # Swap memory total
my @nets_oids = ($nets_ram_free, $nets_ram_total, $nets_swap_free, $nets_swap_total, $nets_ram_cache, $nets_ram_buffer);
# Cisco
my $cisco_mem_pool = "1.3.6.1.4.1.9.9.48.1.1.1"; # Cisco memory pool
my $cisco_index = "1.3.6.1.4.1.9.9.48.1.1.1.2"; # memory pool name and index
my $cisco_valid = "1.3.6.1.4.1.9.9.48.1.1.1.4"; # Valid memory if 1
my $cisco_used = "1.3.6.1.4.1.9.9.48.1.1.1.5"; # Used memory
my $cisco_free = "1.3.6.1.4.1.9.9.48.1.1.1.6"; # Free memory
# .1 : type, .2 : name, .3 : alternate, .4 : valid, .5 : used, .6 : free, .7 : max free
# HP Procurve
my $hp_mem_pool = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1"; # HP memory pool
my $hp_mem_index = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.1"; # memory slot index
my $hp_mem_total = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5"; # Total Bytes
my $hp_mem_free = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6"; # Free Bytes
my $hp_mem_free_seg = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.3"; # Free segments
# AS/400
# Windows NT/2K/(XP?)
# check_snmp_storage.pl -C <community> -H <hostIP> -m "^Virtual Memory$" -w <warn %> -c <crit %>
# Globals
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_domain = 'udp/ipv4'; # Default to UDP over IPv4
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_netsnmp = 1; # Check with netsnmp (default)
my $o_cisco = undef; # Check cisco router mem
my $o_hp = undef; # Check hp procurve mem
my $o_warn = undef; # warning level option
my $o_warnR = undef; # warning level for Real memory
my $o_warnS = undef; # warning levels for swap
my $o_crit = undef; # Critical level option
my $o_critR = undef; # critical level for Real memory
my $o_critS = undef; # critical level for swap
my $o_perf = undef; # Performance data option
my $o_cache = undef; # Include cached memory as used memory
my $o_buffer = undef; # Exclude buffered memory as used memory
my $o_timeout = undef; # Timeout (Default 5)
my $o_version2 = undef; # use snmp v2c
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_mem version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-P <protocol>] -w <warn level> -c <crit level> [-I|-N|-E] [-f] [-m -b] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub round ($$) {
sprintf "%.$_[1]f", $_[0];
}
sub help {
print "\nSNMP Memory Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL license, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-p, --port=PORT
SNMP port (Default 161)
-P, --protocol=PROTOCOL
Network protocol to be used
['udp/ipv4'] : UDP over IPv4
'udp/ipv6' : UDP over IPv6
'tcp/ipv4' : TCP over IPv4
'tcp/ipv6' : TCP over IPv6
-w, --warn=INTEGER | INT,INT
warning level for memory in percent (0 for no checks)
Default (-N switch) : comma separated level for Real Memory and Swap
-I switch : warning level
-c, --crit=INTEGER | INT,INT
critical level for memory in percent (0 for no checks)
Default (-N switch) : comma separated level for Real Memory and Swap
-I switch : critical level
-N, --netsnmp (default)
check linux memory & swap provided by Net SNMP
-m, --memcache
include cached memory in used memory (only with Net-SNMP)
-b, --membuffer
exclude buffered memory in used memory (only with Net-SNMP)
-I, --cisco
check cisco memory (sum of all memory pools)
-E, --hp
check HP proccurve memory
-f, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
# Get the alarm signal (just in case snmp timout screws up)
$SIG{'ALRM'} = sub {
print("ERROR: Alarm signal (Nagios time-out)\n");
exit $ERRORS{"UNKNOWN"};
};
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'P:s' => \$o_domain,
'protocol:s' => \$o_domain,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'I' => \$o_cisco,
'cisco' => \$o_cisco,
'N' => \$o_netsnmp,
'netsnmp' => \$o_netsnmp,
'E' => \$o_hp,
'hp' => \$o_hp,
'2' => \$o_version2,
'v2c' => \$o_version2,
'c:s' => \$o_crit,
'critical:s' => \$o_crit,
'w:s' => \$o_warn,
'warn:s' => \$o_warn,
'm' => \$o_cache,
'memcache' => \$o_cache,
'b' => \$o_buffer,
'membuffer' => \$o_buffer,
'f' => \$o_perf,
'perfdata' => \$o_perf
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print "No host defined!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
#Check Warning and crit are present
if (!defined($o_warn) || !defined($o_crit)) {
print "Put warning and critical values!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Get rid of % sign
$o_warn =~ s/\%//g;
$o_crit =~ s/\%//g;
# if -N or -E switch , undef $o_netsnmp
if (defined($o_cisco) || defined($o_hp)) {
$o_netsnmp = undef;
if (isnnum($o_warn) || isnnum($o_crit)) {
print "Numeric value for warning or critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (($o_crit != 0) && ($o_warn > $o_crit)) {
print "warning <= critical ! \n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (defined($o_netsnmp)) {
my @o_warnL = split(/,/, $o_warn);
my @o_critL = split(/,/, $o_crit);
if (($#o_warnL != 1) || ($#o_critL != 1)) {
print "2 warnings and critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
for (my $i = 0; $i < 2; $i++) {
if (isnnum($o_warnL[$i]) || isnnum($o_critL[$i])) {
print "Numeric value for warning or critical !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (($o_critL[$i] != 0) && ($o_warnL[$i] > $o_critL[$i])) {
print "warning <= critical ! \n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_critL[$i] > 100) {
print "critical percent must be < 100 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
$o_warnR = $o_warnL[0];
$o_warnS = $o_warnL[1];
$o_critR = $o_critL[0];
$o_critS = $o_critL[1];
}
}
########## MAIN #######
check_options();
# Check gobal timeout if snmp screws up
if (defined($TIMEOUT)) {
verb("Alarm at $TIMEOUT");
alarm($TIMEOUT);
} else {
verb("no timeout defined : $o_timeout + 10");
alarm($o_timeout + 10);
}
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout,
-domain => $o_domain
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
# Global variable
my $resultat = undef;
########### Cisco memory check ############
if (defined($o_cisco)) {
# Get Cisco memory table
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($cisco_mem_pool)
: $session->get_table(Baseoid => $cisco_mem_pool);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my (@oid, @index) = (undef, undef);
my $nindex = 0;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($key =~ /$cisco_index/) {
@oid = split(/\./, $key);
$index[$nindex++] = pop(@oid);
}
}
# Check if at least 1 memory pool exists
if ($nindex == 0) {
printf("ERROR: No memory pools found");
$session->close;
exit $ERRORS{"UNKNOWN"};
}
# Test every memory pool
my ($c_output, $prct_free) = (undef, undef);
my ($warn_s, $crit_s) = (0, 0);
my ($used, $free) = (0, 0);
foreach (@index) {
$c_output .= "," if defined($c_output);
if ($$resultat{ $cisco_valid . "." . $_ } == 1) {
$used += $$resultat{ $cisco_used . "." . $_ };
$free += $$resultat{ $cisco_free . "." . $_ };
$prct_free = round(
$$resultat{ $cisco_used . "." . $_ } * 100
/ ($$resultat{ $cisco_free . "." . $_ } + $$resultat{ $cisco_used . "." . $_ }),
0
);
$c_output .= $$resultat{ $cisco_index . "." . $_ } . ":" . $prct_free . "%";
if (($o_crit != 0) && ($o_crit <= $prct_free)) {
$crit_s = 1;
} elsif (($o_warn != 0) && ($o_warn <= $prct_free)) {
$warn_s = 1;
}
} else {
$c_output .= $$resultat{ $cisco_index . "." . $_ } . ": INVALID";
$crit_s = 1;
}
}
my $total = $used + $free;
$prct_free = round($used * 100 / ($total), 0);
verb("Total used : $used, free: $free, output : $c_output");
my $c_status = "OK";
$c_output .= " : " . $prct_free . "% : ";
if ($crit_s == 1) {
$c_output .= " > " . $o_crit;
$c_status = "CRITICAL";
} else {
if ($warn_s == 1) {
$c_output .= " > " . $o_warn;
$c_status = "WARNING";
}
}
$c_output .= " ; " . $c_status;
if (defined($o_perf)) {
$c_output .= " | ram_used=" . $used . ";";
$c_output .= ($o_warn == 0) ? ";" : round($o_warn * $total / 100, 0) . ";";
$c_output .= ($o_crit == 0) ? ";" : round($o_crit * $total / 100, 0) . ";";
$c_output .= "0;" . $total;
}
$session->close;
print "$c_output \n";
exit $ERRORS{$c_status};
}
########### HP Procurve memory check ############
if (defined($o_hp)) {
# Get hp memory table
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($hp_mem_pool)
: $session->get_table(Baseoid => $hp_mem_pool);
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my (@oid, @index) = (undef, undef);
my $nindex = 0;
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($key =~ /$hp_mem_index/) {
@oid = split(/\./, $key);
$index[$nindex++] = pop(@oid);
}
}
# Check if at least 1 memory slots exists
if ($nindex == 0) {
printf("ERROR: No memory slots found");
$session->close;
exit $ERRORS{"UNKNOWN"};
}
# Consolidate the datas
my ($total, $free) = (0, 0);
my ($c_output, $prct_free) = (undef, undef);
foreach (@index) {
$c_output .= "," if defined($c_output);
$total += $$resultat{ $hp_mem_total . "." . $_ };
$free += $$resultat{ $hp_mem_free . "." . $_ };
$c_output
.= "Slot "
. $$resultat{ $hp_mem_index . "." . $_ } . ":"
. round(100 - ($$resultat{ $hp_mem_free . "." . $_ } * 100 / $$resultat{ $hp_mem_total . "." . $_ }), 0)
. "%";
}
my $used = $total - $free;
$prct_free = round($used * 100 / ($total), 0);
verb("Used : $used, Free: $free, Output : $c_output");
my $c_status = "OK";
$c_output .= " : " . $prct_free . "% : ";
if (($o_crit != 0) && ($o_crit <= $prct_free)) {
$c_output .= " > " . $o_crit;
$c_status = "CRITICAL";
} else {
if (($o_warn != 0) && ($o_warn <= $prct_free)) {
$c_output .= " > " . $o_warn;
$c_status = "WARNING";
}
}
$c_output .= " ; " . $c_status;
if (defined($o_perf)) {
$c_output .= " | ram_used=" . $used . ";";
$c_output .= ($o_warn == 0) ? ";" : round($o_warn * $total / 100, 0) . ";";
$c_output .= ($o_crit == 0) ? ";" : round($o_crit * $total / 100, 0) . ";";
$c_output .= "0;" . $total;
}
$session->close;
print "$c_output \n";
exit $ERRORS{$c_status};
}
########### Net snmp memory check ############
if (defined($o_netsnmp)) {
# Get NetSNMP memory values
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@nets_oids)
: $session->get_request(-varbindlist => \@nets_oids);
if (!defined($resultat)) {
printf("ERROR: netsnmp : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my ($realused, $swapused) = (undef, undef);
my $totalcachedbuffered = 0;
if (defined($o_buffer)) {
$totalcachedbuffered = $$resultat{$nets_ram_buffer};
}
if (!defined($o_cache)) {
$totalcachedbuffered = $totalcachedbuffered + $$resultat{$nets_ram_cache};
}
$realused = ($$resultat{$nets_ram_total} - ($$resultat{$nets_ram_free} + $totalcachedbuffered))
/ $$resultat{$nets_ram_total};
if ($$resultat{$nets_ram_total} == 0) { $realused = 0; }
$swapused
= ($$resultat{$nets_swap_total} == 0)
? 0
: ($$resultat{$nets_swap_total} - $$resultat{$nets_swap_free}) / $$resultat{$nets_swap_total};
$realused = round($realused * 100, 0);
$swapused = round($swapused * 100, 0);
verb(
"Ram : $$resultat{$nets_ram_free} ($$resultat{$nets_ram_cache} cached, $$resultat{$nets_ram_buffer} buff) / $$resultat{$nets_ram_total} : $realused"
);
verb("Swap : $$resultat{$nets_swap_free} / $$resultat{$nets_swap_total} : $swapused");
my $n_status = "OK";
my $n_output = "Ram : " . $realused . "%, Swap : " . $swapused . "% :";
if ((($o_critR != 0) && ($o_critR <= $realused)) || (($o_critS != 0) && ($o_critS <= $swapused))) {
$n_output .= " > " . $o_critR . ", " . $o_critS;
$n_status = "CRITICAL";
} else {
if ((($o_warnR != 0) && ($o_warnR <= $realused)) || (($o_warnS != 0) && ($o_warnS <= $swapused))) {
$n_output .= " > " . $o_warnR . ", " . $o_warnS;
$n_status = "WARNING";
}
}
$n_output .= " ; " . $n_status;
if (defined($o_perf)) {
if (defined($o_cache)) {
$n_output .= " | ram_used=" . ($$resultat{$nets_ram_total} - $$resultat{$nets_ram_free}) . ";";
} else {
$n_output .= " | ram_used="
. ($$resultat{$nets_ram_total} - $$resultat{$nets_ram_free} - $$resultat{$nets_ram_cache}) . ";";
}
$n_output .= ($o_warnR == 0) ? ";" : round($o_warnR * $$resultat{$nets_ram_total} / 100, 0) . ";";
$n_output .= ($o_critR == 0) ? ";" : round($o_critR * $$resultat{$nets_ram_total} / 100, 0) . ";";
$n_output .= "0;" . $$resultat{$nets_ram_total} . " ";
$n_output .= "swap_used=" . ($$resultat{$nets_swap_total} - $$resultat{$nets_swap_free}) . ";";
$n_output .= ($o_warnS == 0) ? ";" : round($o_warnS * $$resultat{$nets_swap_total} / 100, 0) . ";";
$n_output .= ($o_critS == 0) ? ";" : round($o_critS * $$resultat{$nets_swap_total} / 100, 0) . ";";
$n_output .= "0;" . $$resultat{$nets_swap_total};
}
$session->close;
print "$n_output \n";
exit $ERRORS{$n_status};
}

406
plugins/check_snmp_nsbox.pl Executable file
View file

@ -0,0 +1,406 @@
#!/usr/bin/perl -w
############################## check_snmp_nsbox #################
# Version : 1.0
# Date : Jan 16 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://www.manubulon.com/nagios/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Changelog :
# Contributors :
#################################################################
#
# Help : ./check_snmp_nsbox.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my $TIMEOUT = 15;
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $ns_service_status = "1.3.6.1.4.1.14020.2.2.1.3.0"; # service status 1= ok ??
my $ns_service_table = "1.3.6.1.4.1.14020.2.3"; # vhost & diode table
my $ns_vhost_table = "1.3.6.1.4.1.14020.2.3.1"; # vhost table
my $ns_vhost_name = "1.0"; # GUI Vhost Name
my $ns_vhost_requests = "2.0"; # Instant Vhost Requests per Second : NOT POPULATED IN V 2.0.8
my $ns_vhost_Trequests = "2.0"; # Total Vhost Requests : NOT POPULATED IN V 2.0.8
my $ns_diode_table = "1.3.6.1.4.1.14020.2.3.2"; # diode table
my $ns_diode_name = "1.0"; # GUI Diode Name
my $ns_diode_status = "2.0"; # Last diode Status (" " = OK?) (undocumented)
my $ns_rsa_prct_usage = ".1.3.6.1.4.1.14020.1.1.1.3.0"; # % usage of RSA operations. (undocumented)
my $ns_rsa_oper_second = ".1.3.6.1.4.1.14020.1.1.3.4.0;"; # number of RSA operations/s (undocumented)
# Globals
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_timeout = undef; # Timeout (Default 5)
my $o_perf = undef; # Output performance data
my $o_version2 = undef; # use snmp v2c
# specific
my $o_vhost = undef; # vhost regexp
my $o_diode = undef; # diode regexp
my $o_nvhost = undef; # vhost number
my $o_ndiode = undef; # diode number
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_nsbox version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -d <diode> -s <vhost> -n <ndiode>,<nvhost> [-p <port>] [-f] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub set_status { # return worst status with this order : OK, unknwonw, warning, critical
my $new_status = shift;
my $cur_status = shift;
if (($cur_status == 0) || ($new_status == $cur_status)) { return $new_status; }
if ($new_status == 3) { return $cur_status; }
if ($new_status > $cur_status) { return $new_status; }
return $cur_status;
}
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
my $pat = shift;
if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings
return eval { "" =~ /$pat/; 1 } || 0;
}
sub help {
print "\nSNMP NetSecureOne Netbox monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "(c)2004-2006 Patrick Proy\n\n";
print_usage();
print <<EOT;
Check that diode and vhost selected by regexp are active.
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-d, --diode=<diode>
Diode selection by regexp
-s, --vhost=<vhost>
Vhost selection by regexp
-n, --number=<ndiode>,<nvhost>
number of diode and vhost that must be up.
-P, --port=PORT
SNMP port (Default 161)
-f, --perfparse, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'2' => \$o_version2,
'v2c' => \$o_version2,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf,
'd:s' => \$o_diode,
'diode:s' => \$o_diode,
's:s' => \$o_vhost,
'vhost:s' => \$o_vhost,
'n:s' => \$o_nvhost,
'number:s' => \$o_nvhost
);
# Basic checks
if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (!defined($o_vhost) || !(is_pattern_valid($o_vhost))) {
print "Vhost selection must be set and be a valid regexp (-s)\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_diode) || !(is_pattern_valid($o_diode))) {
print "Diode selection must be set and be a valid regexp (-d)\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_nvhost)) {
print "Diode and vhost number must be set (-n)\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @nsbox_number = split(/,/, $o_nvhost);
if ($#nsbox_number != 1) { print "2 numbers must be set with -n option\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if (isnnum($nsbox_number[0]) || isnnum($nsbox_number[1])) {
print "2 numbers must be set with -n option\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
$o_ndiode = $nsbox_number[0];
$o_nvhost = $nsbox_number[1];
}
########## MAIN #######
check_options();
# Check gobal timeout if snmp screws up
if (defined($TIMEOUT)) {
verb("Alarm at $TIMEOUT + 5");
alarm($TIMEOUT + 5);
} else {
verb("no global timeout defined : $o_timeout + 10");
alarm($o_timeout + 10);
}
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
########### check global status ##############
my @oidlist = ($ns_service_status);
my $resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oidlist)
: $session->get_request(-varbindlist => \@oidlist);
if (!defined($resultat) || ($$resultat{$ns_service_status} eq "noSuchObject")) {
printf("ERROR: Global status oid not found : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
if ($$resultat{$ns_service_status} != 1) {
print "Global service is in state ", $$resultat{$ns_service_status}, " : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
########### check vhost & diode status ##############
$resultat = undef;
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($ns_service_table)
: $session->get_table(Baseoid => $ns_service_table);
if (!defined($resultat)) {
printf("ERROR: vhost and diode status table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my $output = "";
my $output_perf = "";
my ($index, $name) = undef;
my ($nvhost, $ndiode) = (0, 0);
my (@found_vhost, @found_diode) = (undef, undef);
foreach my $key (keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
if ($key =~ /($ns_vhost_table)\.(\d+)\.($ns_vhost_name)/) { # Get index of vhost with name
$index = $2;
$name = $$resultat{$key};
if ($name =~ /$o_vhost/) {
$found_vhost[$nvhost++] = $name;
verb("found vhost $name");
}
}
if ($key =~ /($ns_diode_table)\.(\d+)\.($ns_diode_name)/) { # Get index of diode with name
$index = $2;
$name = $$resultat{$key};
if ($name =~ /$o_diode/) {
# TODO Check diode status : undocumented for now.
$found_diode[$ndiode++] = $name;
verb("found diode $name");
}
}
}
if (($ndiode < $o_ndiode) || ($nvhost < $o_nvhost)) {
$output = "Diode";
if ($ndiode == 0) { $output .= ": none "; }
else {
$output .= "(" . $ndiode . "): :";
for (my $i = 0; $i < $ndiode; $i++) {
$output .= $found_diode[$i] . " ";
}
}
$output .= "Vhost";
if ($nvhost == 0) { $output .= ": none "; }
else {
$output .= "(" . $nvhost . "): :";
for (my $i = 0; $i < $nvhost; $i++) {
$output .= $found_vhost[$i] . " ";
}
}
$output .= " < " . $o_ndiode . "," . $o_nvhost . " : CRITICAL";
print $output, "\n";
exit $ERRORS{"CRITICAL"};
}
$output = $ndiode . " diodes, " . $nvhost . " vhosts :";
if (($ndiode > $o_ndiode) || ($nvhost > $o_nvhost)) {
$output .= " > " . $o_ndiode . "," . $o_nvhost . " : WARNING";
} else {
$output .= " OK";
}
print $output, "\n";
exit $ERRORS{"OK"};

848
plugins/check_snmp_process.pl Executable file
View file

@ -0,0 +1,848 @@
#!/usr/bin/perl -w
############################## check_snmp_process ##############
my $VERSION = "2.0.0";
# Date : Oct 12 2007
# Author : Patrick Proy (patrick at proy dot org)
# Help : http://nagios.manubulon.com
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : Makina Corpus, adam At greekattic d0t com
# TODO : put $o_delta as an option
# If testing on localhost, selects itself....
###############################################################
#
# help : ./check_snmp_process -h
use strict;
use Net::SNMP;
use Getopt::Long;
############### BASE DIRECTORY FOR TEMP FILE ########
my $o_base_dir = "/tmp/tmp_Icinga_proc.";
my $file_history = 200; # number of data to keep in files.
my $delta_of_time_to_make_average = 300; # 5minutes by default
# Icinga specific
my $TIMEOUT = 15;
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $process_table = '1.3.6.1.2.1.25.4.2.1';
my $index_table = '1.3.6.1.2.1.25.4.2.1.1';
my $run_name_table = '1.3.6.1.2.1.25.4.2.1.2';
my $run_path_table = '1.3.6.1.2.1.25.4.2.1.4';
my $run_param_table = '1.3.6.1.2.1.25.4.2.1.5';
my $proc_mem_table = '1.3.6.1.2.1.25.5.1.1.2'; # Kbytes
my $proc_cpu_table = '1.3.6.1.2.1.25.5.1.1.1'; # Centi sec of CPU
my $proc_run_state = '1.3.6.1.2.1.25.4.2.1.7';
# Globals
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_domain = 'udp/ipv4'; # Default to UDP over IPv4
my $o_version2 = undef; #use snmp v2c
my $o_descr = undef; # description filter
my $o_warn = 0; # warning limit
my @o_warnL = undef; # warning limits (min,max)
my $o_crit = 0; # critical limit
my @o_critL = undef; # critical limits (min,max)
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_noreg = undef; # Do not use Regexp for name
my $o_path = undef; # check path instead of name
my $o_inverse = undef; # checks max instead of min number of process
my $o_get_all = undef; # get all tables at once
my $o_param = undef; # Add process parameters for selection
my $o_perf = undef; # Add performance output
my $o_timeout = 5; # Default 5s Timeout
# SNMP V3 specific
my $o_login = undef; # snmp v3 login
my $o_passwd = undef; # snmp v3 passwd
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# SNMP Message size parameter (Makina Corpus contrib)
my $o_octetlength = undef;
# Memory & CPU
my $o_mem = undef; # checks memory (max)
my @o_memL = undef; # warn and crit level for mem
my $o_mem_avg = undef; # cheks memory average
my $o_cpu = undef; # checks CPU usage
my @o_cpuL = undef; # warn and crit level for cpu
my $o_delta = $delta_of_time_to_make_average; # delta time for CPU check
# functions
sub p_version { print "check_snmp_process version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] [-P <IP Protocol>] -n <name> [-w <min_proc>[,<max_proc>] -c <min_proc>[,max_proc] ] [-m<warn Mb>,<crit Mb> -a -u<warn %>,<crit%> -d<delta> ] [-t <timeout>] [-o <octet_length>] [-f -A -F ] [-r] [-V] [-g]\n";
}
sub isnotnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub read_file {
# Input : File, items_number
# Returns : array of value : [line][item]
my ($traffic_file, $items_number) = @_;
my ($ligne, $n_rows) = (undef, 0);
my (@last_values, @file_values, $i);
open(FILE, "<" . $traffic_file) || return (1, 0, 0);
while ($ligne = <FILE>) {
chomp($ligne);
@file_values = split(":", $ligne);
#verb("@file_values");
if ($#file_values >= ($items_number - 1)) {
# check if there is enough data, else ignore line
for ($i = 0; $i < $items_number; $i++) { $last_values[$n_rows][$i] = $file_values[$i]; }
$n_rows++;
}
}
close FILE;
if ($n_rows != 0) {
return (0, $n_rows, @last_values);
} else {
return (1, 0, 0);
}
}
sub write_file {
# Input : file , rows, items, array of value : [line][item]
# Returns : 0 / OK, 1 / error
my ($file_out, $rows, $item, @file_values) = @_;
my $start_line = ($rows > $file_history) ? $rows - $file_history : 0;
if (open(FILE2, ">" . $file_out)) {
for (my $i = $start_line; $i < $rows; $i++) {
for (my $j = 0; $j < $item; $j++) {
print FILE2 $file_values[$i][$j];
if ($j != ($item - 1)) { print FILE2 ":" }
}
print FILE2 "\n";
}
close FILE2;
return 0;
} else {
return 1;
}
}
sub help {
print "\nSNMP Process Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL license, (c)2004-2006 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information (and lists all storages)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
-l, --login=LOGIN ; -x, --passwd=PASSWD, -2, --v2c
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-2 : use snmp v2c
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-p, --port=PORT
SNMP port (Default 161)
-P, --protocol=PROTOCOL
Network protocol to be used
['udp/ipv4'] : UDP over IPv4
'udp/ipv6' : UDP over IPv6
'tcp/ipv4' : TCP over IPv4
'tcp/ipv6' : TCP over IPv6
-n, --name=NAME
Name of the process (regexp)
No trailing slash !
-r, --noregexp
Do not use regexp to match NAME in description OID
-f, --fullpath
Use full path name instead of process name
(Windows doesn't provide full path name)
-A, --param
Add parameters to select processes.
ex : "named.*-t /var/named/chroot" will only select named process with this parameter
-F, --perfout
Add performance output
outputs : memory_usage, num_process, cpu_usage
-w, --warn=MIN[,MAX]
Number of process that will cause a warning
-1 for no warning, MAX must be >0. Ex : -w-1,50
-c, --critical=MIN[,MAX]
number of process that will cause an error (
-1 for no critical, MAX must be >0. Ex : -c-1,50
Notes on warning and critical :
with the following options : -w m1,x1 -c m2,x2
you must have : m2 <= m1 < x1 <= x2
you can omit x1 or x2 or both
-m, --memory=WARN,CRIT
checks memory usage (default max of all process)
values are warning and critical values in Mb
-a, --average
makes an average of memory used by process instead of max
-u, --cpu=WARN,CRIT
checks cpu usage of all process
values are warning and critical values in % of CPU usage
if more than one CPU, value can be > 100% : 100%=1 CPU
-d, --delta=seconds
make an average of <delta> seconds for CPU (default 300=5min)
-g, --getall
In some cases, it is necessary to get all data at once because
process die very frequently.
This option eats bandwidth an cpu (for remote host) at breakfast.
-o, --octetlength=INTEGER
max-size of the SNMP message, usefull in case of Too Long responses.
Be carefull with network filters. Range 484 - 65535, default are
usually 1472,1452,1460 or 1440.
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
Note :
CPU usage is in % of one cpu, so maximum can be 100% * number of CPU
example :
Browse process list : <script> -C <community> -H <host> -n <anything> -v
the -n option allows regexp in perl format :
All process of /opt/soft/bin : -n /opt/soft/bin/ -f
All 'named' process : -n named
EOT
}
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'P:s' => \$o_domain,
'protocol:s' => \$o_domain,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
'c:s' => \$o_crit,
'critical:s' => \$o_crit,
'w:s' => \$o_warn,
'warn:s' => \$o_warn,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'n:s' => \$o_descr,
'name:s' => \$o_descr,
'r' => \$o_noreg,
'noregexp' => \$o_noreg,
'f' => \$o_path,
'fullpath' => \$o_path,
'm:s' => \$o_mem,
'memory:s' => \$o_mem,
'a' => \$o_mem_avg,
'average' => \$o_mem_avg,
'u:s' => \$o_cpu,
'cpu' => \$o_cpu,
'2' => \$o_version2,
'v2c' => \$o_version2,
'o:i' => \$o_octetlength,
'octetlength:i' => \$o_octetlength,
'g' => \$o_get_all,
'getall' => \$o_get_all,
'A' => \$o_param,
'param' => \$o_param,
'F' => \$o_perf,
'perfout' => \$o_perf,
'd:i' => \$o_delta,
'delta:i' => \$o_delta,
'V' => \$o_version,
'version' => \$o_version
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
if (defined($o_timeout) && (isnotnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) {
print "Timeout must be >1 and <60 !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_timeout)) { $o_timeout = 5; }
# Check compulsory attributes
if (!defined($o_descr) || !defined($o_host)) { print_usage(); exit $ERRORS{"UNKNOWN"} }
@o_warnL = split(/,/, $o_warn);
@o_critL = split(/,/, $o_crit);
verb("$o_warn $o_crit $#o_warnL $#o_critL");
if (isnotnum($o_warnL[0]) || isnotnum($o_critL[0])) {
print "Numerical values for warning and critical\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_warnL[1]) && isnotnum($o_warnL[1])) || (defined($o_critL[1]) && isnotnum($o_critL[1]))) {
print "Numerical values for warning and critical\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Check for positive numbers on maximum number of processes
if ((defined($o_warnL[1]) && ($o_warnL[1] < 0)) || (defined($o_critL[1]) && ($o_critL[1] < 0))) {
print " Maximum process warn and critical > 0 \n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Check min_crit < min warn < max warn < crit warn
if ($o_warnL[0] < $o_critL[0]) {
print " warn minimum must be >= crit minimum\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_warnL[1])) {
if ($o_warnL[1] <= $o_warnL[0]) {
print "warn minimum must be < warn maximum\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
} elsif (defined($o_critL[1]) && ($o_critL[1] <= $o_warnL[0])) {
print "warn minimum must be < crit maximum when no crit warning defined\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_critL[1]) && defined($o_warnL[1]) && ($o_critL[1] < $o_warnL[1])) {
print "warn max must be <= crit maximum\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
#### Memory checks
if (defined($o_mem)) {
@o_memL = split(/,/, $o_mem);
if ($#o_memL != 1) { print "2 values (warning,critical) for memory\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if (isnotnum($o_memL[0]) || isnotnum($o_memL[1])) {
print "Numeric values for memory!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_memL[0] > $o_memL[1]) {
print "Warning must be <= Critical for memory!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
#### CPU checks
if (defined($o_cpu)) {
@o_cpuL = split(/,/, $o_cpu);
if ($#o_cpuL != 1) { print "2 values (warning,critical) for cpu\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if (isnotnum($o_cpuL[0]) || isnotnum($o_cpuL[1])) {
print "Numeric values for cpu!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ($o_cpuL[0] > $o_cpuL[1]) {
print "Warning must be <= Critical for cpu!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
#### octet length checks
if (defined($o_octetlength) && (isnotnum($o_octetlength) || $o_octetlength > 65535 || $o_octetlength < 484)) {
print "octet lenght must be < 65535 and > 484\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-port => $o_port,
-domain => $o_domain,
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-port => $o_port,
-domain => $o_domain,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-domain => $o_domain,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-domain => $o_domain,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_octetlength)) {
my $oct_resultat = undef;
my $oct_test = $session->max_msg_size();
verb(" actual max octets:: $oct_test");
$oct_resultat = $session->max_msg_size($o_octetlength);
if (!defined($oct_resultat)) {
printf("ERROR: Session settings : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$oct_test = $session->max_msg_size();
verb(" new max octets:: $oct_test");
}
# Look for process in name or path name table
my $resultat = undef;
my %result_cons = ();
my ($getall_run, $getall_cpu, $getall_mem) = (undef, undef, undef);
if (!defined($o_path)) {
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($run_name_table)
: $session->get_table(Baseoid => $run_name_table);
} else {
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($run_path_table)
: $session->get_table(Baseoid => $run_path_table);
}
if (!defined($resultat)) {
printf("ERROR: Process name table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my $resultat_param = undef;
if (defined($o_param)) { # Get parameter table too
$resultat_param
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($run_param_table)
: $session->get_table(Baseoid => $run_param_table);
if (!defined($resultat_param)) {
printf("ERROR: Process param table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
}
if (defined($o_get_all)) {
$getall_run
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($proc_run_state)
: $session->get_table(Baseoid => $proc_run_state);
if (!defined($getall_run)) {
printf("ERROR: Process run table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
foreach my $key (keys %$getall_run) {
$result_cons{$key} = $$getall_run{$key};
}
$getall_cpu
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($proc_cpu_table)
: $session->get_table(Baseoid => $proc_cpu_table);
if (!defined($getall_cpu)) {
printf("ERROR: Process cpu table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
foreach my $key (keys %$getall_cpu) {
$result_cons{$key} = $$getall_cpu{$key};
}
$getall_mem
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($proc_mem_table)
: $session->get_table(Baseoid => $proc_mem_table);
if (!defined($getall_mem)) {
printf("ERROR: Process memory table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
foreach my $key (keys %$getall_mem) {
$result_cons{$key} = $$getall_mem{$key};
}
}
my @tindex = undef;
my @oids = undef;
my @descr = undef;
my $num_int = 0;
my $count_oid = 0;
# Select storage by regexp of exact match
# and put the oid to query in an array
verb("Filter : $o_descr");
foreach my $key (keys %$resultat) {
# test by regexp or exact match
# First add param if necessary
if (defined($o_param)) {
my $pid = (split /\./, $key)[-1];
$pid = $run_param_table . "." . $pid;
$$resultat{$key} .= " " . $$resultat_param{$pid};
}
verb("OID : $key, Desc : $$resultat{$key}");
my $test
= defined($o_noreg)
? $$resultat{$key} eq $o_descr
: $$resultat{$key} =~ /$o_descr/;
if ($test) {
# get the index number of the interface
my @oid_list = split(/\./, $key);
$tindex[$num_int] = pop(@oid_list);
# get the full description
$descr[$num_int] = $$resultat{$key};
# put the oid of running and mem (check this maybe ?) in an array.
$oids[$count_oid++] = $proc_mem_table . "." . $tindex[$num_int];
$oids[$count_oid++] = $proc_cpu_table . "." . $tindex[$num_int];
$oids[$count_oid++] = $proc_run_state . "." . $tindex[$num_int];
#verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
verb($oids[$count_oid - 1]);
$num_int++;
}
}
if ($num_int == 0) {
print "No process ", (defined($o_noreg)) ? "named " : "matching ", $o_descr, " found : ";
if ($o_critL[0] >= 0) {
print "CRITICAL\n";
exit $ERRORS{"CRITICAL"};
} elsif ($o_warnL[0] >= 0) {
print "WARNING\n";
exit $ERRORS{"WARNING"};
}
print "YOU told me it was : OK\n";
exit $ERRORS{"OK"};
}
my $result = undef;
my $num_int_ok = 0;
# Splitting snmp request because can't use get_bulk_request with v1 protocol
if (!defined($o_get_all)) {
if ($count_oid >= 50) {
my @toid = undef;
my $tmp_num = 0;
my $tmp_index = 0;
my $tmp_count = $count_oid;
my $tmp_result = undef;
verb("More than 50 oid, splitting");
while ($tmp_count != 0) {
$tmp_num = ($tmp_count >= 50) ? 50 : $tmp_count;
for (my $i = 0; $i < $tmp_num; $i++) {
$toid[$i] = $oids[$i + $tmp_index];
#verb("$i : $toid[$i] : $oids[$i+$tmp_index]");
}
$tmp_result
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@toid)
: $session->get_request(Varbindlist => \@toid);
if (!defined($tmp_result)) {
printf("ERROR: running table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
foreach (@toid) { $result_cons{$_} = $$tmp_result{$_}; }
$tmp_count -= $tmp_num;
$tmp_index += $tmp_num;
}
} else {
$result
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oids)
: $session->get_request(Varbindlist => \@oids);
if (!defined($result)) {
printf("ERROR: running table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
foreach (@oids) { $result_cons{$_} = $$result{$_}; }
}
}
$session->close;
#Check if process are in running or runnable state
for (my $i = 0; $i < $num_int; $i++) {
my $state = $result_cons{ $proc_run_state . "." . $tindex[$i] };
my $tmpmem = $result_cons{ $proc_mem_table . "." . $tindex[$i] };
my $tmpcpu = $result_cons{ $proc_cpu_table . "." . $tindex[$i] };
verb("Process $tindex[$i] in state $state using $tmpmem, and $tmpcpu CPU");
if (!isnotnum($state)) { # check argument is numeric (can be NoSuchInstance)
$num_int_ok++ if (($state == 1) || ($state == 2));
}
}
my $final_status = 0;
my $perf_output;
my ($res_memory, $res_cpu) = (0, 0);
my $memory_print = "";
my $cpu_print = "";
###### Checks memory usage
if (defined($o_mem)) {
if (defined($o_mem_avg)) {
for (my $i = 0; $i < $num_int; $i++) { $res_memory += $result_cons{ $proc_mem_table . "." . $tindex[$i] }; }
$res_memory /= ($num_int_ok * 1024);
verb("Memory average : $res_memory");
} else {
for (my $i = 0; $i < $num_int; $i++) {
$res_memory
= ($result_cons{ $proc_mem_table . "." . $tindex[$i] } > $res_memory)
? $result_cons{ $proc_mem_table . "." . $tindex[$i] }
: $res_memory;
}
$res_memory /= 1024;
verb("Memory max : $res_memory");
}
if ($res_memory > $o_memL[1]) {
$final_status = 2;
$memory_print = ", Mem : " . sprintf("%.1f", $res_memory) . "Mb > " . $o_memL[1] . " CRITICAL";
} elsif ($res_memory > $o_memL[0]) {
$final_status = 1;
$memory_print = ", Mem : " . sprintf("%.1f", $res_memory) . "Mb > " . $o_memL[0] . " WARNING";
} else {
$memory_print = ", Mem : " . sprintf("%.1f", $res_memory) . "Mb OK";
}
if (defined($o_perf)) {
$perf_output = "'memory_usage'=" . sprintf("%.1f", $res_memory) . "MB;" . $o_memL[0] . ";" . $o_memL[1];
}
}
######## Checks CPU usage
if (defined($o_cpu)) {
my $timenow = time;
my $temp_file_name;
my ($return, @file_values) = (undef, undef);
my $n_rows = 0;
my $n_items_check = 2;
my $trigger = $timenow - ($o_delta - ($o_delta / 10));
my $trigger_low = $timenow - 3 * $o_delta;
my ($old_value, $old_time) = undef;
my $found_value = undef;
#### Get the current values
for (my $i = 0; $i < $num_int; $i++) { $res_cpu += $result_cons{ $proc_cpu_table . "." . $tindex[$i] }; }
verb("Time: $timenow , cpu (centiseconds) : $res_cpu");
#### Read file
$temp_file_name = $o_descr;
$temp_file_name =~ s/ /_/g;
$temp_file_name =~ s/\//_/g;
$temp_file_name =~ s/-//g;
$temp_file_name =~ s/=//g;
$temp_file_name = substr($temp_file_name, 0, 40);
$temp_file_name = $o_base_dir . $o_host . "." . $temp_file_name;
# First, read entire file
my @ret_array = read_file($temp_file_name, $n_items_check);
$return = shift(@ret_array);
$n_rows = shift(@ret_array);
if ($n_rows != 0) { @file_values = @ret_array }
verb("File read returns : $return with $n_rows rows");
#make the checks if the file is OK
if ($return == 0) {
my $j = $n_rows - 1;
do {
if ($file_values[$j][0] < $trigger) {
if ($file_values[$j][0] > $trigger_low) {
# found value = centiseconds / seconds = %cpu
$found_value = ($res_cpu - $file_values[$j][1]) / ($timenow - $file_values[$j][0]);
if ($found_value < 0) { # in case of program restart
$j = 0;
$found_value = undef; # don't look for more values
$n_rows = 0; # reset file
}
}
}
$j--;
} while (($j >= 0) && (!defined($found_value)));
}
###### Write file
$file_values[$n_rows][0] = $timenow;
$file_values[$n_rows][1] = $res_cpu;
$n_rows++;
$return = write_file($temp_file_name, $n_rows, $n_items_check, @file_values);
if ($return != 0) { $cpu_print .= "! ERROR writing file $temp_file_name !"; $final_status = 3; }
##### Check values (if something to check...)
if (defined($found_value)) {
if ($found_value > $o_cpuL[1]) {
$final_status = 2;
$cpu_print .= ", Cpu : " . sprintf("%.0f", $found_value) . "% > " . $o_cpuL[1] . " CRITICAL";
} elsif ($found_value > $o_cpuL[0]) {
$final_status = ($final_status == 2) ? 2 : 1;
$cpu_print .= ", Cpu : " . sprintf("%.0f", $found_value) . "% > " . $o_cpuL[0] . " WARNING";
} else {
$cpu_print .= ", Cpu : " . sprintf("%.0f", $found_value) . "% OK";
}
if (defined($o_perf)) {
if (!defined($perf_output)) { $perf_output = ""; }
else { $perf_output .= " "; }
$perf_output .= "'cpu_usage'=" . sprintf("%.0f", $found_value) . "%;" . $o_cpuL[0] . ";" . $o_cpuL[1];
}
} else {
if ($final_status == 0) { $final_status = 3 }
$cpu_print .= ", No data for CPU (" . $n_rows . " line(s)):UNKNOWN";
}
}
print $num_int_ok, " process ", (defined($o_noreg)) ? "named " : "matching ", $o_descr, " ";
#### Check for min and max number of process
if ($num_int_ok <= $o_critL[0]) {
print "(<= ", $o_critL[0], " : CRITICAL)";
$final_status = 2;
} elsif ($num_int_ok <= $o_warnL[0]) {
print "(<= ", $o_warnL[0], " : WARNING)";
$final_status = ($final_status == 2) ? 2 : 1;
} else {
print "(> ", $o_warnL[0], ")";
}
if (defined($o_critL[1]) && ($num_int_ok > $o_critL[1])) {
print " (> ", $o_critL[1], " : CRITICAL)";
$final_status = 2;
} elsif (defined($o_warnL[1]) && ($num_int_ok > $o_warnL[1])) {
print " (> ", $o_warnL[1], " : WARNING)";
$final_status = ($final_status == 2) ? 2 : 1;
} elsif (defined($o_warnL[1])) {
print " (<= ", $o_warnL[1], "):OK";
}
print $memory_print, $cpu_print;
if (defined($o_perf)) {
if (!defined($perf_output)) { $perf_output = ""; }
else { $perf_output .= " "; }
$perf_output .= "'num_process'=" . $num_int_ok . ";" . $o_warnL[0] . ";" . $o_critL[0];
print " | ", $perf_output;
}
print "\n";
if ($final_status == 2) { exit $ERRORS{"CRITICAL"}; }
if ($final_status == 1) { exit $ERRORS{"WARNING"}; }
if ($final_status == 3) { exit $ERRORS{"UNKNOWN"}; }
exit $ERRORS{"OK"};

810
plugins/check_snmp_storage.pl Executable file
View file

@ -0,0 +1,810 @@
#!/usr/bin/perl -w
############################## check_snmp_storage ##############
# Version : 1.3.3
# Date : Jun 1 2007
# Author : Patrick Proy ( patrick at proy.org)
# Help : http://nagios.manubulon.com
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# TODO :
# Contribs : Dimo Velev, Makina Corpus, A. Greiner-B\ufffdr
#################################################################
#
# help : ./check_snmp_storage -h
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
my $storage_table = '1.3.6.1.2.1.25.2.3.1';
my $storagetype_table = '1.3.6.1.2.1.25.2.3.1.2';
my $index_table = '1.3.6.1.2.1.25.2.3.1.1';
my $descr_table = '1.3.6.1.2.1.25.2.3.1.3';
my $size_table = '1.3.6.1.2.1.25.2.3.1.5.';
my $used_table = '1.3.6.1.2.1.25.2.3.1.6.';
my $alloc_units = '1.3.6.1.2.1.25.2.3.1.4.';
#Storage types definition - from /usr/share/snmp/mibs/HOST-RESOURCES-TYPES.txt
my %hrStorage;
$hrStorage{"Other"} = '1.3.6.1.2.1.25.2.1.1';
$hrStorage{"1.3.6.1.2.1.25.2.1.1"} = 'Other';
$hrStorage{"Ram"} = '1.3.6.1.2.1.25.2.1.2';
$hrStorage{"1.3.6.1.2.1.25.2.1.2"} = 'Ram';
$hrStorage{"VirtualMemory"} = '1.3.6.1.2.1.25.2.1.3';
$hrStorage{"1.3.6.1.2.1.25.2.1.3"} = 'VirtualMemory';
$hrStorage{"FixedDisk"} = '1.3.6.1.2.1.25.2.1.4';
$hrStorage{"1.3.6.1.2.1.25.2.1.4"} = 'FixedDisk';
$hrStorage{"RemovableDisk"} = '1.3.6.1.2.1.25.2.1.5';
$hrStorage{"1.3.6.1.2.1.25.2.1.5"} = 'RemovableDisk';
$hrStorage{"FloppyDisk"} = '1.3.6.1.2.1.25.2.1.6';
$hrStorage{"1.3.6.1.2.1.25.2.1.6"} = 'FloppyDisk';
$hrStorage{"CompactDisk"} = '1.3.6.1.2.1.25.2.1.7';
$hrStorage{"1.3.6.1.2.1.25.2.1.7"} = 'CompactDisk';
$hrStorage{"RamDisk"} = '1.3.6.1.2.1.25.2.1.8';
$hrStorage{"1.3.6.1.2.1.25.2.1.8"} = 'RamDisk';
$hrStorage{"FlashMemory"} = '1.3.6.1.2.1.25.2.1.9';
$hrStorage{"1.3.6.1.2.1.25.2.1.9"} = 'FlashMemory';
$hrStorage{"NetworkDisk"} = '1.3.6.1.2.1.25.2.1.10';
$hrStorage{"1.3.6.1.2.1.25.2.1.10"} = 'NetworkDisk';
# Globals
my $Name = 'check_snmp_storage';
my $VERSION = "2.0.0";
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_domain = 'udp/ipv4'; # Default to UDP over IPv4
my $o_version2 = undef; #use snmp v2c
my $o_descr = undef; # description filter
my $o_storagetype = undef; # parse storage type also
my $o_warn = undef; # warning limit
my $o_crit = undef; # critical limit
my $o_help = undef; # wan't some help ?
my $o_type = undef; # pl, pu, mbl, mbu
my @o_typeok = ("pu", "pl", "bu", "bl"); # valid values for o_type
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_noreg = undef; # Do not use Regexp for name
my $o_sum = undef; # add all storage before testing
my $o_index = undef; # Parse index instead of description
my $o_negate = undef; # Negate the regexp if set
my $o_timeout = 5; # Default 5s Timeout
my $o_perf = undef; # Output performance data
my $o_short = undef; # Short output parameters
my @o_shortL = undef; # output type,where,cut
my $o_reserve = 0; # % reserved blocks (A. Greiner-B\ufffdr patch)
my $o_giga = undef; # output and levels in gigabytes instead of megabytes
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
my $UOM_float = 4; # decimal places
# SNMP Message size parameter (Makina Corpus contrib)
my $o_octetlength = undef;
# functions
sub p_version { print "$Name version : $VERSION\n"; }
sub print_usage {
print
"Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] [-P <protocol>] -m <name in desc_oid> [-q storagetype] -w <warn_level> -c <crit_level> [-t <timeout>] [-T pl|pu|bl|bu ] [-r -s -i -G] [-e] [-S 0|1[,1,<car>]] [-o <octet_length>] [-R <% reserved>]\n";
}
sub round ($$) {
sprintf "%.$_[1]f", $_[0];
}
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
my $pat = shift;
if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings
return eval { "" =~ /$pat/; 1 } || 0;
}
# Get the alarm signal (just in case snmp timout screws up)
$SIG{'ALRM'} = sub {
# print ("ERROR: General time-out (Alarm signal)\n");
# exit $ERRORS{"UNKNOWN"};
print("Waiting for info\n");
exit $ERRORS{"OK"};
};
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub help {
print "\nSNMP Disk Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "(c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
By default, plugin will monitor %used on drives :
warn if %used > warn and critical if %used > crit
-v, --verbose
print extra debugging information (and lists all storages)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-x, --passwd=PASSWD
Password for snmpv3 authentication
-p, --port=PORT
SNMP port (Default 161)
-P, --protocol=PROTOCOL
Network protocol to be used
['udp/ipv4'] : UDP over IPv4
'udp/ipv6' : UDP over IPv6
'tcp/ipv4' : TCP over IPv4
'tcp/ipv6' : TCP over IPv6
-m, --name=NAME
Name in description OID (can be mounpoints '/home' or 'Swap Space'...)
This is treated as a regexp : -m /var will match /var , /var/log, /opt/var ...
Test it before, because there are known bugs (ex : trailling /)
No trailing slash for mountpoints !
-q, --storagetype=[Other|Ram|VirtualMemory|FixedDisk|RemovableDisk|FloppyDisk
CompactDisk|RamDisk|FlashMemory|NetworkDisk]
Also check the storage type in addition of the name
It is possible to use regular expressions ( "FixedDisk|FloppyDisk" )
-r, --noregexp
Do not use regexp to match NAME in description OID
-s, --sum
Add all storages that match NAME (used space and total space)
THEN make the tests.
-i, --index
Parse index table instead of description table to select storage
-e, --exclude
Select all storages except the one(s) selected by -m
No action on storage type selection
-T, --type=TYPE
pl : calculate percent left
pu : calculate percent used (Default)
bl : calculate MegaBytes left
bu : calculate MegaBytes used
-w, --warn=INTEGER
percent / MB of disk used to generate WARNING state
you can add the % sign
-c, --critical=INTEGER
percent / MB of disk used to generate CRITICAL state
you can add the % sign
-R, --reserved=INTEGER
% reserved blocks for superuser
For ext2/3 filesystems, it is 5% by default
-G, --gigabyte
output, warning & critical levels in gigabytes
-f, --perfparse, --perfdata
Performance data output
-S, --short=<type>[,<where>,<cut>]
<type>: Make the output shorter :
0 : only print the global result except the disk in warning or critical
ex: "< 80% : OK"
1 : Don't print all info for every disk
ex : "/ : 66 %used (< 80) : OK"
<where>: (optional) if = 1, put the OK/WARN/CRIT at the beginning
<cut>: take the <n> first caracters or <n> last if n<0
-o, --octetlength=INTEGER
max-size of the SNMP message, usefull in case of Too Long responses.
Be carefull with network filters. Range 484 - 65535, default are
usually 1472,1452,1460 or 1440.
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
Note :
with T=pu or T=bu : OK < warn < crit
with T=pl ot T=bl : crit < warn < OK
If multiple storage are selected, the worse condition will be returned
i.e if one disk is critical, the return is critical
example :
Browse storage list : <script> -C <community> -H <host> -m <anything> -w 1 -c 2 -v
the -m option allows regexp in perl format :
Test drive C,F,G,H,I on Windows : -m ^[CFGHI]:
Test all mounts containing /var : -m /var
Test all mounts under /var : -m ^/var
Test only /var : -m /var -r
Test all swap spaces : -m ^Swap
Test all but swap spaces : -m ^Swap -e
EOT
}
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'P:s' => \$o_domain,
'protocol:s' => \$o_domain,
'C:s' => \$o_community,
'community:s' => \$o_community,
'2' => \$o_version2,
'v2c' => \$o_version2,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
'c:s' => \$o_crit,
'critical:s' => \$o_crit,
'w:s' => \$o_warn,
'warn:s' => \$o_warn,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'm:s' => \$o_descr,
'name:s' => \$o_descr,
'T:s' => \$o_type,
'type:s' => \$o_type,
'r' => \$o_noreg,
'noregexp' => \$o_noreg,
's' => \$o_sum,
'sum' => \$o_sum,
'i' => \$o_index,
'index' => \$o_index,
'e' => \$o_negate,
'exclude' => \$o_negate,
'V' => \$o_version,
'version' => \$o_version,
'q:s' => \$o_storagetype,
'storagetype:s' => \$o_storagetype,
'S:s' => \$o_short,
'short:s' => \$o_short,
'o:i' => \$o_octetlength,
'octetlength:i' => \$o_octetlength,
'f' => \$o_perf,
'perfparse' => \$o_perf,
'perfdata' => \$o_perf,
'R:i' => \$o_reserve,
'reserved:i' => \$o_reserve,
'G' => \$o_giga,
'gigabyte' => \$o_giga
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
# check mount point regexp
if (!is_pattern_valid($o_descr)) { print "Bad pattern for mount point !\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check types
if (!defined($o_type)) { $o_type = "pu"; }
if (!grep(/^$o_type$/, @o_typeok)) { print_usage(); exit $ERRORS{"UNKNOWN"} }
# Check compulsory attributes
if ( !defined($o_descr)
|| !defined($o_host)
|| !defined($o_warn)
|| !defined($o_crit))
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Get rid of % sign if any
$o_warn =~ s/\%//;
$o_crit =~ s/\%//;
# Check for positive numbers
if (($o_warn < 0) || ($o_crit < 0)) { print " warn and critical > 0 \n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
# check if warn or crit in % and MB is tested
if ((($o_warn =~ /%/) || ($o_crit =~ /%/)) && (($o_type eq 'bu') || ($o_type eq 'bl'))) {
print "warning or critical cannot be in % when MB are tested\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Check warning and critical values
if (($o_type eq 'pu') || ($o_type eq 'bu')) {
if ($o_warn >= $o_crit) { print " warn < crit if type=", $o_type, "\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
if (($o_type eq 'pl') || ($o_type eq 'bl')) {
if ($o_warn <= $o_crit) { print " warn > crit if type=", $o_type, "\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
if (($o_warn < 0) || ($o_crit < 0)) { print "warn and crit must be > 0\n"; print_usage(); exit $ERRORS{"UNKNOWN"} }
if (($o_type eq 'pl') || ($o_type eq 'pu')) {
if (($o_warn > 100) || ($o_crit > 100)) {
print "percent must be < 100\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check short values
if (defined($o_short)) {
@o_shortL = split(/,/, $o_short);
if ((isnnum($o_shortL[0])) || ($o_shortL[0] != 0) && ($o_shortL[0] != 1)) {
print "-S first option must be 0 or 1\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_shortL[1]) && $o_shortL[1] eq "") { $o_shortL[1] = undef }
if (defined($o_shortL[2]) && isnnum($o_shortL[2])) {
print "-S last option must be an integer\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
#### octet length checks
if (defined($o_octetlength) && (isnnum($o_octetlength) || $o_octetlength > 65535 || $o_octetlength < 484)) {
print "octet lenght must be < 65535 and > 484\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
#### reserved blocks checks (A. Greiner-B\ufffdr patch).
if (defined($o_reserve) && (isnnum($o_reserve) || $o_reserve > 99 || $o_reserve < 0)) {
print "reserved blocks must be < 100 and >= 0\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-port => $o_port,
-retries => 10,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-port => $o_port,
-retries => 10,
-timeout => $o_timeout,
-domain => $o_domain
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-retries => 10,
-timeout => $o_timeout,
-domain => $o_domain
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-retries => 10,
-timeout => $o_timeout,
-domain => $o_domain
);
}
}
if (!defined($session)) {
printf("ERROR: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
if (defined($o_octetlength)) {
my $oct_resultat = undef;
my $oct_test = $session->max_msg_size();
verb(" actual max octets:: $oct_test");
$oct_resultat = $session->max_msg_size($o_octetlength);
if (!defined($oct_resultat)) {
printf("ERROR: Session settings : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$oct_test = $session->max_msg_size();
verb(" new max octets:: $oct_test");
}
my $resultat = undef;
my $stype = undef;
# Get rid of UTF8 translation in case of accentuated caracters (thanks to Dimo Velev).
$session->translate(Net::SNMP->TRANSLATE_NONE);
if (defined($o_index)) {
if (version->parse(Net::SNMP->VERSION) < 4) {
$resultat = $session->get_table($index_table);
} else {
$resultat = $session->get_table(Baseoid => $index_table);
}
} else {
if (version->parse(Net::SNMP->VERSION) < 4) {
$resultat = $session->get_table($descr_table);
} else {
$resultat = $session->get_table(Baseoid => $descr_table);
}
}
#get storage typetable for reference
if (defined($o_storagetype)) {
if (version->parse(Net::SNMP->VERSION) < 4) {
$stype = $session->get_table($storagetype_table);
} else {
$stype = $session->get_table(Baseoid => $storagetype_table);
}
}
if (!defined($resultat) | (!defined($stype) && defined($o_storagetype))) {
printf("ERROR: Description/Type table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my @tindex = undef;
my @oids = undef;
my @descr = undef;
my $num_int = 0;
my $count_oid = 0;
my $test = undef;
my $perf_out = undef;
# Select storage by regexp of exact match
# and put the oid to query in an array
verb("Filter : $o_descr");
foreach my $key (sort { $$resultat{$a} cmp $$resultat{$b} } keys %$resultat) {
verb("OID : $key, Desc : $$resultat{$key}");
# test by regexp or exact match / include or exclude
if (defined($o_negate)) {
$test
= defined($o_noreg)
? $$resultat{$key} ne $o_descr
: $$resultat{$key} !~ /$o_descr/;
} else {
$test
= defined($o_noreg)
? $$resultat{$key} eq $o_descr
: $$resultat{$key} =~ /$o_descr/;
}
if ($test) {
# get the index number of the interface
my @oid_list = split(/\./, $key);
$tindex[$num_int] = pop(@oid_list);
# Check if storage type is OK
if (defined($o_storagetype)) {
my ($skey) = $storagetype_table . "." . $tindex[$num_int];
verb(" OID : $skey, Storagetype: $hrStorage{$$stype{$skey}} ?= $o_storagetype");
if ($hrStorage{ $$stype{$skey} } !~ $o_storagetype) {
$test = undef;
}
}
if ($test) {
# get the full description
$descr[$num_int] = $$resultat{$key};
# put the oid in an array
$oids[$count_oid++] = $size_table . $tindex[$num_int];
$oids[$count_oid++] = $used_table . $tindex[$num_int];
$oids[$count_oid++] = $alloc_units . $tindex[$num_int];
verb(" Name : $descr[$num_int], Index : $tindex[$num_int]");
$num_int++;
}
}
}
verb("storages selected : $num_int");
if ($num_int == 0) { print "Unknown storage : $o_descr : ERROR\n"; exit $ERRORS{"UNKNOWN"}; }
my $result = undef;
if (version->parse(Net::SNMP->VERSION) < 4) {
$result = $session->get_request(@oids);
} else {
$result = $session->get_request(Varbindlist => \@oids);
foreach my $key (sort keys %$result) {
# Fix for filesystems larger 2 TB. More than 2 TB will cause an error because
# as defined in the RFC hrStorageSize is a 32 bit integer. So filesystems
# larger 2 TB report a negative value because the first bit will be interpreted
# as an algebraic sign. (0 = +, all others will be -). You simply have to add
# 2 to the power of 32 (4294967296) and it is fixed.
# Martin Fuerstenau, Oce Printing Systems, 25th Sept 2012
if ($$result{$key} < 0) {
$$result{$key} = $$result{$key} + 4294967296;
}
verb("$key x $$result{$key}");
}
}
if (!defined($result)) {
printf("ERROR: Size table :%s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
# Only a few ms left...
alarm(0);
# Sum everything if -s and more than one storage
if (defined($o_sum) && ($num_int > 1)) {
verb("Adding all entries");
$$result{ $size_table . $tindex[0] } *= $$result{ $alloc_units . $tindex[0] };
$$result{ $used_table . $tindex[0] } *= $$result{ $alloc_units . $tindex[0] };
$$result{ $alloc_units . $tindex[0] } = 1;
for (my $i = 1; $i < $num_int; $i++) {
$$result{ $size_table . $tindex[0] }
+= ($$result{ $size_table . $tindex[$i] } * $$result{ $alloc_units . $tindex[$i] });
$$result{ $used_table . $tindex[0] }
+= ($$result{ $used_table . $tindex[$i] } * $$result{ $alloc_units . $tindex[$i] });
}
$num_int = 1;
$descr[0] = "Sum of all $o_descr";
}
my $i = undef;
my $warn_state = 0;
my $crit_state = 0;
my ($p_warn, $p_crit);
my $output = undef;
my $output_metric_val = 1024**2;
my $output_metric = "M";
# Set the metric
if (defined($o_giga)) {
$output_metric_val *= 1024;
$output_metric = 'G';
}
for ($i = 0; $i < $num_int; $i++) {
verb("Descr : $descr[$i]");
verb("Size : $$result{$size_table . $tindex[$i]}");
verb("Used : $$result{$used_table . $tindex[$i]}");
verb("Alloc : $$result{$alloc_units . $tindex[$i]}");
if ( !defined($$result{ $size_table . $tindex[$i] })
|| !defined($$result{ $used_table . $tindex[$i] })
|| !defined($$result{ $alloc_units . $tindex[$i] }))
{
print "Data not fully defined for storage ", $descr[$i], " : UNKNOWN\n";
exit $ERRORS{"UNKNOWN"};
}
my $to
= $$result{ $size_table . $tindex[$i] }
* ((100 - $o_reserve) / 100)
* $$result{ $alloc_units . $tindex[$i] }
/ $output_metric_val;
my $pu = undef;
if ($$result{ $used_table . $tindex[$i] } != 0) {
$pu = $$result{ $used_table . $tindex[$i] } * 100
/ ($$result{ $size_table . $tindex[$i] } * (100 - $o_reserve) / 100);
} else {
$pu = 0;
}
my $bu = $$result{ $used_table . $tindex[$i] } * $$result{ $alloc_units . $tindex[$i] } / $output_metric_val;
my $pl = 100 - $pu;
my $bl
= (
($$result{ $size_table . $tindex[$i] } * ((100 - $o_reserve) / 100) - ($$result{ $used_table . $tindex[$i] }))
* $$result{ $alloc_units . $tindex[$i] }
/ $output_metric_val);
# add a ' ' if some data exists in $perf_out
$perf_out .= " " if (defined($perf_out));
##### Ouputs and checks
# Keep complete description fot performance output (in MB)
my $Pdescr = $descr[$i];
$Pdescr =~ s/[`~!\$%\^&\*'"<>|\?,\(= )]/_/g;
##### TODO : subs "," with something
if (defined($o_shortL[2])) {
if ($o_shortL[2] < 0) { $descr[$i] = substr($descr[$i], $o_shortL[2]); }
else { $descr[$i] = substr($descr[$i], 0, $o_shortL[2]); }
}
if ($o_type eq "pu") { # Checks % used
my $locstate = 0;
$p_warn = $o_warn * $to / 100;
$p_crit = $o_crit * $to / 100;
(($pu >= $o_crit) && ($locstate = $crit_state = 1))
|| (($pu >= $o_warn) && ($locstate = $warn_state = 1));
if (defined($o_shortL[2])) { }
if (!defined($o_shortL[0]) || ($locstate == 1)) { # print full output if warn or critical state
$output .= sprintf("%s: %.0f%%used(%.0f%sB/%.0f%sB) ", $descr[$i], $pu, $bu, $output_metric, $to,
$output_metric);
} elsif ($o_shortL[0] == 1) {
$output .= sprintf("%s: %.0f%% ", $descr[$i], $pu);
}
}
if ($o_type eq 'bu') { # Checks MBytes used
my $locstate = 0;
$p_warn = $o_warn;
$p_crit = $o_crit;
(($bu >= $o_crit) && ($locstate = $crit_state = 1))
|| (($bu >= $o_warn) && ($locstate = $warn_state = 1));
if (!defined($o_shortL[0]) || ($locstate == 1)) { # print full output if warn or critical state
$output
.= sprintf("%s: %.0f%sBused/%.0f%sB (%.0f%%) ", $descr[$i], $bu, $output_metric, $to, $output_metric,
$pu);
} elsif ($o_shortL[0] == 1) {
$output .= sprintf("%s: %.0f%sB ", $descr[$i], $bu, $output_metric);
}
}
if ($o_type eq 'bl') {
my $locstate = 0;
$p_warn = $to - $o_warn;
$p_crit = $to - $o_crit;
(($bl <= $o_crit) && ($locstate = $crit_state = 1))
|| (($bl <= $o_warn) && ($locstate = $warn_state = 1));
if (!defined($o_shortL[0]) || ($locstate == 1)) { # print full output if warn or critical state
$output
.= sprintf("%s: %.0f%sBleft/%.0f%sB (%.0f%%) ", $descr[$i], $bl, $output_metric, $to, $output_metric,
$pl);
} elsif ($o_shortL[0] == 1) {
$output .= sprintf("%s: %.0f%sB ", $descr[$i], $bl, $output_metric);
}
}
if ($o_type eq 'pl') {
my $locstate = 0;
$p_warn = (100 - $o_warn) * $to / 100;
$p_crit = (100 - $o_crit) * $to / 100;
(($pl <= $o_crit) && ($locstate = $crit_state = 1))
|| (($pl <= $o_warn) && ($locstate = $warn_state = 1));
if (!defined($o_shortL[0]) || ($locstate == 1)) { # print full output if warn or critical state
$output .= sprintf("%s: %.0f%%left(%.0f%sB/%.0f%sB) ", $descr[$i], $pl, $bl, $output_metric, $to,
$output_metric);
} elsif ($o_shortL[0] == 1) {
$output .= sprintf("%s: %.0f%% ", $descr[$i], $pl);
}
}
# Performance output (in MB)
$perf_out
.= "'"
. $Pdescr . "'="
. round($bu, $UOM_float)
. $output_metric . "B;"
. round($p_warn, 0) . ";"
. round($p_crit, 0) . ";0;"
. round($to, 0);
}
verb("Perf data : $perf_out");
my $comp_oper = undef;
my $comp_unit = undef;
($o_type eq "pu") && ($comp_oper = "<") && ($comp_unit = "%");
($o_type eq "pl") && ($comp_oper = ">") && ($comp_unit = "%");
($o_type eq "bu") && ($comp_oper = "<") && ($comp_unit = $output_metric . "B");
($o_type eq 'bl') && ($comp_oper = ">") && ($comp_unit = $output_metric . "B");
if (!defined($output)) { $output = "All selected storages "; }
if ($crit_state == 1) {
$comp_oper = ($comp_oper eq "<") ? ">" : "<"; # Inverse comp operator
if (defined($o_shortL[1])) {
print "CRITICAL : (", $comp_oper, $o_crit, $comp_unit, ") ", $output;
} else {
print $output, "(", $comp_oper, $o_crit, $comp_unit, ") : CRITICAL";
}
(defined($o_perf)) ? print " | ", $perf_out, "\n" : print "\n";
exit $ERRORS{"CRITICAL"};
}
if ($warn_state == 1) {
$comp_oper = ($comp_oper eq "<") ? ">" : "<"; # Inverse comp operator
if (defined($o_shortL[1])) {
print "WARNING : (", $comp_oper, $o_warn, $comp_unit, ") ", $output;
} else {
print $output, "(", $comp_oper, $o_warn, $comp_unit, ") : WARNING";
}
(defined($o_perf)) ? print " | ", $perf_out, "\n" : print "\n";
exit $ERRORS{"WARNING"};
}
if (defined($o_shortL[1])) {
print "OK : (", $comp_oper, $o_warn, $comp_unit, ") ", $output;
} else {
print $output, "(", $comp_oper, $o_warn, $comp_unit, ") : OK";
}
(defined($o_perf)) ? print " | ", $perf_out, "\n" : print "\n";
exit $ERRORS{"OK"};

525
plugins/check_snmp_vrrp.pl Executable file
View file

@ -0,0 +1,525 @@
#!/usr/bin/perl -w
############################## check_snmp_vrrp ##############
my $VERSION = "2.0.0";
# Date : Oct 17 2007
# Author : Patrick Proy (patrick at proy.org)
# Help : http://nagios.manubulon.com/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : C. Maser (Alteon + Netscreen), Harm-Jan Blok (Foundry)
#################################################################
#
# Help : ./check_snmp_vrrp.pl -h
#
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas
######### Nokia (standard ???)
my $all_vrrp = "1.3.6.1.2.1.68";
my $nokia_base_vrrp = "1.3.6.1.2.1.68.1.3.1"; # oid for vrrp
my $nokia_vrrp_oper = "1.3.6.1.2.1.68.1.3.1.3"; # vrrp operational status
my $nokia_vrrp_admin = "1.3.6.1.2.1.68.1.3.1.4"; # vrrp admin status
my $nokia_vrrp_prio = "1.3.6.1.2.1.68.1.3.1.5"; # vrrp vrid priority
######### Nokia Ipso Clustering
my $nokia_clust_table = "1.3.6.1.4.1.94.1.21.5.1.4.1"; # IpsoclusterEntry
my $nokia_clust_index = "1.3.6.1.4.1.94.1.21.5.1.4.1.1.1"; #index
my $nokia_clust_memberid = "1.3.6.1.4.1.94.1.21.5.1.4.1.2.1"; # member ID
my $nokia_clust_percent = "1.3.6.1.4.1.94.1.21.5.1.4.1.3.1"; #percent assigned
my $nokia_clust_rating = "1.3.6.1.4.1.94.1.21.5.1.4.1.4.1"; # node rating
my $nokia_clust_addr = "1.3.6.1.4.1.94.1.21.5.1.4.1.5.1"; # ip address
######### LinkProof
my $lp_base_vrrp = "1.3.6.1.2.1.68.1.3.1"; # oid for vrrp
my $lp_vrrp_oper = "1.3.6.1.2.1.68.1.3.1.4"; # vrrp operational status
my $lp_vrrp_admin = "1.3.6.1.2.1.68.1.3.1.5"; # vrrp admin status
my $lp_vrrp_prio = "1.3.6.1.2.1.68.1.3.1.6"; # vrrp vrid priority
######### Alteon (AD4 Loadbalancers)
my $alteon_base_vrrp = "1.3.6.1.4.1.1872.2.1.9.4";
my $alteon_vrrp_oper = "1.3.6.1.4.1.1872.2.1.9.4.1.1.2";
my $alteon_vrrp_admin = "";
my $alteon_vrrp_prio = "1.3.6.1.4.1.1872.2.1.9.4.1.1.3";
######### Netscreen (ScreenOS 5.1)
### .0 is always the queried device itself
### so in a cluster every device has its own numbering of members
my $ns_base_vrrp = "1.3.6.1.4.1.3224.6.2";
my $ns_vrrp_oper = "1.3.6.1.4.1.3224.6.2.2.1.3";
my $ns_vrrp_admin = "";
my $ns_vrrp_prio = "1.3.6.1.4.1.3224.6.2.2.1.4";
######## Foundry
my $foundry_base_vrrp = "1.3.6.1.4.1.1991.1.2.12.3.1.1"; # oid for vrrp
my $foundry_vrrp_oper = "1.3.6.1.4.1.1991.1.2.12.3.1.1.10"; # vrrp operational status
my $foundry_vrrp_admin = "1.3.6.1.4.1.1991.1.2.12.3.1.1.3"; # vrrp admin status
my $foundry_vrrp_prio = "1.3.6.1.4.1.1991.1.2.12.3.1.1.6"; # vrrp vrid priority
######### Make an array
my %base_vrrp = (
"nokia", $nokia_base_vrrp, "lp", $lp_base_vrrp, "alteon", $alteon_base_vrrp,
"nsc", $ns_base_vrrp, "foundry", $foundry_base_vrrp
);
my %vrrp_oper = (
"nokia", $nokia_vrrp_oper, "lp", $lp_vrrp_oper, "alteon", $alteon_vrrp_oper,
"nsc", $ns_vrrp_oper, "foundry", $foundry_vrrp_oper
);
my %vrrp_admin = (
"nokia", $nokia_vrrp_admin, "lp", $lp_vrrp_admin, "alteon", $alteon_vrrp_admin,
"nsc", $ns_vrrp_admin, "foundry", $foundry_vrrp_admin
);
my %vrrp_prio = (
"nokia", $nokia_vrrp_prio, "lp", $lp_vrrp_prio, "alteon", $alteon_vrrp_prio,
"nsc", $ns_vrrp_prio, "foundry", $foundry_vrrp_oper
);
my %state_master = ("nokia", 3, "alteon", 2, "lp", 3, "nsc", 2, "foundry", 1);
my %state_backup = ("nokia", 2, "alteon", 3, "lp", 2, "nsc", 3, "foundry", 2);
# Globals
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_version2 = undef; #use snmp v2c
my $o_port = 161; # port
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_state = undef; # Check master or backup state for ok
my $o_clustnum = undef; # number of cluster members
my $o_clustprct = undef; # Max % assigned to one cluster.
my $o_type = 'nokia'; # Check type : nokia|alteon|lp|nsc|foundry
my $o_long = undef; # Make output long
my $o_timeout = 5; # Default 5s Timeout
# SNMPv3 specific
my $o_login = undef; # Login for snmpv3
my $o_passwd = undef; # Pass for snmpv3
my $v3protocols = undef; # V3 protocol list.
my $o_authproto = 'md5'; # Auth protocol
my $o_privproto = 'des'; # Priv protocol
my $o_privpass = undef; # priv password
# functions
sub p_version { print "check_snmp_vrrp version : $VERSION\n"; }
sub print_usage {
print
"Usage: $0 [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) -s <master|backup|num,%> [-T <nokia|alteon|lp|nsc|ipsocluster|foundry>] [-p <port>] [-t <timeout>] [-V]\n";
}
sub isnnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub help {
print "\nSNMP VRRP Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL license, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=<authproto>,<privproto>
<authproto> : Authentication protocol (md5|sha : default md5)
<privproto> : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-T, --type=<nokia|alteon|lp|nsc|ipso>
Type of vrrp router to check
nokia (default) : Nokia vrrp. Should be working for most vrrp routers
alteon : for Alteon AD4 Loadbalancers
lp : Radware Linkproof
nsc : Nescreen (ScreenOS 5.x NSRP)
ipso : Nokia IPSO clustering
foundry : Foundry VRRP
-s, --state=master|backup|num,%
Nokia ipso clustering : number of members, max % assigned to nodes.
Other : check vrrp interface to be master or backup
-g, --long
Make output long even is all is OK
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
EOT
}
# For verbose output
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
# Get the alarm signal (just in case snmp timout screws up)
$SIG{'ALRM'} = sub {
print("ERROR: Alarm signal (Nagios time-out)\n");
exit $ERRORS{"UNKNOWN"};
};
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'V' => \$o_version,
'version' => \$o_version,
'g' => \$o_long,
'long' => \$o_long,
'T:s' => \$o_type,
'type:s' => \$o_type,
'2' => \$o_version2,
'v2c' => \$o_version2,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
'X:s' => \$o_privpass,
'privpass:s' => \$o_privpass,
'L:s' => \$v3protocols,
'protocols:s' => \$v3protocols,
's:s' => \$o_state,
'state:s' => \$o_state
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
if (!defined($o_host)) # check host and filter
{
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) {
print "Can't mix snmp v1,2c,3 protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (defined($v3protocols)) {
if (!defined($o_login)) {
print "Put snmp V3 login info with protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
my @v3proto = split(/,/, $v3protocols);
if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol
if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol
if ((defined($v3proto[1])) && (!defined($o_privpass))) {
print "Put snmp V3 priv login info with priv protocols!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check state
if ($o_type eq "ipso") {
my @state = split(/,/, $o_state);
if ($#state != 1) {
print "On ipso clustering : number of nodes, % assigned\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
$state[1] =~ s/%//;
if (isnnum($state[0]) || isnnum($state[1])) {
print "On ipso clustering (numbers) : number of nodes, % assigned\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
$o_clustnum = $state[0];
$o_clustprct = $state[1];
} else {
if (!defined($o_state) || ($o_state ne "master") && ($o_state ne "backup")) {
print "state must be master or backup\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
# Check type
if (
!defined($o_type)
|| ( ($o_type ne "nokia")
&& ($o_type ne "alteon")
&& ($o_type ne "lp")
&& ($o_type ne "nsc")
&& ($o_type ne "ipso")
&& ($o_type ne "foundry"))
)
{
print "type must be alteon,nokia,lp,nsc or ipso\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
if (!defined($o_privpass)) {
verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-port => $o_port,
-timeout => $o_timeout
);
} else {
verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => $o_authproto,
-privpassword => $o_privpass,
-privprotocol => $o_privproto,
-port => $o_port,
-timeout => $o_timeout
);
}
} else {
if (defined($o_version2)) {
# SNMPv2 Login
verb("SNMP v2c login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
verb("SNMP v1 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR opening session: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
############ Nokia ipso clustering
my $key = undef;
if ($o_type eq "ipso") {
# Get cluster table
my $resultat;
if (version->parse(Net::SNMP->VERSION) < 4) {
$resultat = $session->get_table($nokia_clust_table);
} else {
$resultat = $session->get_table(Baseoid => $nokia_clust_table);
}
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my $nclusterindex = 0;
my $output = undef;
my $overload = 0;
foreach $key (keys %$resultat) {
if ($key =~ /$nokia_clust_memberid/) {
# Get rid of the vrrp oper part
my $Cindex = $$resultat{$key};
$key =~ s/$nokia_clust_memberid\.//;
verb("Found cluster, index $key");
my $Pkey = $nokia_clust_percent . "." . $key;
my $percent = $$resultat{$Pkey};
verb("$percent / $Cindex");
if ($percent > $o_clustprct) { $overload = 1 }
if (defined($output)) {
$output .= "; Cluster " . $Cindex . " : " . $percent . "%";
} else {
$output = "Cluster " . $Cindex . " : " . $percent . "%";
}
$nclusterindex++;
}
}
if ($nclusterindex == 0) {
print "No Cluster membre found : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
if ($nclusterindex != $o_clustnum) {
print $output, " : Not ", $o_clustnum, " members : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
if ($overload == 1) {
print $output, " assigned % is > ", $o_clustprct, " : WARNING\n";
exit $ERRORS{"WARNING"};
}
print $output, " : OK\n";
exit $ERRORS{"OK"};
}
########### get vrrp table ############
# Get vrrp table
my $resultat;
if (version->parse(Net::SNMP->VERSION) < 4) {
$resultat = $session->get_table($base_vrrp{$o_type});
} else {
$resultat = $session->get_table(Baseoid => $base_vrrp{$o_type});
}
if (!defined($resultat)) {
printf("ERROR: Description table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my @vrid = undef;
my $nvrid = 0;
my $oid0 = undef;
my @oid = undef;
if ($o_type eq 'nsc') {
$nvrid = 1;
$vrid[0] = '0';
} else {
foreach $key (keys %$resultat) {
if ($key =~ /$vrrp_oper{$o_type}/) {
# Get rid of the vrrp oper part
$key =~ s/$vrrp_oper{$o_type}\.//;
@oid = split(/\./, $key);
$vrid[$nvrid] = pop(@oid);
$oid0 = pop(@oid);
while (defined($oid0)) {
$vrid[$nvrid] = $oid0 . "." . $vrid[$nvrid];
$oid0 = pop(@oid);
}
verb("Added vrid $vrid[$nvrid]");
$nvrid++;
}
}
}
if ($nvrid == 0) { printf("No vrid found : CRITICAL\n"); exit $ERRORS{"CRITICAL"}; }
my $ok = 0;
my $value;
my $output = undef;
my $vrid_out;
for (my $i = 0; $i < $nvrid; $i++) {
$output .= ", " if (defined($output));
# Get last part of oid to output the vrid
$vrid_out = $vrid[$i];
$vrid_out =~ s/.*\.//;
$output .= "$vrid_out(";
# Get the state
$key = $vrrp_oper{$o_type} . "." . $vrid[$i];
$value
= ($$resultat{$key} == $state_master{$o_type}) ? "master"
: ($$resultat{$key} == $state_backup{$o_type}) ? "backup"
: "initialise : " . $$resultat{$key};
$output .= $value . "/";
($value eq $o_state) && $ok++;
# Get the administrative status
if (($o_type eq 'alteon') || ($o_type eq 'nsc')) {
$ok++;
} else {
$key = $vrrp_admin{$o_type} . "." . $vrid[$i];
$value = ($$resultat{$key} == 1) ? "up" : "down";
$output .= $value . "/";
if (($o_type eq 'foundry') && ($o_state eq 'backup') && ($value eq "down")) {
$ok++;
} else {
($value eq "up") && $ok++;
}
}
# Get the priority
$key = $vrrp_prio{$o_type} . "." . $vrid[$i];
$value = $$resultat{$key};
$output .= $value . ")";
}
verb("verif : $ok");
if ($ok == (2 * $nvrid)) {
if (defined($o_long)) {
printf("Vrid : %s : %s %s : OK\n", $output, $nvrid, $o_state);
} else {
printf("%s vrid %s :OK\n", $nvrid, $o_state);
}
exit $ERRORS{"OK"};
}
printf("Vrid : %s : not all %s : NOK\n", $output, $o_state);
exit $ERRORS{"CRITICAL"};

428
plugins/check_snmp_win.pl Executable file
View file

@ -0,0 +1,428 @@
#!/usr/bin/perl -w
############################## check_snmp_win ##############
my $VERSION = "2.0.0";
# Date : Oct 12 2007
# Author : Patrick Proy (patrick at proy.org)
# Help : http://nagios.manubulon.com/
# License : GPL - http://www.fsf.org/licenses/gpl.txt
# Contrib : Tenaku
# TODO :
###############################################################
#
# help : ./check_snmp_win.pl -h
use strict;
use Net::SNMP;
use Getopt::Long;
# Icinga specific
my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4);
# SNMP Datas for processes (MIB II)
my $process_table = '1.3.6.1.2.1.25.4.2.1';
my $index_table = '1.3.6.1.2.1.25.4.2.1.1';
my $run_name_table = '1.3.6.1.2.1.25.4.2.1.2';
my $run_path_table = '1.3.6.1.2.1.25.4.2.1.4';
my $proc_mem_table = '1.3.6.1.2.1.25.5.1.1.2'; # Kbytes
my $proc_cpu_table = '1.3.6.1.2.1.25.5.1.1.1'; # Centi sec of CPU
my $proc_run_state = '1.3.6.1.2.1.25.4.2.1.7';
# Windows SNMP DATA
my $win_serv_table = '1.3.6.1.4.1.77.1.2.3.1'; # Windows services table
my $win_serv_name = '1.3.6.1.4.1.77.1.2.3.1.1'; # Name of the service
# Install state : uninstalled(1), install-pending(2), uninstall-pending(3), installed(4)
my $win_serv_inst = '1.3.6.1.4.1.77.1.2.3.1.2';
# Operating state : active(1), continue-pending(2), pause-pending(3), paused(4)
my $win_serv_state = '1.3.6.1.4.1.77.1.2.3.1.3';
my %win_serv_state_label = (1 => 'active', 2 => 'continue-pending', 3 => 'pause-pending', 4 => 'paused');
# Can be uninstalled : cannot-be-uninstalled(1), can-be-uninstalled(2)
my $win_serv_uninst = '1.3.6.1.4.1.77.1.2.3.1.4';
# Globals
my $Name = 'check_snmp_win';
my $o_host = undef; # hostname
my $o_community = undef; # community
my $o_port = 161; # port
my $o_version2 = undef; #use snmp v2c
my $o_descr = undef; # description filter
my @o_descrL = undef; # Service descriprion list.
my $o_showall = undef; # Show all services even if OK
my $o_type = "service"; # Check type (service, ...)
my $o_number = undef; # Number of service for warn and crit levels
my $o_help = undef; # wan't some help ?
my $o_verb = undef; # verbose mode
my $o_version = undef; # print version
my $o_noreg = undef; # Do not use Regexp for name
my $o_timeout = 5; # Default 5s Timeout
# SNMP V3 specific
my $o_login = undef; # snmp v3 login
my $o_passwd = undef; # snmp v3 passwd
# functions
sub p_version { print "$Name version : $VERSION\n"; }
sub print_usage {
print
"Usage: $Name [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -n <name>[,<name2] [-T=service] [-r] [-s] [-N=<n>] [-t <timeout>] [-V]\n";
}
sub isnotnum { # Return true if arg is not a number
my $num = shift;
if ($num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/) { return 0; }
return 1;
}
sub is_pattern_valid { # Test for things like "<I\s*[^>" or "+5-i"
my $pat = shift;
if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings
return eval { "" =~ /$pat/; 1 } || 0;
}
# Get the alarm signal (just in case snmp timout screws up)
$SIG{'ALRM'} = sub {
print("ERROR: Alarm signal (Nagios time-out)\n");
exit $ERRORS{"UNKNOWN"};
};
sub help {
print "\nSNMP Windows Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n";
print "GPL license, (c)2004-2007 Patrick Proy\n\n";
print_usage();
print <<EOT;
-v, --verbose
print extra debugging information (and lists all services)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN
Login for snmpv3 authentication (implies v3 protocol with MD5)
-x, --passwd=PASSWD
Password for snmpv3 authentication
-p, --port=PORT
SNMP port (Default 161)
-T, --type=service
Check type :
- service (default) checks service
-n, --name=NAME[,NAME2...]
Comma separated names of services (perl regular expressions can be used for every one).
By default, it is not case sensitive.
-N, --number=<n>
Compare matching services with <n> instead of the number of names provided.
-s, --showall
Show all services in the output, instead of only the non-active ones.
-r, --noregexp
Do not use regexp to match NAME in service description.
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
Note :
The script will return
OK if ALL services are in active state,
WARNING if there is more than specified (ex 2 service specified, 3 active services matching),
CRITICAL if at least one of them is non active.
The -n option will allows regexp in perl format
-n "service" will match 'service WINS' 'sevice DNS' etc...
It is not case sensitive by default : WINS = wins
EOT
}
sub verb { my $t = shift; print $t, "\n" if defined($o_verb); }
sub decode_utf8 { # just replaces UFT8 caracters by "."
my $utfstr = shift;
if (substr($utfstr, 0, 2) ne "0x") { return $utfstr; }
my @stringL = split(//, $utfstr);
my $newstring = "";
for (my $i = 2; $i < $#stringL; $i += 2) {
if (($stringL[$i] . $stringL[$i + 1]) eq "c3") {
$i += 2;
$newstring .= ".";
} else {
$newstring .= chr(hex($stringL[$i] . $stringL[$i + 1]));
}
}
return $newstring;
}
sub check_options {
Getopt::Long::Configure("bundling");
GetOptions(
'v' => \$o_verb,
'verbose' => \$o_verb,
'h' => \$o_help,
'help' => \$o_help,
'H:s' => \$o_host,
'hostname:s' => \$o_host,
'p:i' => \$o_port,
'port:i' => \$o_port,
'C:s' => \$o_community,
'community:s' => \$o_community,
'l:s' => \$o_login,
'login:s' => \$o_login,
'x:s' => \$o_passwd,
'passwd:s' => \$o_passwd,
't:i' => \$o_timeout,
'timeout:i' => \$o_timeout,
'n:s' => \$o_descr,
'name:s' => \$o_descr,
'r' => \$o_noreg,
'noregexp' => \$o_noreg,
'T:s' => \$o_type,
'type:s' => \$o_type,
'N:i' => \$o_number,
'number:i' => \$o_number,
'2' => \$o_version2,
'v2c' => \$o_version2,
's' => \$o_showall,
'showall' => \$o_showall,
'V' => \$o_version,
'version' => \$o_version
);
if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} }
if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} }
# check snmp information
if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) {
print "Put snmp login info!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
# Check compulsory attributes
if ($o_type ne "service") {
print "Invalid check type !\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
if (!defined($o_descr) || !defined($o_host)) { print_usage(); exit $ERRORS{"UNKNOWN"} }
@o_descrL = split(/,/, $o_descr);
foreach my $List (@o_descrL) {
if (!is_pattern_valid($List)) { print "Invalid pattern ! "; print_usage(); exit $ERRORS{"UNKNOWN"} }
}
if (defined($o_number)) {
if (isnotnum($o_number) || ($o_number < 0)) {
print "Invalid number of services!\n";
print_usage();
exit $ERRORS{"UNKNOWN"};
}
}
}
########## MAIN #######
check_options();
# Check timeout if snmp screws up
if (defined($o_timeout)) {
verb("Alarm in $o_timeout seconds");
alarm($o_timeout);
}
$SIG{'ALRM'} = sub {
print "No answer from host $o_host:$o_port\n";
exit $ERRORS{"UNKNOWN"};
};
# Connect to host
my ($session, $error);
if (defined($o_login) && defined($o_passwd)) {
# SNMPv3 login
verb("SNMPv3 login");
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => '3',
-username => $o_login,
-authpassword => $o_passwd,
-authprotocol => 'md5',
-privpassword => $o_passwd,
-timeout => $o_timeout
);
} else {
if (defined($o_version2)) {
# SNMPv2 Login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-version => 2,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
} else {
# SNMPV1 login
($session, $error) = Net::SNMP->session(
-hostname => $o_host,
-community => $o_community,
-port => $o_port,
-timeout => $o_timeout
);
}
}
if (!defined($session)) {
printf("ERROR: %s.\n", $error);
exit $ERRORS{"UNKNOWN"};
}
$session->max_msg_size(5000);
verb($session->max_msg_size);
# Look for process in name or path name table
my $resultat = undef;
$resultat
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_table($win_serv_name)
: $session->get_table(Baseoid => $win_serv_name);
if (!defined($resultat)) {
printf("ERROR: Process name table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
my @tindex = undef;
my @oids = undef;
my @descr = undef;
my $num_int = 0;
my $count_oid = 0;
# Select storage by regexp of exact match
# and put the oid to query in an array
verb("Filter : $o_descr");
foreach my $key (keys %$resultat) {
my $descr_d = decode_utf8($$resultat{$key});
verb("Desc : $descr_d");
# test by regexp or exact match
my $test = undef;
foreach my $List (@o_descrL) {
if (!($test)) {
$test
= defined($o_noreg)
? $descr_d eq $List
: $descr_d =~ /$List/i;
}
}
if ($test) {
# get the full description
$descr[$num_int] = $descr_d;
# get the index number of the process
$key =~ s/$win_serv_name\.//;
$tindex[$num_int] = $key;
# put the oid of running state in an array.
$oids[$count_oid++] = $win_serv_state . "." . $tindex[$num_int];
verb("Name : $descr[$num_int], Index : $tindex[$num_int]");
$num_int++;
}
}
if ($num_int == 0) {
if (defined($o_number) && ($o_number == 0)) {
print "No services ", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : OK\n";
exit $ERRORS{"OK"};
} else {
print "No services ", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : CRITICAL\n";
exit $ERRORS{"CRITICAL"};
}
}
my $result = undef;
my $num_int_ok = 0;
$result
= (version->parse(Net::SNMP->VERSION) < 4)
? $session->get_request(@oids)
: $session->get_request(Varbindlist => \@oids);
if (!defined($result)) {
printf("ERROR: running table : %s.\n", $session->error);
$session->close;
exit $ERRORS{"UNKNOWN"};
}
$session->close;
my $output = undef;
#Check if service are in active state
for (my $i = 0; $i < $num_int; $i++) {
my $state = $$result{ $win_serv_state . "." . $tindex[$i] };
verb("Process $tindex[$i] in state $state");
if ($state == 1) {
$num_int_ok++;
} else {
$output .= ", " if defined($output);
$output .= $descr[$i] . " : " . $win_serv_state_label{$state};
}
}
my $force_critical = 0;
# Show the services that are not present
# Or all of them with -s option
foreach my $List (@o_descrL) {
my $test = 0;
for (my $i = 0; $i < $num_int; $i++) {
if (defined($o_noreg)) {
if ($descr[$i] eq $List) { $test++; }
} else {
if ($descr[$i] =~ /$List/i) { $test++; }
}
}
if ($test == 0) {
$output .= ", " if defined($output);
$output .= "\"" . $List . "\" not active";
# Force a critical state (could otherwise lead to false OK)
$force_critical = 1;
} elsif (defined($o_showall)) {
$output .= ", " if defined($output);
$output .= "\"" . $List . "\" active";
if ($test != 1) {
$output .= "(" . $test . " services)";
}
}
}
if (defined($output)) {
print $output, " : ";
} else {
print $num_int_ok, " services active (", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\") : ";
}
$o_number = $#o_descrL + 1 if (!defined($o_number));
if (($num_int_ok < $o_number) || ($force_critical == 1)) {
print "CRITICAL\n";
exit $ERRORS{"CRITICAL"};
} elsif ($num_int_ok > $o_number) {
print "WARNING\n";
exit $ERRORS{"WARNING"};
}
print "OK\n";
exit $ERRORS{"OK"};

256
plugins/doc/faq.html Executable file
View file

@ -0,0 +1,256 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0" height="1477">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top height="1452">
<tr>
<td class="ProgramTitle"> FAQ</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">&nbsp;</p>
<p class="SectionTitle"> Last update : May 25 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">&nbsp;</p>
<p class="SectionTitle"><b>FIRST, </b>look at the web page associated
with every script.</p>
<p class="SectionBody"><b>Running the scripts :</b></p>
<p class="SectionBody">- <a href="#FAQ1">The scripts outputs &quot;Can't
locate Net/SNMP.pm in @INC.....&quot;</a></p>
<p class="SectionBody">-<a href="#FAQ2"> How do I install Net::SNMP
perl module</a></p>
<p class="SectionBody">- <a href="#FAQ3">What are the supported platforms
to run the scripts on ?</a></p>
<p class="SectionBody">- <a href="#FAQ4">How do I get help on the
options ?</a></p>
<p class="SectionBody">- <a href="#FAQ5">Return code of X is out of
bounds</a></p>
<p class="SectionBody">- <a href="#FAQ6">Are these plugins compatible
with Nagios 2.0 ?</a></p>
<p class="SectionBody">- <a href="#FAQ7"> ERROR: XXXXXX : Expected
OBJECT IDENTIFIER in dotted notation. </a></p>
<p class="SectionBody">- <a href="#FAQ8">&quot;No Output&quot; using
Nagios 2</a></p>
<p class="SectionBody">- <a href="#FAQ9">Getting : &quot;ERROR: Size
table :Message size exceeded buffer maxMsgSize&quot;</a></p>
<p class="SectionBody">- <a href="#FAQ10">No usable data on file (X rows)</a></p>
<p class="SectionBody"><b>Misc<br>
</b></p>
<p class="SectionBody">- <a href="#FAQM3">Are these scripts secure
?</a></p>
<p class="SectionBody">- <a href="#FAQM1">How can I get help ? Is
there a mailling list ? a forum ?</a></p>
<p class="SectionBody">- <a href="#FAQM2">Can I donate to help this
project ?</a></p>
<hr>
<p class="SectionTitle"><a name="FAQ1"></a>The scripts outputs &quot;Can't
locate Net/SNMP.pm in @INC.....&quot;</p>
<p class="SectionBody">You don't have Net::SNMP installed, see below</p>
<p class="SectionTitle"><a name="FAQ2"></a>How do I install Net::SNMP
perl module ?</p>
<p class="SectionBody">There are 2 ways of doing this </p>
<p class="SectionBody"><b>1) By CPAN (best)</b></p>
<p class="SectionBody">on command line, as root : <br>
<br>
[your_host]# <b>perl -MCPAN -e shell</b><br>
cpan shell -- CPAN exploration and modules installation (v1.76)<br>
ReadLine support enabled<br>
cpan&gt; <b>install Net::SNMP</b><br>
</p>
<p class="SectionBody">If it's the first time you run CPAN, it will
probably ask you some (simple) questions.</p>
<p class="SectionBody">CPAN will also ask you to satisfy some dependencies
(Crypt::DES, Digest::MD5, etc..).</p>
<p class="SectionBody"><b>2) &quot;By hand&quot;</b><br>
</p>
<p class="SectionBody">Get the folowings modules (tar.gz format) on
<a href="http://www.cpan.org">www.cpan.org</a></p>
<p class="SectionBody">- Crypt::DES<br>
- Digest::MD5<br>
- Digest::SHA1<br>
- Digest::HMAC<br>
- Net::SNMP<br>
<br>
for each one (you must install Net::SNMP at the end) : <br>
<b>tar zxf &lt;module&gt;.tar.gz<br>
cd &lt;module&gt;<br>
perl Makefile.pl<br>
make test<br>
make install</b></p>
<p class="SectionTitle"><a name="FAQ3"></a>What are the supported
platforms to run the scripts on ?</p>
<p class="SectionBody">Most Linux, maybe some unixes and maybe Cygwin.<br>
Actually anything you can run perl on.<br>
If you can install the latest Net::SNMP module, then the perl version
should be OK.</p>
<p class="SectionTitle"><a name="FAQ4"></a>How do I get help on the
options ?</p>
<p class="SectionBody">Just run <b>&lt;script&gt; -h </b>on the command
line.<br>
<br>
</p>
<p class="SectionTitle"><a name="FAQ5"></a>Return code of X is out
of bounds</p>
<p class="SectionBody">Have a look at : <a href="http://www.nagios.org/faqs/viewfaq.php?faq_id=17">http://www.nagios.org/faqs/viewfaq.php?faq_id=17</a></p>
<p class="SectionBody">In case of return code 127, try putting perl
in the command line definition : </p>
<p class="SectionBody"> define command{<br>
command_name check_disk<br>
command_line <b>/usr/bin/perl</b> $USER1$/check_snmp_storage.pl
-C $ARG1$ [........]<br>
}<br>
</p>
<p class="SectionTitle"><a name="FAQ6"></a>Are these plugins compatible
with Nagios 2.0 ?</p>
<p class="SectionBody">Yes.</p>
<p class="SectionTitle"><a name="FAQ7"></a>ERROR: XXXXXX : Expected OBJECT IDENTIFIER in dotted notation.
</p>
<p class="SectionBody">Upgrade your Net::SNMP module version (5 is good, 4 maybe OK, 3 gives this error) <br>
This happens with Debian Woody (Net::SNMP version 3.6).<br>
I have special patches if you can't upgrade : contact me.</p>
<p class="SectionTitle"><a name="FAQ8"></a>&quot;No Output&quot; using
Nagios 2</p>
<p class="SectionBody">It's a &quot;bug&quot; of embeded perl. It
has been corrected in latest Nagios releases.</p>
<p class="SectionBody">You can :<br>
</p>
<p class="SectionBody">- Add a patch if your nagios release is old.
Here is a patch made by Gavin Carr for the p1.pl file to correct
this (it should be in nagios CVS shortly). <a href="http://nagios.manubulon.com/p1-print.pl.patch">http://nagios.manubulon.com/p1-print.pl.patch</a>
</p>
<p class="SectionBody">- Upgrade Nagios.<br>
<br>
- add &quot;/usr/bin/perl&quot; before the script command so Nagios
won't use embeded perl. </p>
<p class="SectionTitle"><a name="FAQ9"></a>Getting : &quot;ERROR:
Size table :Message size exceeded buffer maxMsgSize&quot;</p>
<p class="SectionBody">Your snmp table is too big.</p>
<p class="SectionBody">Some of my scripts (check_snmp_storage and
check_snmp_process) now have an option (-o) to set this directly
on command line (thx to Makina Corpus for the patch).</p>
<p class="SectionBody">In other scripts, try adding :</p>
<p class="SectionBody"> $session-&gt;max_msg_size(5000);<br>
</p>
<p class="SectionBody">After the session has been initialized. </p>
<p class="SectionTitle"><a name="FAQ10"></a>No usable data on file (X rows)</p>
<p class="SectionBody">Scripts like check_snmp_int need to store data when they get a SNMP counter so they can outpout readable data like bandwidth, cpu, etc....</p>
<p class="SectionBody">For example, to output a bandwidth with an octet counter, check_snmp_int will store data every time it is run. It will also read the previous data, and try to get data old enough to make a correct average. By default, it needs data which was produced 5 minutes ago.</p>
<p class="SectionBody">So, when you first run the script - or if you run it a long time ago -, it won't be able to get data old enough and will report an error (UNKNOWN status) saying the is &quot;no usable data on file (X rows)&quot;.<br>
If you leave the 5 minutes default delta value, the script will need data wich is : <br>
- At least 4 minutes and 30 seconds old (5 min - 10%)<br>
- At most 15 minutes old (3 * 5 min) </p>
<p class="SectionBody">You can change this 5 minutes value using the '-d &lt;sec&gt;' option. The script will then look for data which is at least &lt;sec&gt;-10% old and at most 3*&lt;sec&gt;. </p>
<p class="SectionBody">This option will only tell to make an average on &lt;sec&gt; seconds, you can run the service every minute with Nagios, it will always get the newest value which is at least &lt;sec&gt;-10% old.<br>
The only thing you must check is that your service will at least run every 15 minutes, or the script will always output &quot;unknown&quot; as the value will be too old for him. </p>
<p class="SectionTitle"><br>
<a name="FAQM3"></a>Are these scripts secure ?</p>
<p class="SectionBody">Not at all ! You must secure the Nagios server.<br>
Nobody else than the nagios user should be allowed to even think
about running these scripts.<br>
</p>
<p class="SectionTitle"><a name="FAQM1"></a>How can I get help ? Is
there a mailling list ? a forum ?</p>
<p class="SectionBody">Go to the sourceforge project page for all this : <a href=http://sourceforge.net/projects/nagios-snmp/>Nagios-snmp</a>
<p class="SectionBody"><a name="FAQM2"></a><span class="SectionTitle">Can
I donate to help this project ?</span></p>
<p class="SectionBody">Of course you can, I just haven't got any idea
of how, so just send a postcard to my son (Jolan) with a nice drawing (or buy a cookie to your son/daughter/nephew/grand-ma...).<br>
You can get my postal address on my resume (<a href="http://www.manubulon.com/cvpproy.htm">www.manubulon.com/cvpproy.htm</a>).<br>
He will answer you when he knows how to write (in several years).</p>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is also hosted by : <br>
<A href="http://sourceforge.net/projects/nagios-snmp/"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p></td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

431
plugins/doc/index.html Executable file
View file

@ -0,0 +1,431 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<table width="100%" border="0">
<tr>
<td width="127" valign=top height="1448">
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a class="SideNavBarHotItem" >This site :</a></td>
</tr>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td><a href="index_snmp.html" class="SideNavBarItem" >Nagios plugins</a></td>
</tr>
<tr>
<td><a href="index_info.html" class="SideNavBarItem" >Info on snmp</a></td>
</tr>
<tr>
<td><a href="index_commands.html" class="SideNavBarItem" > Nagios config</a></td>
</tr>
<tr>
<td><a href="faq.html" class="SideNavBarItem" > FAQ</a></td>
</tr>
<tr>
<td> <a href="http://sourceforge.net/projects/nagios-snmp/" class="SideNavBarItem" >
Project page on SourceForge</a> </td>
</tr>
<tr>
<td><font color="#FFFFFF">-----------</font></td>
</tr>
<tr>
<td><a class="SideNavBarHotItem" >Links :</a></td>
</tr>
<tr>
<td><a href="http://www.nagios.org/" class="SideNavBarItem" >Nagios
Home</a></td>
</tr>
<tr>
<td><a href="http://sourceforge.net/projects/nagiosplugins" class="SideNavBarItem" >Nagios
Plugins</a></td>
</tr>
<tr>
<td><a href="http://www.oreon.org" class="SideNavBarItem" >Oreon project</a></td>
</tr>
<tr>
<td><a href="http://www.nagiosexchange.org" class="SideNavBarItem" >NagiosExchange</a></td>
</tr>
<tr>
<td><a href="http://forums.opsyx.com/viewforum.php?f=1" class="SideNavBarItem" >Opsyx
forum</a></td>
</tr>
<tr>
<td><a href="http://forum.2037.org/" class="SideNavBarItem" >Forum 2037</a></td>
</tr>
<tr>
<td><font color="#FFFFFF">-----------</font></td>
</tr>
<tr>
<td> <A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&amp;type=3" width="110" height="37" border="0" alt="SourceForge.net Logo" /></A>
</td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table width="100%" border="0" valign=top>
<tr>
<td class="ProgramTitle"> My plugins for <img src="img/smalllogo7.jpg" border="0" alt="Nagios">
</td>
</tr>
<tr>
<td>
<p class="SectionTitle" align="right">Last update : Jun 9 2007</p>
<p class="SectionTitle" align="left">About </p>
<p class="SectionBody">The general idea of these scripts is to check
as many things as possible with snmp (how do you install NRPE on
Cisco or AS/400 ?) : disks, memory, load, interface, running procsses,
etc...<br>
</p>
<p class="SectionBody">The other idea is to select disks, interfaces,
process using regular expressions <br>
<br>
- it is possible to test more than one disk/int/process in one Nagios
check (ex : eth* instead of eth0,eth1,eth2,...)<br>
<br>
- you only have to provide a unique part of the name to select a
disk/int/process (ex : &quot;C:&quot; instead of &quot;C:\ Label:
Serial Number xxxxxxx&quot; makes it easy to use on multiple Windows
hosts). </p>
<p class="SectionBody">Most of these scripts can make performance
outputs. </p>
<p class="SectionBody">Enjoy and give me feedback !<br>
<br>
All code here is under GPL licence. <br>
</p>
<p class="SectionTitle"> If you want to be informed when I release
new versions, <br>
or if you have some advices, feedback, questions, go to the project's
sourceforge page : <a href="http://sourceforge.net/projects/nagios-snmp">nagios-snmp</a></p>
<p class="SectionBody">Please send me your feedback : <br>
- Test with embeded Perl<br>
- Test on various systems<br>
- Bugs, advices, comments, RFE, etc...<br>
Thank you !</p>
<p class="SectionBody">Run the scripts with '-h' to get help.</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">&nbsp;</p>
<p class="SectionTitle">Requirements</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - if not run 'perl
script' or change the path in the scripts first line <br>
- Net::SNMP<br>
- file 'utils.pm' in diretory /usr/local/icinga/libexec or change
the line "use libs /usr/local/icinga/libexec/" in the scripts<br>
</p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="SectionTitle">Plugins<br>
</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top>Bundle of all plugins</td>
<td class="SectionBody">
<p>Version 1.1.1 : <a href="nagios-snmp-plugins.1.1.1.tgz">nagios-snmp-plugins.1.1.1.tgz</a></p>
<p>This bundle contains all the plugins, including an install
script useful if you have special Nagios or perl paths.</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_storage.html">check_snmp_storage</a><br>
<br>
<p> Download version <a href="check_snmp_storage.pl">1.3.3</a></p>
<p>&nbsp; </p>
</td>
<td class="SectionBody">
<p>This scripts checks by snmp (1,2c,3) disks, memory, swap,
everthing in hrStorage table. <br>
Disk selection can be done by perl regexp on description,
index or type to select one or multiple storages.<br>
<br>
V&eacute;rifie par snmp v1 ou v3 (merci &agrave; V. Carpentier)
l'occupation des disques, mais aussi de la swap, de la m&eacute;moire,
etc.. tout ce qui est disponible en snmp par la table hrStorage.<br>
Les disques sont s&eacute;lectionnables par expression r&eacute;guli&egrave;re
compatible Perl</p>
<p><a href="snmp_storage.html">Details</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_int.html">check_snmp_int</a><br>
<br>
Download version <a href="check_snmp_int.pl">1.4.8</a></p>
</td>
<td class="SectionBody">
<p>Checks by snmp (1,2c,3) interface state and usage. Interfaces
can be selected by regexp.<br>
It is possible to check the input/output bandwidth and error
rate of the interface.<br>
<br>
V&eacute;rifie par snmp v1 ou v3 l'&eacute;tat des interfaces
d'un h&ocirc;te.<br>
Ce script permet d'utiliser des expressions r&eacute;guli&egrave;res
pour s&eacute;lectionner les interfaces : ex 'eth' va v&eacute;rifier
eth0, eth1, ...<br>
Il permet &eacute;galement de lister toutes les interfaces
disponibles sur la machine cible (option -v). </p>
<p><a href="snmp_int.html">Details</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_process.html">check_snmp_process</a></p>
<p>Download version <a href="check_snmp_process.pl">1.5<br>
</a></p>
<p>&nbsp;</p>
</td>
<td class="SectionBody">
<p>Checks by snmp (1,2c,3) the number (can be 1) of processes
matching a perl regexp.<br>
The script can also check memory and cpu usage of processes.</p>
<p>V&eacute;rifie par snmp v1 ou v3 (idem) le nombre de process
sur un h&ocirc;te.<br>
Ce script permet d'utiliser des expressions r&eacute;guli&egrave;res
pour s&eacute;lectionner les process.<br>
Il est &eacute;galement possible de v&eacute;rifier l'utilisation
m&eacute;moire et CPU de la machine.<br>
Il permet &eacute;galement de lister touts les process disponibles
sur la machine cible (option -v). </p>
<p><a href="snmp_load.html">Details</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_load.html">check_snmp_load</a></p>
<p> Download version <a href="check_snmp_load.pl">1.3.2</a></p>
</td>
<td class="SectionBody">
<p>Checks by snmp (1,2c,3) cpu or average load. <br>
Works on Linux, Windows, Cisco, AS400, HP Procurve, LinkProof,
Blucoat, Nokia, Fortinet, Netscreen,HP-UX.</p>
<p> V&eacute;rifie par snmp (1,2c,3) la charge ou l'ocupation
CPU.<br>
</p>
<p><a href="snmp_load.html">Details.</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_mem.html">check_snmp_mem</a></p>
<p>Download version <a href="check_snmp_mem.pl">1.1</a></p>
</td>
<td class="SectionBody">
<p>Checks by snmp (1,2c,3) : <br>
- Memory and swap usage on Linux/Net-snmp<br>
- Memory usage on cisco routers or Pix<br>
- Memory usage on HP Procurve switchs<br>
For memory check on other OS (Windows, AS400) see the description
page </p>
<p>V&eacute;rifcation de <br>
- l'utilisation m&eacute;moire et swap sur Linux/Net-snmp<br>
- l'utilisation m&eacute;moire sur Cisco (routeurs et Pix).<br>
- l'utilisation m&eacute;moire sur Switch Hp Procurve.<br>
Pour d'autres SE (Windows, AS400), aller &agrave; la page
de description.</p>
<p><a href="snmp_mem.html">D&eacute;tail</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_vrrp.html">check_snmp_vrrp</a></p>
<p>Download version : <a href="check_snmp_vrrp.pl">1.3</a></p>
</td>
<td class="SectionBody">
<p>Checks the vrrp state of all the interface of a host. You
can specify if they must be master or backup.<br>
Supported platforms : Nokia IP (vrrp &amp; clustering), Linkproof,
Alteon.</p>
<p>Verifie l'&eacute;tat vrrp des interfaces d'un host.</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_cpfw.html">check_snmp_cpfw</a></p>
<p>Download version : <a href="check_snmp_cpfw.pl">1.2.1</a></p>
</td>
<td class="SectionBody">
<p>Checks the state of Checkpoint Firewall-1 modules (SVN, HA,
FW, MGMT) and active connexions (tested on NG).<br>
Snmp extensions must be activated</p>
<p>V&eacute;rifie l'&eacute;tat des modules Checkpoint Fw-1
(HA, SVN, MGMT, FW) et les connexions actives. Test&eacute;
sur NG-AI R55.<br>
L'extension SNMP doit &ecirc;tre activ&eacute;e sur les modules.</p>
<p><a href="snmp_cpfw.html">D&eacute;tail</a></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top>
<p><a href="snmp_windows.html">check_snmp_win</a></p>
<p>Download version : <a href="check_snmp_win.pl">0.6</a></p>
</td>
<td class="SectionBody">
<p>Checks windows services state with snmp.</p>
<p>V&eacute;ifie l'&eacute;tat de services Windows par snmp.</p>
<p><a href="snmp_windows.html">D&eacute;tail</a></p>
</td>
</tr>
<tr>
<td class="SectionBody">
<p><a href="snmp_css.html" class="NewsItemDate">check_snmp_css</a></p>
<p><b>Download version</b> : <a href="check_snmp_css.pl">1.0</a></p>
</td>
<td class="SectionBody">Checks css services state</td>
</tr>
<tr>
<td class="SectionBody">
<p><a href="snmp_env.html" class="NewsItemDate">check_snmp_env</a></p>
<p><b>Download version</b> : <a href="check_snmp_env.pl">1.2</a></p>
</td>
<td class="SectionBody">Checks environemental status (fan, temp,
power supply) on Cisco, Nokia, Bluecoat, IronPort.</td>
</tr>
<tr>
<td class="SectionBody">
<p class="NewsItemDate">check_snmp_nsbox</p>
<p><b>Download versio</b>n : <a href="check_snmp_nsbox.pl">1.0</a></p>
</td>
<td class="SectionBody">Checks nsbox vhost &amp; diode status.</td>
</tr>
<tr>
<td class="SectionBody">
<p class="NewsItemDate">check_snmp_boostedge</p>
<p><b>Download version</b> : <a href="check_snmp_boostedge.pl">1.0</a></p>
</td>
<td class="SectionBody">Checks Boostedge services</td>
</tr>
<tr>
<td class="SectionBody">
<p class="NewsItemDate">check_snmp_linkproof_nhr</p>
<p><b>Download version</b> : <a href="check_snmp_linkproof_nhr.pl">1.0</a></p>
</td>
<td class="SectionBody">Checks linkproof NHR</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionTitle">Compatibility matrix : </p>
<table width="100%" border="2" class="SectionBody" cellspacing="3">
<tr>
<td class="SectionTitle">System</td>
<td class="SectionTitle">check_snmp_storage</td>
<td class="SectionTitle">check_snmp_int</td>
<td class="SectionTitle">check_snmp_process</td>
<td class="SectionTitle">check_snmp_mem</td>
<td class="SectionTitle">check_snmp_load</td>
</tr>
<tr>
<td>Linux</td>
<td>
<p>OK : <br>
- '/home', '/var'<br>
- 'Swap', 'Real Memory'<br>
</p>
</td>
<td>OK : <br>
- 'eth' <br>
- 'ppp'</td>
<td>OK</td>
<td>OK (mem &amp; swap)</td>
<td>
<p>OK</p>
</td>
</tr>
<tr>
<td>Windows</td>
<td>
<p>OK :<br>
- '^[CDE]:'</p>
</td>
<td>OK</td>
<td>OK</td>
<td>
<p>NO<br>
See check_snmp_storage for virtual mem</p>
</td>
<td>OK</td>
</tr>
<tr>
<td>Cisco/HP switch</td>
<td>N/A</td>
<td>OK :<br>
- 'Giga' : all gigabits<br>
- 'Fast.*0.1[1234]' : checks FastEternet0/11 to 0/14.</td>
<td>N/A</td>
<td>OK</td>
<td>OK</td>
</tr>
<tr>
<td>AS400</td>
<td>OK :<br>
- '-m RAM -s' to get all RAM<br>
- 'System ASP' : Disk<br>
</td>
<td>OK </td>
<td>OK</td>
<td>
<p>NO<br>
See check_snmp_storage</p>
</td>
<td>OK</td>
</tr>
<tr>
<td>LinkProof</td>
<td>N/A</td>
<td>OK</td>
<td>N/A</td>
<td>N/A</td>
<td>OK</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<hr>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>

2038
plugins/doc/index_commands.html Executable file

File diff suppressed because it is too large Load diff

471
plugins/doc/snmp_cpfw.html Executable file
View file

@ -0,0 +1,471 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp Checkpoint FW-1 check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_cpfw.pl</p>
<p class="SectionTitle"> Last update : April 19 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 some modules of
Checkpoint FW-1 filtering or management module :</p>
<p class="SectionBody">You can choose to check 1, 2, 3 or all 4 modules.
Each module will be checked independently and critical state will
be returned if one of them is not OK.</p>
<p class="SectionBody">- Firewall (on filtering firewall) : </p>
<p class="SectionBody">Checks policy state : must be installed<br>
Can check installed policy name : you mut provide the exact name
of the policy (-p = &lt;policy name&gt;)<br>
Can check connections : warning and maximum levels must be provided
( -c=&lt;warn&gt;,&lt;crit&gt;)</p>
<p class="SectionBody">- SVN</p>
<p class="SectionBody">Checks the svan status code (must be &quot;OK&quot;)
of SVN</p>
<p class="SectionBody">- Management</p>
<p class="SectionBody">Checks the management state (&quot;active&quot;)
and if management is alive.</p>
<p class="SectionBody">- High availability</p>
<p class="SectionBody">Checks the HA state : <br>
- &quot;active&quot; on IPSO &amp; master on SPLAT (default)<br>
- &quot;standby&quot; on SPLAT<br>
Use check_snmp_vrrp.pl for checks on active/standby or IPSO clusters
on IPSO<br>
Check the blocking state (&quot;OK&quot;)<br>
Checks the state of all HA softs, usually : Synchronization,Filter,
cphad and fwd.</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody">- On the Checkpoint Firewall : SNMP extentions
must be active</p>
<p class="SectionBody">- Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)</p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a><br>
</p>
<p class="SectionBody"><a href="check_snmp_cpfw.pl" class="SectionTitle">Dowload
lastest version : 1.2.1</a></p>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Get help
</td>
<td class="SectionBody" width="387">
<p>./check_snmp_cpfw.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">snmpv3 login</td>
<td class="SectionBody" width="387">./check_snmp_cpfw.pl -H 127.0.0.1
<b>-l login -x passwd .....</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check firewall / HA / SVN - for a HA filtering module -
</td>
<td class="SectionBody" width="387">
<p>./check_snmp_cpfw.pl -H 127.0.0.1 -C public <b>-swa</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p align="right">Result example :
</td>
<td class="SectionBody" width="387">
<p>FW : OK / SVN : OK / HA : OK / CPFW Status : OK</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check SVN/Mgmt - for a management -
</td>
<td class="SectionBody" width="387">
<p>./check_snmp_cpfw.pl -H 127.0.0.1 -C public <b>-sm</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<div align="right">Result example : </div>
</td>
<td class="SectionBody" width="387">SVN : OK / MGMT : OK / CPFW
Status : OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">Check policy
name </td>
<td class="SectionBody" width="387">./check_snmp_cpfw.pl -H 127.0.0.1
-C public <b>-w -p prod</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p align="right">Result example : </p>
</td>
<td class="SectionBody" width="387">FW : OK / CPFW Status : OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<div align="right">Same with another policy installed : </div>
</td>
<td class="SectionBody" width="387">FW : Policy installed : Standard
/ CPFW Status : CRITICAL</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">Check number
of active connection with performance data output</td>
<td class="SectionBody" width="387">./check_snmp_cpfw.pl -H 127.0.0.1
-C public <b>-w -c 1000,5000 -f</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<div align="right">Result example : </div>
</td>
<td class="SectionBody" width="387">FW : OK / CPFW Status : OK
| fw_connexions=340</td>
</tr>
</table>
<p class="SectionBody">&nbsp;</p>
<p class="NewsItemDate">Output of check_snmp_cpfw.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p class="SectionBody">SNMP Checkpoint FW-1 Monitor for Nagios
version 1.2.1<br>
GPL Licence, (c)2004-2007 - Patrick Proy
<p>Usage: ./check_snmp_cpfw.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt;
[-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
[-s] [-w [-p=pol_name] [-c=warn,crit]] [-m] [-a [standby]
] [-f] [-p &lt;port&gt;] [-t &lt;timeout&gt;] [-V]<br>
-v, --verbose<br>
print extra debugging information (including interface list
on the system)<br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies v1 protocol)<br>
2, --v2c<br>
Use snmp v2c<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default
md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des)
<br>
-s, --svn<br>
check for svn status<br>
-w, --fw<br>
check for fw status<br>
-a, --ha[=standby]<br>
check for ha status and node in &quot;active&quot; state<br>
If using SecurePlatform and monitoring a standby unit, put
&quot;standby&quot; too<br>
-m, --mgmt<br>
check for management status<br>
-p, --policy=POLICY_NAME<br>
check if installed policy is POLICY_NAME (must have -w)<br>
-c, --connexions=WARN,CRIT<br>
check warn and critical number of connexions (must have -w)<br>
-f, --perfparse, --perfdata<br>
performance data output (only works with -c)<br>
-P, --port=PORT<br>
SNMP port (Default 161)<br>
-t, --timeout=INTEGER<br>
timeout for SNMP (Default: Nagios default) <br>
-V, --version<br>
prints version number<br>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>

381
plugins/doc/snmp_css.html Executable file
View file

@ -0,0 +1,381 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp CSS check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_css.pl / check_snmp_css_main.pl</p>
<p class="SectionTitle"> Last update : Jan 22 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 CSS services state</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)<br>
</p>
<p class="SectionTitle">Checks </p>
<p class="SectionBody">This scripts checks status of the CSS services.</p>
<p class="SectionBody"><b class="SectionTitle">Select service(s)</b><br>
You select services you wan't to check with -n using regular expressions</p>
<p class="SectionBody"><b class="SectionTitle">Put thresholds</b><br>
You select the warning and critical levels for : &lt;num&gt;,&lt;resp&gt;,&lt;conn&gt;
<br>
num : minimum number of active &amp; alive service <br>
resp : average response time in ms<br>
conn : number of connexions </p>
<p class="SectionBody">You can choose not to put 1, 2 or 3 numbers.
<br>
If you set &quot;-w 3&quot; only the number of active services will
be checked.<br>
If you set &quot;-w 3,200&quot; only the number of active services
and response time will be checked.<br>
<br>
For no warnings, put -1 (ex : -w5,-1,3). <br>
When using negative numbers, dont put space after &quot;-w&quot;
: &quot;-w -1,100,6&quot; will not work, &quot;-w-1,100,6&quot;
will work.</p>
<p class="SectionBody"><b class="SectionTitle">-d option and check_snmp_css_main.pl</b></p>
<p class="SectionBody">This option is set to make the script read
the index from a file instead of on the CSS.</p>
<p class="SectionBody">The reason of this option is :<br>
- when you have a lot (&gt; 50) services on the CSS <br>
- you want to check 10 service group consisting of 5 services every
2 minutes.</p>
<p class="SectionBody">If you use check_snmp_css, then it will read
the index (50 oids) + checks 5 oids = 55 OID every 12 seconds in
average. This will heavily load the CSS.<br>
This is why I wrote check_snmp_css_main.pl. This script will get
the index of the CSS every 10 minutes for example (could be more)
as the index won't change often.<br>
Then the check_snmp_css will only have to check for the 5 oids every
12 seconds, which will reduce by about 10 the amount of snmp queries
!</p>
<p class="SectionBody">How to use it :</p>
<p class="SectionBody">Create a service with long inter-delay check
executing : </p>
<p class="SectionBody">check_snmp_css_main.pl -H &lt;host&gt; &lt;snmp
logins&gt; -2 -d /var/tmp<br>
<b>-2 </b>if for using snmpv2c (better to get a lot of data)<br>
<b>-d /var/tmp </b>is to put the temp file to a special directory
(default is /tmp).</p>
<p class="SectionBody">A file named : <b>Nagios_CSS_&lt;IP Address&gt;</b>
will be created</p>
<p class="SectionBody">Then you can use your check_snmp_css.pl script
just as before but adding the '<b>-d</b>' option with the temp directory
if not /tmp.</p>
<p class="SectionBody">If the Nagios_CSS_&lt;IP&gt; file is not created
when the check_snmp_css script runs, it will then return unknown
status.<br>
If the check_snmp_css_main.pl cannot read index, a warning will
be returned but the old index file will remain.</p>
<p class="SectionBody">A lockfile is created bye check_snmp_css_main.pl
when it writes it's file. The check_snmp_css script will wait until
the lock file is removed to read the index file. <br>
The lock file is named : <b>Nagios_CSS_&lt;IP Address&gt;.lock<br>
</b>The lock file format is simple: every line is in format <b>
<br>
&lt;OID&gt;:&lt;Service name&gt;</b> </p>
<p class="SectionBody">&nbsp;</p>
<p class="SectionBody"><a href="check_snmp_css.pl" class="SectionTitle">Dowload
lastest version of check_snmp_css.pl : 1.0</a></p>
<p class="SectionBody"><a href="check_snmp_css_main.pl" class="SectionTitle">Dowload
lastest version of check_snmp_css_main.pl : 1.0</a></p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Get help
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_css.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">Verbose output</td>
<td class="SectionBody" width="420">./check_snmp_css.pl -H &lt;IP&gt;
-C &lt;com&gt; <b>-v</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">snmpv3 login</td>
<td class="SectionBody" width="420">./check_snmp_css.pl -H 127.0.0.1
-l login -x passwd<b></b></td>
</tr>
</table>
<p class="NewsItemDate">Output of check_snmp_css.pl -h </p>
<table border="1" cellspacing="5" width="100">
<tr>
<td>
<pre>
SNMP Cisco CSS monitor for Nagios version 1.0
(c)2004-2006 Patrick Proy
Usage: ./check_snmp_css.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt; [-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
-n &lt;name&gt; [-d directory] [-w &lt;num&gt;,&lt;resp&gt;,&lt;conn&gt; -c &lt;num&gt;,&lt;resp&gt;,&lt;conn&gt;] [-p &lt;port&gt;] [-f] [-t &lt;timeout&gt;] [-V]
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-n, --name=&lt;name&gt;
regexp to select service
-w, --warning=&lt;num&gt;,&lt;resp&gt;,&lt;conn&gt;
Optional. Warning level for
- minimum number of active &amp; alive service
- average response time
- number of connexions
For no warnings, put -1 (ex : -w5,-1,3).
When using negative numbers, dont put space after &quot;-w&quot;
-d, --dir=&lt;directory to put file&gt;
Directory where the temp file with index, created by check_snmp_css_main.pl, can be found
If no directory is set, /tmp will be used
-c, --critical=&lt;num&gt;,resp&gt;,&lt;conn&gt;
Optional. Critical levels (-1 for no critical levels)
See warning levels.
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;
&lt;authproto&gt; : Authentication protocol (md5|sha : default md5)
&lt;privproto&gt; : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-f, --perfparse, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
</pre>
</td>
</tr>
</table>
<br>
<p class="NewsItemDate">Output of check_snmp_css_main.pl -h </p>
<table border="1" cellspacing="5" width="100">
<tr>
<td>
<pre>
SNMP Cisco CSS monitor MAIN script for Nagios version 1.0
GPL Licence, (c)2004-2006 Patrick Proy
Usage: ./check_snmp_css_main.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt; [-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
[-d directory] [-p &lt;port&gt;] [-t &lt;timeout&gt;] [-V]
-v, --verbose
print extra debugging information
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-d, --dir=&lt;directory to put file&gt;
Directory where temp file with index is written
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies v1 protocol)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;
&lt;authproto&gt; : Authentication protocol (md5|sha : default md5)
&lt;privproto&gt; : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
</pre>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>

370
plugins/doc/snmp_env.html Executable file
View file

@ -0,0 +1,370 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp env check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_env.pl</p>
<p class="SectionTitle"> Last update : April 19 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 environemental
parameters such as fan, power supply, temperature</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)<br>
</p>
<p class="SectionTitle">Checks </p>
<p class="SectionBody">The script will make the following checks depending
on host type.<br>
Either the threshold is directly set by the hardware manufacturer,
or you must set them with an option.</p>
<p class="SectionBody">This table shows what the script CAN check,
depending on hardware version the sensors might not be there.<br>
The script will return &quot;UNKNOWN&quot; if no sensors can be
found. </p>
<p class="SectionBody">If no option is specified in this table, it
means the script uses the threshold of the snmp table.</p>
<table width="100%" border="1">
<tr>
<td class="SectionTitle">Host type</td>
<td class="SectionTitle">Option</td>
<td class="SectionTitle">Power supply</td>
<td class="SectionTitle">Fan</td>
<td class="SectionTitle">Voltage</td>
<td class="SectionTitle">Temperature</td>
<td class="SectionTitle">Disks</td>
</tr>
<tr>
<td class="SectionBody">Cisco</td>
<td class="SectionBody">cisco</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">No (working on it)</td>
<td class="SectionBody">No (working on it)</td>
<td class="SectionBody">No</td>
</tr>
<tr>
<td class="SectionBody">Nokia Ipso</td>
<td class="SectionBody">nokia</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">No.</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">No</td>
</tr>
<tr>
<td class="SectionBody">Bluecoat</td>
<td class="SectionBody">bc</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes</td>
</tr>
<tr>
<td class="SectionBody">IronPort</td>
<td class="SectionBody">iron</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">Yes, option '-F' in RPM</td>
<td class="SectionBody">No</td>
<td class="SectionBody">Yes, option '-c' in Celcius</td>
<td class="SectionBody">No</td>
</tr>
<tr>
<td class="SectionBody">Foundry</td>
<td class="SectionBody">Foundry</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">No (bug in snmp agent)</td>
<td class="SectionBody">No</td>
<td class="SectionBody">Yes</td>
<td class="SectionBody">No</td>
</tr>
</table>
<p class="SectionBody">Note : Bluecoat provides an &quot;other&quot;
sensor which is tested also. But I never saw a Bluecoat reporting
it.</p>
<p class="SectionBody">&nbsp;</p>
<p class="SectionBody"><a href="check_snmp_env.pl" class="SectionTitle">Dowload
lastest version : 1.2</a></p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Get help
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_env.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">Verbose output</td>
<td class="SectionBody" width="420">./check_snmp_env.pl -H &lt;IP&gt;
-C &lt;com&gt; <b>-v</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">snmpv3 login</td>
<td class="SectionBody" width="420">./check_snmp_env.pl -H 127.0.0.1
-l login -x passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Check Cisco for all sensors
</td>
<td class="SectionBody" width="420">
<p class="SectionBody">./check_snmp_env.pl -H 127.0.0.1 -C public
<b>-T cisco</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">Check Nokia
for all sensors</td>
<td class="SectionBody" width="420">./check_snmp_env.pl -H 127.0.0.1
-C public <b>-T nokia</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">checks ironport
fans RPM &gt; 1500 and temp &lt; 70 deg celcius</td>
<td class="SectionBody" width="420">./check_snmp_env.pl -H 127.0.0.1
-C public <b>-T iron -F 1500 -c 70</b></td>
</tr>
</table>
<p class="NewsItemDate">Output of check_snmp_env.pl -h </p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p class="SectionBody"> <br>
SNMP environmental Monitor for Nagios version 1.2<br>
GPL Licence, (c)2006-2007 Patrick Proy
<p>Usage: ./check_snmp_env.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt;
[-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
[-p &lt;port&gt;] -T (cisco|nokia|bc|iron|foundry) [-F &lt;rpm&gt;]
[-c &lt;celcius&gt;] [-f] [-t &lt;timeout&gt;] [-V]<br>
-v, --verbose<br>
print extra debugging information <br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies v1 protocol)<br>
-2, --v2c<br>
Use snmp v2c<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default
md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des)
<br>
-P, --port=PORT<br>
SNMP port (Default 161)<br>
-T, --type=cisco|nokia|bc|iron|foundry<br>
Environemental check : <br>
cisco : voltage,temp,fan,power supply status<br>
will try to check everything present<br>
nokia : fan and power supply<br>
bc : fans, power supply, voltage, disks<br>
iron : fans, power supply, temp<br>
foundry : power supply, temp<br>
-F, --fan=&lt;rpm&gt;<br>
Minimum fan rpm value<br>
-c, --celcius=&lt;celcius&gt;<br>
Maximum temp in degree celcius<br>
-f, --perfparse, --perfdata<br>
Performance data output<br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5)<br>
-V, --version<br>
prints version number<br>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>

673
plugins/doc/snmp_int.html Executable file
View file

@ -0,0 +1,673 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0" height="1477">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top height="1452">
<tr>
<td class="ProgramTitle"> Snmp interface check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_int.pl</p>
<p class="SectionTitle"> Last update : May 24 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description :</p>
<p class="SectionBody">Checks by snmp (v1, v2c or v3) host interface
state and usage. <br>
<br>
Interfaces can be selected by regexp ( 'eth' will check eth0, eth1,
eth2, ...).<br>
If multiple interfaces are selected, all must be up to get an OK
result<br>
<b><br>
</b>Vérifie par snmp v1, v2c ou v3 l'&eacute;tat des interfaces
d'un h&ocirc;te, leur utilisation (bande passante, erreurs, pertes)
et sortir des informations de performances.<br>
Ce script permet d'utiliser des expressions r&eacute;guli&egrave;res
pour s&eacute;lectionner les interfaces : ex 'eth' va v&eacute;rifier
eth0, eth1, ...<br>
Il permet également de lister toutes les interfaces disponibles
sur la machine cible (option -v) pour voir leur nom en SNMP.<br>
<i>Pour les francophones, je ferais un manuel en Fran&ccedil;ais
quand j'aurais le temps... (et toute aide est bienvenue).</i><b><br>
</b><br>
<span class="SectionTitle">Standard checks</span><br>
</p>
<p class="SectionBody">The script will check interface operationnal
status using the MIB-II table. The interface is (are) selected by
the <b>-n </b>option.<br>
This option will be treated as a regular expression (eth will match
eth0, eth1, eth2...). You can disable this with the <b>-r </b>option
: the interface will be selected if it's description exactly matches
the name given by -n</p>
<p class="SectionBody">The interfaces are selected by their description
in the MIB-II table.<br>
<b>To see how interface looks like by snmp, you can list all of
them with the '-v' switch.</b><br>
</p>
<p class="SectionBody">The script will return OK if ALL interfaces
selected are UP, or CRITICAL if at least one interface is down.<br>
<br>
You can make the script return a OK value when all interfaces are
down (and CRITICAL when at least one is up) with the <b>-i </b>option.</p>
<p class="SectionBody">You can make the same tests on administrative
status instead with the <b>-a </b>option.</p>
<p class="SectionBody">If you have ISDN interface, and want that DORMANT state returns ok, put <strong>-D</strong>.</p>
<p class="SectionBody">To make output shorter, specially when you
have multiple interface, you can put the <b>-s</b> option. <br>
It will get only the first &lt;n&gt; caracters of the interface
descrition. If the number is negative then get the last &lt;n&gt;
caracters.</p>
<p class="SectionBody">Ex : EL20005 3Com Gigabit NIC (3C2000 Family)<br>
<b> -s 4 </b> will output : &quot;EL20&quot;.<br>
<b>-s -4</b> will output : &quot;ily)&quot;.</p>
<p class="SectionTitle">Performance output </p>
<p class="SectionBody"><b>-f </b>option : activate performance output
(default the In/out octet as a counter).<br>
<b>-e </b>option : in/out errors and discarded packets. -f must
also be set.<br>
-<b>S</b> option : Include speed in performance output in bits/s
as '&lt;interface_name&gt;_speed_bps'<br>
<b>-y </b>option : output performance data in % of interface speed<b><br>
-Y</b> option : output performance data in bits/s or Bytes/s (depending
on -B)</p>
<p class="SectionBody"><b>Note</b> : -y and -Y options need the usage
check to ba active (-k)</p>
<p class="SectionBody"><b>Warning</b> : the counters needed by -e
are not always available on all machines (ex Nokia IP)<br>
</p>
<p class="SectionBody"><span class="SectionTitle">Usage check (-k)
</span><br>
<br>
<br>
A temporary file will be created in &quot;/tmp&quot; by default
: this can be changed at the beginning of the script. <br>
The file name will be : tmp_Icinga_int.&lt;host IP&gt;.&lt;Interface
name&gt;. One file will be created by interface.<br>
<br>
The status UNKNOWN is returned when the script doesn't have enough
information (see -d option).<br>
<br>
You will have to tell the warning and critical levels, separated
with &quot;,&quot; and you can use decimal (ex : 10.3).<br>
For standard checks (no &quot;-q&quot; option) : <br>
-w <i>&lt;In warn&gt;</i>,<i>&lt;Out warn&gt;</i> -c <i>&lt;In warn&gt;</i>,<i>&lt;Out
warn&gt;<br>
</i>In warn : warning level for incomming traffic<br>
Out warn : warning level for outgoing traffic<br>
In crit : critical level for incomming traffic<br>
Out crit : critical level for outgoing traffic<br>
</p>
<p class="SectionBody">The unit for the check depends on the -B, -M
and -G option :</p>
<table border="0" cellpadding="2" cellspacing="3" width="276">
<tr>
<td class="SectionBody" width="111">&nbsp;</td>
<td class="SectionBody" width="66"><b> -B set</b></td>
<td class="SectionBody" width="75"><b>-B not set</b></td>
</tr>
<tr>
<td class="SectionBody" width="111"><b>-M &amp; -G not set</b></td>
<td class="SectionBody" width="66">
<div align="center">Kbps</div>
</td>
<td class="SectionBody" width="75">
<div align="center">KBps</div>
</td>
</tr>
<tr>
<td class="SectionBody" width="111"><b>-M set</b></td>
<td class="SectionBody" width="66">
<div align="center">Mbps</div>
</td>
<td class="SectionBody" width="75">
<div align="center">MBps</div>
</td>
</tr>
<tr>
<td class="SectionBody" width="111"><b>-G set</b></td>
<td class="SectionBody" width="66">
<div align="center">Gbps</div>
</td>
<td class="SectionBody" width="75">
<div align="center">GBps</div>
</td>
</tr>
</table>
<p class="SectionBody">It is possible to put warning and critical
levels with -b option.<br>
<b>0 means no warning or critical level checks</b></p>
<p class="SectionBody">When the extended checks are activated (-q
option), the warning levels are <br>
-w <i>&lt;In bytes&gt;</i>,<i>&lt;Out bytes&gt;</i>,<i>&lt;In error&gt;</i>,<i>&lt;Out
error&gt;,<i>&lt;In disc&gt;</i>,<i>&lt;Out disc&gt;</i></i> -c
<i>&lt;In warn&gt;</i>,<i>&lt;Out warn&gt;</i>, .....<br>
In error : warn/crit level in inboud <b>error/minute<br>
</b>Out error : warn/crit level in outbound error/minute<b> </b><br>
In disc : warn/crit level in inboud <b>discarded packets/minute<br>
</b>Out disc : warn/crit level in outbound discarded packets/minute<b>
</b><br>
</p>
<p class="SectionBody"><b>-k</b> : activates the standard usage feature<br>
<b>-q</b> : activates the extended usage<br>
<b>-d</b> : delta in seconds (default is 300s)<br>
<b>-w</b> : warning levels<br>
<b>-c</b> : critical levels<br>
</p>
<p class="SectionBody"><b>-d</b>: delta time<br>
You can put the delta time as an option : the &quot;delta&quot;
is the prefered time between two values that the script will use
to calculate the average Kbytes/s or error/min. The delta time should
(not must) be bigger than the check interval.<br>
Here is an example : Check interval of 2 minutes and delta of 4min</p>
<p class="SectionBody">T0 : value 1 : can't calculate usage<br>
T0+2 : value 2 : can't calculate usage<br>
T0+4 : value 3 : usage=(value3-value1)/((T0+4)-T0) <br>
T0+6 : value 4 : usage=(value4-value2)/((T0+6)-T0+2)<br>
(Yes I know TO+4-T0=4, it's just to explain..)<br>
.........</p>
<p class="SectionBody">The script will allow 10% less of the delta
and 300% more than delta as a correct interval. <br>
For example, with a delta of 5 minutes, the acceptable interval
will be between 4'30&quot; and 15 minutes.</p>
<p class="SectionBody"> <b>Msg size option </b>(<i>-o</i><b><i> </i></b>option)</p>
<p class="SectionBody">In case you get a &quot;ERROR: running table
: Message size exceeded maxMsgSize&quot; error, you may need to
adjust the maxMsgSize, i.e. the maximum size of snmp message with
the -o option. Try a value with the -o AND the -v option : the script
will output the actual value so you can add some octets to it with
the -o option.</p>
<p class="SectionBody"><b>--label option</b></p>
<p class="SectionBody">This option just put label before the speed
output :<br>
Without : eth1:UP (10.3Kbps/4.4Kbps), eth0:UP (10.9Kbps/16.4Kbps):2
UP: OK<br>
With : eth1:UP (in=14.4Kbps/out=6.2Kbps), eth0:UP (in=15.3Kbps/out=22.9Kbps):2
UP: OK<br>
</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)<br>
</p>
<p class="SectionBody"><a href="check_snmp_int.pl" class="SectionTitle">Dowload
latest version : 1.4.8</a></p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configuration
examples</a></p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<p class="SectionBody">If multiple interfaces are selected, all must
be up to get an OK result</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Get help
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">List all interfaces</td>
<td class="SectionBody" width="496">./check_snmp_int.pl -H 127.0.0.1
-C public -n zzzz <b>-v</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">snmpv3 login</td>
<td class="SectionBody" width="496">./check_snmp_int.pl -H 127.0.0.1
-l login -w passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Check eth0 interface is up
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl -H 127.0.0.1 -C public <b>-n eth0 -r</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Check that all eth interface are up
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl -H 127.0.0.1 -C public <b>-n eth </b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Check that all ppp interface are down
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl -H 127.0.0.1 -C public <b>-n ppp -i</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Check that all eth interface are administratively up
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl -H 127.0.0.1 -C public <b>-n eth -a</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">
<p>Check that FastEternet0/11 to 0/14 are up (Cisco)
</td>
<td class="SectionBody" width="496">
<p>./check_snmp_int.pl -H 127.0.0.1 -C public <b>-n &quot;Fast.*0.1[1234]&quot;</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="198">Check the eth0
usage <br>
Note : no critical inbound (0)</td>
<td class="SectionBody" width="496">./check_snmp_int.pl -H 127.0.0.1
-C public -n eth0 <b>-k -w 200,400 -c 0,600</b></td>
</tr>
</table>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="NewsItemDate">Output of check_snmp_int.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p>SNMP Network Interface Monitor for Nagios version 1.4.8<br>
GPL licence, (c)2004-2007 Patrick Proy</p>
<p>Usage: ./check_snmp_int.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt; [-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;) [-p &lt;port&gt;] -n &lt;name in desc_oid&gt; [-i -a -D] [-r] [-f[eSyY]] [-k[qBMGu] -g -w&lt;warn levels&gt; -c&lt;crit levels&gt; -d&lt;delta&gt;] [-o &lt;octet_length&gt;] [-t &lt;timeout&gt;] [-s] --label [-V]<br>
-v, --verbose<br>
print extra debugging information (including interface list on the system)<br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies v1 protocol)<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD, -2, --v2c<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-2 : use snmp v2c<br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des) <br>
-P, --port=PORT<br>
SNMP port (Default 161)<br>
-n, --name=NAME<br>
Name in description OID (eth0, ppp0 ...).<br>
This is treated as a regexp : -n eth will match eth0,eth1,...<br>
Test it before, because there are known bugs (ex : trailling /)<br>
-r, --noregexp<br>
Do not use regexp to match NAME in description OID<br>
-i, --inverse<br>
Make critical when up<br>
-a, --admin<br>
Use administrative status instead of operational<br>
-D, --dormant<br>
Dormant state is an OK state<br>
-o, --octetlength=INTEGER<br>
max-size of the SNMP message, usefull in case of Too Long responses.<br>
Be carefull with network filters. Range 484 - 65535, default are<br>
usually 1472,1452,1460 or 1440. <br>
-f, --perfparse, --perfdata<br>
Performance data output (no output when interface is down).<br>
-e, --error<br>
Add error &amp; discard to Perfparse output<br>
-S, --intspeed<br>
Include speed in performance output in bits/s<br>
-y, --perfprct ; -Y, --perfspeed<br>
-y : output performance data in % of max speed <br>
-Y : output performance data in bits/s or Bytes/s (depending on -B) <br>
-k, --perfcheck ; -q, --extperfcheck <br>
-k check the input/ouput bandwidth of the interface<br>
-q also check the error and discard input/output<br>
--label<br>
Add label before speed in output : in=, out=, errors-out=, etc...<br>
-g, --64bits<br>
Use 64 bits counters instead of the standard counters when checking <br>
bandwidth &amp; performance data for interface &gt;= 1Gbps.<br>
You must use snmp v2c or v3 to get 64 bits counters.<br>
-d, --delta=seconds<br>
make an average of &lt;delta&gt; seconds (default 300=5min)<br>
-B, --kbits<br>
Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s<br>
-G, --giga ; -M, --mega ; -u, --prct<br>
-G : Make the warning and critical levels in Gbps (with -B) or GBps<br>
-M : Make the warning and critical levels in Mbps (with -B) or MBps<br>
-u : Make the warning and critical levels in % of reported interface speed.<br>
-w, --warning=input,output[,error in,error out,discard in,discard out]<br>
warning level for input / output bandwidth (0 for no warning)<br>
unit depends on B,M,G,u options<br>
warning for error &amp; discard input / output in error/min (need -q)<br>
-c, --critical=input,output[,error in,error out,discard in,discard out]<br>
critical level for input / output bandwidth (0 for no critical)<br>
unit depends on B,M,G,u options<br>
critical for error &amp; discard input / output in error/min (need -q)<br>
-s, --short=int<br>
Make the output shorter : only the first &lt;n&gt; chars of the interface(s)<br>
If the number is negative, then get the &lt;n&gt; LAST caracters.<br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5) <br>
-V, --version<br>
prints version number<br>
Note : when multiple interface are selected with regexp, <br>
all be must be up (or down with -i) to get an OK result.</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

409
plugins/doc/snmp_load.html Executable file
View file

@ -0,0 +1,409 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp load check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_load.pl</p>
<p class="SectionTitle"> Last update : Sept 5 2006</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 cpu or average
load. <br>
Works on Windows, Linux/Unix, AS400, Cisco, Cisco catalyst, HP Procurve, LinkProof,
Blucoat, Nokia, Fortinet, Netscreen.</p>
<p class="SectionBody">Check types are selected by the -T option :
</p>
<table border="1">
<tr>
<td class="SectionTitle">
<div align="center">-T value</div>
</td>
<td class="SectionTitle">
<div align="center">System </div>
</td>
<td class="SectionTitle">
<div align="center">-w &amp; -c values</div>
</td>
</tr>
<tr>
<td class="SectionBody"><b>netsl</b></td>
<td class="SectionBody">Linux : load provided by Net SNMP</td>
<td class="SectionBody">3 values : load average on 1 min, 5 min,
15 min (absolute)</td>
</tr>
<tr>
<td class="SectionBody"><b>netsc</b></td>
<td class="SectionBody">Linux : CPU usage given by net-snmp</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>as400</b></td>
<td class="SectionBody">as400 CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>cisco</b></td>
<td class="SectionBody">cisco CPU usage</td>
<td class="SectionBody">3 values : CPU average on 5sec, 1 min
&amp; 5 min (%)</td>
</tr>
<tr>
<td class="SectionBody"><b>cata</b></td>
<td class="SectionBody">cisco catalyst CPU usage</td>
<td class="SectionBody">3 values : CPU average on 5sec, 1 min
&amp; 5 min (%)</td>
</tr>
<tr>
<td class="SectionBody"><b>nsc</b></td>
<td class="SectionBody">Netscreen CPU usage</td>
<td class="SectionBody">3 values : CPU average on 5sec, 1 min
&amp; 5 min (%)</td>
</tr>
<tr>
<td class="SectionBody"><b>fg</b></td>
<td class="SectionBody">Fortigate CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>bc</b></td>
<td class="SectionBody">bluecoat CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>nokia</b></td>
<td class="SectionBody">nokia CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>hp</b></td>
<td class="SectionBody">HP procurve switch CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>lp</b></td>
<td class="SectionBody">Linkproof CPU usage</td>
<td class="SectionBody">1 value in %</td>
</tr>
<tr>
<td class="SectionBody"><b>hpux</b></td>
<td class="SectionBody">HP-UX load</td>
<td class="SectionBody">3 values : load average on 1 min, 5 min,
15 min</td>
</tr>
</table>
<p class="SectionBody"> V&eacute;rifie par snmp v1,v2c ou v3 la charge
ou l'ocupation CPU.</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory<br>
</p>
<p class="SectionBody"><a href="check_snmp_load.pl" class="SectionTitle">Dowload
lastest version : 1.3.1</a> </p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="SectionTitle"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<p class="SectionBody">If multiple interfaces are selected, all must
be up to get an OK result</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Get help
</td>
<td class="SectionBody">
<p>./check_snmp_load.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check loads on linux with Net-SNMP : checks the 1, 5 and
15 minutes load average.
</td>
<td class="SectionBody">
<p>./check_snmp_load.pl -H 127.0.0.1 -C public <b>-w 3,3,2 -c
4,4,3 -T netsl</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check cpu load (generic) : checks the %used CPU for the last
minute
</td>
<td class="SectionBody">
<p>./check_snmp_load.pl -H 127.0.0.1 -C public <b>-w 98% -c
99%</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check cpu load on AS/400
</td>
<td class="SectionBody">
<p>./check_snmp_load.pl -H 127.0.0.1 -C public <b>-w 98% -c
99% -T as400</b></p>
</td>
</tr>
</table>
<p class="NewsItemDate">Output of check_snmp_load.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
SNMP Load &amp; CPU Monitor for Nagios version 1.3<br>
(c)2004-2006 Patrick Proy
<p>Usage: ./check_snmp_load.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt;
[-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
[-p &lt;port&gt;] -w &lt;warn level&gt; -c &lt;crit level&gt;
-T=[stand|netsl|netsc|as400|cisco|cata|nsc|fg|bc|nokia|hp|lp]
[-f] [-t &lt;timeout&gt;] [-V]<br>
-v, --verbose<br>
print extra debugging information <br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies v1 protocol)<br>
-2, --v2c<br>
Use snmp v2c<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default
md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des)
<br>
-P, --port=PORT<br>
SNMP port (Default 161)<br>
-w, --warn=INTEGER | INT,INT,INT<br>
1 value check : warning level for cpu in percent (on one minute)<br>
3 value check : comma separated level for load or cpu for
1min, 5min, 15min <br>
-c, --crit=INTEGER | INT,INT,INT<br>
critical level for cpu in percent (on one minute)<br>
1 value check : critical level for cpu in percent (on one
minute)<br>
3 value check : comma separated level for load or cpu for
1min, 5min, 15min <br>
-T, --type=stand|netsl|netsc|as400|cisco|bc|nokia|hp|lp<br>
CPU check : <br>
stand : standard MIBII (works with Windows), <br>
can handle multiple CPU.<br>
netsl : linux load provided by Net SNMP<br>
netsc : cpu usage given by net-snmp (100-idle)<br>
as400 : as400 CPU usage<br>
cisco : Cisco CPU usage<br>
cata : Cisco catalyst CPU usage<br>
nsc : NetScreen CPU usage<br>
fg : Fortigate CPU usage<br>
bc : Bluecoat CPU usage<br>
nokia : Nokia CPU usage<br>
hp : HP procurve switch CPU usage<br>
lp : Linkproof CPU usage<br>
-f, --perfparse, --perfdata<br>
Performance data output<br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5)<br>
-V, --version<br>
prints version number</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

485
plugins/doc/snmp_mem.html Executable file
View file

@ -0,0 +1,485 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<!-- background="img/sideback.jpg" -->
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp memory check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_mem.pl</p>
<p class="SectionTitle"> Last update : Sept 4 2006</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 :</p>
<p class="SectionBody">- Memory and swap usage on Linux given by Net-snmp.
<br>
It checks memory and swap usage independantly : one warning and
critical level for each of them.<br>
</p>
<p class="SectionBody">- Memory usage on cisco routers or Pix : the
plugin will add all of the memory pool and then checks the warning
and critical levels.<br>
On cisco routeurs, it will add 'IO' and 'Processor' memory<br>
On Pix, it will check the memory used (one memory pool only on Pix).<br>
</p>
<p class="SectionBody">- Memory usage on HP Procurve switch.<br>
Memory segments will be added then the free memory will be checked.<br>
</p>
<p class="SectionBody">V&eacute;rification de :<br>
- l'utilisation m&eacute;moire et swap sur Linux/Net-snmp<br>
- l'utilisation m&eacute;moire sur Cisco (routeurs et Pix).<br>
Pour d'autres SE (Windows, AS400), lire la suite.</p>
<p class="SectionTitle">Checking memory for other os :</p>
<p class="SectionBody"><b>AS/400 : </b>use the check_snmp_storage
command to check the RAM</p>
<p class="SectionBody">./check_snmp_storage.pl -H <b>&lt;IP&gt;</b>
-C <b>&lt;community&gt;</b> -m RAM -s -w <b>&lt;warn%&gt;</b> -c
<b>&lt;crit%&gt;</b></p>
<p class="SectionBody"><b>Windows : </b>use the check_snmp_storage
command to check the virtual memory (RAM+Swap)</p>
<p class="SectionBody">./check_snmp_storage.pl -H <b>&lt;IP&gt;</b>
-C <b>&lt;community&gt;</b> -m &quot;^Virtual Memory$&quot; -w <b>&lt;warn%&gt;</b>
-c <b>&lt;crit%&gt;</b></p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory (/usr/local/icinga/libexec)<br>
</p>
<p class="SectionBody"><a href="check_snmp_mem.pl" class="SectionTitle">Dowload
lastest version : 1.1</a> </p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Get help
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_mem.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">Verbose output</td>
<td class="SectionBody" width="420">./check_snmp_mem.pl -H &lt;IP&gt;
-C &lt;com&gt; -w 80 -c 81 <b>-v</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">snmpv3 login</td>
<td class="SectionBody" width="420">./check_snmp_mem.pl -H 127.0.0.1
-l login -x passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>&nbsp;
</td>
<td class="SectionBody" width="420">
<p class="NewsItemDate">Unix/Linux</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>%used of <br>
- RAM &lt; 99% and 100%<br>
- Swap : &lt; 20% and 30%
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_mem.pl -H &lt;IP&gt; -C &lt;com&gt; <b> -w 99,20
-c 100,30</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Same with no warning levels for memory
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_mem.pl -H &lt;IP&gt; -C &lt;com&gt; -w <b>0</b>,20
-c 100,30</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="154">
<p>Check memory on Cisco
</td>
<td class="SectionBody" width="420">
<p>./check_snmp_mem.pl -H &lt;IP&gt; -C &lt;com&gt; <b>-I -w
90% -c 98%</b></p>
</td>
</tr>
</table>
<p class="NewsItemDate">Output of check_snmp_mem.pl -h &lt;</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p class="SectionBody">
<pre>
SNMP Memory Monitor for Nagios version 1.1
(c)2004-2006 - Patrick Proy
Usage: ./check_snmp_mem.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt; [-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;]) [-p &lt;port&gt;] -w &lt;warn level&gt; -c &lt;crit level&gt; [-I|-N|-E] [-f] [-m] [-t &lt;timeout&gt;] [-V]
-v, --verbose
print extra debugging information (including interface list on the system)
-h, --help
print this help message
-H, --hostname=HOST
name or IP address of host to check
-C, --community=COMMUNITY NAME
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
-2, --v2c
Use snmp v2c
-l, --login=LOGIN ; -x, --passwd=PASSWD
Login and auth password for snmpv3 authentication
If no priv password exists, implies AuthNoPriv
-X, --privpass=PASSWD
Priv password for snmpv3 (AuthPriv protocol)
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;
&lt;authproto&gt; : Authentication protocol (md5|sha : default md5)
&lt;privproto&gt; : Priv protocole (des|aes : default des)
-P, --port=PORT
SNMP port (Default 161)
-w, --warn=INTEGER | INT,INT
warning level for memory in percent (0 for no checks)
Default (-N switch) : comma separated level for Real Memory and Swap
-I switch : warning level
-c, --crit=INTEGER | INT,INT
critical level for memory in percent (0 for no checks)
Default (-N switch) : comma separated level for Real Memory and Swap
-I switch : critical level
-N, --netsnmp (default)
check linux memory & swap provided by Net SNMP
-m, --memcache
include cached memory in used memory (only with Net-SNMP)
-I, --cisco
check cisco memory (sum of all memory pools)
-E, --hp
check HP proccurve memory
-f, --perfdata
Performance data output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
</pre>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>

377
plugins/doc/snmp_process.html Executable file
View file

@ -0,0 +1,377 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp process check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_process.pl</p>
<p class="SectionTitle"> Last update : Jun 09 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1 or v3 if a process is running
and how many instances are running (minimum &amp; maximum). <br>
It is also possible to check memory and cpu used by one or a group
of process<br>
<br>
Works on Windows, Linux/Unix, AS400.</p>
<p class="SectionBody"> Vérifie par snmp v1 ou v3 si un process tourne
et combien d'instances de ce process tournent (minimum et maximum).<br>
Il est &eacute;galement possible de v&eacute;rifier la m&eacute;moire
et le cpu utilis&eacute;.<br>
<br>
<span class="SectionTitle"> Standard checks<br>
</span></p>
<p class="SectionBody">The plugin checks if there is at least one
process matching the filter (<b>-n </b>option) when no warning or
critical levels are set. <br>
The filter is treated as a regular expression by default, but you
can deactivate this (<b>-r</b>)</p>
<p class="SectionBody">With the following options, you can add to your process selection : </p>
<p class="SectionBody">-f : get full path of the script instead of only it's name</p>
<p class="SectionBody">-A : add parameters with the script name</p>
<table border="1">
<tr>
<th class="SectionBody" scope="col">Option</th>
<th class="SectionBody" scope="col">how the script will see the process </th>
</tr>
<tr>
<td class="SectionBody">None</td>
<td><span class="SectionBody">named</span></td>
</tr>
<tr>
<td class="SectionBody">-f</td>
<td><span class="SectionBody">/usr/sbin/named</span></td>
</tr>
<tr>
<td class="SectionBody">-A</td>
<td><span class="SectionBody">named -u named -t /var/named/chroot</span></td>
</tr>
<tr>
<td class="SectionBody">-f -A </td>
<td><span class="SectionBody">/usr/sbin/named -u named -t /var/named/chroot</span></td>
</tr>
</table>
<p class="SectionBody">Warning : the -f &amp; -A option will not function properly for Windows hosts (the snmp agent don't give this information)</p>
<p class="SectionBody"> You can use -w and -c options to set the warning
and critical levels : <br>
<b>-w &lt;minW&gt;,&lt;maxW&gt; </b>: with minW and maxW the minimum
and maximum number of processes.<br>
<br>
<b>-c &lt;minC&gt;,&lt;maxC&gt;</b> : same thing<br>
Of course : <b>minC &lt;= minW &lt; maxW &lt;=maxC</b><br>
<i><br>
You can omit &lt;maxW&gt; and &lt;maxC&gt;</i><br>
<br>
Saying N is the current number of processes<br>
- N &lt; minC : critical<br>
- minC &lt; N &lt;=minW : warning<br>
- minW&lt; N &lt;= maxW : OK<br>
- maxW&lt; N &lt;= maxC : warning<br>
- maxC &lt; N : critical<br>
</p>
<p class="SectionTitle">Memory checks </p>
<p class="SectionBody">The <b>-m </b>option can check the memory used
by the selected processes.<br>
By default, this will select the process wich use the maximum memory.
The <b>-a</b> switch will make an average<br>
<br>
Ex : <b>-m 7,20 </b>will send a warning if a process uses more than
7 Mb, and critical for more than 20Mb.</p>
<p class="SectionTitle">CPU checks</p>
<p class="SectionBody">When you use the <b>-u </b>option, a temporary
file will be created in &quot;/tmp&quot; by default : this can be
changed at the beginning of the script. <br>
The file name will be : tmp_Icinga_proc.&lt;host IP&gt;.&lt;process
filter&gt;.</p>
<p class="SectionBody">The -u option will add all the cpu used by
all selected process and the make the check<br>
</p>
<p class="SectionBody"><b>-u 91,95</b> : will send a warning if more
than 91% of cpu is used, and critical if more than 95% is used.</p>
<p class="SectionBody">On multiprocessor hosts, the % of cpu use can
be &gt; 100% : on a 4 CPU host, cpu usage can go up to 400% (the
script doesn't check if a host is multiprocessor or not).</p>
<p class="SectionBody">The script curently wants a minimum of 5 minutes
between values taken from host (can be changed at the beginning
of the scripts). You can check more than once every 5 minutes but
don't put check-interval to more than 15 minutes.<br>
When the script doesn't have enough data to compute the CPU use
(for example, the first time it is run), then it will return a UNKNOWN
status. </p>
<p class="SectionBody"><b>Msg size option </b>(<i>-o</i><b><i> </i></b>option)</p>
<p class="SectionBody">In case you get a &quot;ERROR: running table
: Message size exceeded maxMsgSize&quot; error, you may need to
adjust the maxMsgSize, i.e. the maximum size of snmp message with
the -o option. Try a value with the -o AND the -v option : the script
will output the actual value so you can add some octets to it with
the -o option.</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory<br>
</p>
<p class="SectionBody"><a href="check_snmp_process.pl" class="SectionTitle">Dowload
latest version : 1.5</a> </p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="SectionBody"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<p class="SectionBody">If multiple interfaces are selected, all must
be up to get an OK result</p>
<table border="1" cellspacing="5" width="819">
<tr>
<td class="NewsItemDate" valign = top width="261">
<p>Get help
</td>
<td class="SectionBody" width="533">
<p>./check_snmp_process.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">snmpv3 login</td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -l login -x passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">
<p>Check if at least one process matching http is running
</td>
<td class="SectionBody" width="533">
<p>./check_snmp_process.pl -H 127.0.0.1 -C public <b>-n http</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">
<p align="right">Result example :
</td>
<td class="SectionBody" width="533">
<p>3 process matching http : &gt; 0 : OK</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">
<p>Check if at least 3 process matching http are running
</td>
<td class="SectionBody" width="533">
<p>./check_snmp_process.pl -H 127.0.0.1 -C public -n http<b>
-w 2 -c 0</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">
<div align="right">Result example : <br>
(&lt;=2 will return warning, 0 critical)</div>
</td>
<td class="SectionBody" width="533">3 process matching httpd :
&gt; 2 : OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">Check if at
least one process named &quot;httpd&quot; exists (no regexp)</td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -C public -n http <b>-r</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">
<p align="right">Result example : </p>
</td>
<td class="SectionBody" width="533">3 process <b>named</b> httpd
: &gt; 0 : OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">Check process
by their full path : check process of /opt/soft/bin/ (at least
one) </td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -C public <b>-n /opt/soft/bin/ -f</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">Check that at
least 3 process but not more than 8 are running</td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -C public -n http <b>-w 3,8 -c 0,15</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">Same checks
+ checks maximum memory used by process (in Mb) : warning and
critical levels</td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -C public -n http -w 3,8 -c 0,15 <b>-m 9,25</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="261">Same check but
sum all CPU used by all selected process</td>
<td class="SectionBody" width="533">./check_snmp_process.pl -H
127.0.0.1 -C public -n http -w 3,8 -c 0,15 -m 9,25 <b>-u 70,99</b></td>
</tr>
</table>
<p class="NewsItemDate">Output of check_snmp_process.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p>SNMP Process Monitor for Nagios version 1.5<br>
GPL licence, (c)2004-2006 Patrick Proy</p>
<p>Usage: ./check_snmp_process.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt; [-2] | (-l login -x passwd) [-p &lt;port&gt;] -n &lt;name&gt; [-w &lt;min_proc&gt;[,&lt;max_proc&gt;] -c &lt;min_proc&gt;[,max_proc] ] [-m&lt;warn Mb&gt;,&lt;crit Mb&gt; -a -u&lt;warn %&gt;,&lt;crit%&gt; -d&lt;delta&gt; ] [-t &lt;timeout&gt;] [-o &lt;octet_length&gt;] [-f -A -F ] [-r] [-V] [-g]<br>
-v, --verbose<br>
print extra debugging information (and lists all storages)<br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies SNMP v1 or v2c with option)<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD, -2, --v2c<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-2 : use snmp v2c<br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des) <br>
-p, --port=PORT<br>
SNMP port (Default 161)<br>
-n, --name=NAME<br>
Name of the process (regexp)<br>
No trailing slash !<br>
-r, --noregexp<br>
Do not use regexp to match NAME in description OID<br>
-f, --fullpath<br>
Use full path name instead of process name <br>
(Windows doesn't provide full path name)<br>
-A, --param<br>
Add parameters to select processes.<br>
ex : &quot;named.*-t /var/named/chroot&quot; will only select named process with this parameter <br>
-F, --perfout<br>
Add performance output<br>
outputs : memory_usage, num_process, cpu_usage<br>
-w, --warn=MIN[,MAX]<br>
Number of process that will cause a warning <br>
-1 for no warning, MAX must be &gt;0. Ex : -w-1,50<br>
-c, --critical=MIN[,MAX]<br>
number of process that will cause an error (<br>
-1 for no critical, MAX must be &gt;0. Ex : -c-1,50<br>
Notes on warning and critical : <br>
with the following options : -w m1,x1 -c m2,x2<br>
you must have : m2 &lt;= m1 &lt; x1 &lt;= x2<br>
you can omit x1 or x2 or both<br>
-m, --memory=WARN,CRIT<br>
checks memory usage (default max of all process)<br>
values are warning and critical values in Mb<br>
-a, --average<br>
makes an average of memory used by process instead of max<br>
-u, --cpu=WARN,CRIT<br>
checks cpu usage of all process<br>
values are warning and critical values in % of CPU usage<br>
if more than one CPU, value can be &gt; 100% : 100%=1 CPU<br>
-d, --delta=seconds<br>
make an average of &lt;delta&gt; seconds for CPU (default 300=5min) <br>
-g, --getall<br>
In some cases, it is necessary to get all data at once because<br>
process die very frequently.<br>
This option eats bandwidth an cpu (for remote host) at breakfast.<br>
-o, --octetlength=INTEGER<br>
max-size of the SNMP message, usefull in case of Too Long responses.<br>
Be carefull with network filters. Range 484 - 65535, default are<br>
usually 1472,1452,1460 or 1440. <br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5)<br>
-V, --version<br>
prints version number<br>
Note : <br>
CPU usage is in % of one cpu, so maximum can be 100% * number of CPU <br>
example : <br>
Browse process list : &lt;script&gt; -C &lt;community&gt; -H &lt;host&gt; -n &lt;anything&gt; -v <br>
the -n option allows regexp in perl format : <br>
All process of /opt/soft/bin : -n /opt/soft/bin/ -f<br>
All 'named' process : -n named<br>
<br>
</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

1330
plugins/doc/snmp_storage.html Executable file

File diff suppressed because it is too large Load diff

358
plugins/doc/snmp_vrrp.html Executable file
View file

@ -0,0 +1,358 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp vrrp check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_vrrp.pl</p>
<p class="SectionTitle"> Last update : Sept 4 2006</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1, v2c or v3 the vrrp status
of all vrrp enabled interfaces. <br>
Works on<br>
- Nokia IP with ipso 3.X , 4.X in VRRP mode.<br>
- Nokia IP with ipso 3.X , 4.X in clustering mode.<br>
- Radware Linkproof<br>
- Alteon AD4 Loadbalancers</p>
<p class="SectionBody">Depending on the state you put as option (&quot;master&quot;
or &quot;backup&quot;) the script will get all the vrrp enables
interface and check they are in this state. <br>
If not, it will retrun a critical status<br>
By default, it will check Nokia IP platforms using vrrp, you can
test other platforms with the '-T' option :<br>
<br>
- Alteon<br>
- Linkproof (VRRP)<br>
- Nokia clustering.</p>
<p class="SectionTitle">Nokia clustering check</p>
<p class="SectionBody">Nokia clustering check does not have a master
&amp; backup state. Instead, the plugin will check : </p>
<p class="SectionBody">- The number of cluster member<br>
- The % load on each cluster.</p>
<p class="SectionBody">For example <b>-s 2,90</b> will issue <br>
- A critical level if there is not 2 members.<br>
- A warning level if more than 90% is assigned to one cluster member.</p>
<p class="SectionBody">To have a long output, put the '-g' option.</p>
<p class="SectionBody"><span class="SectionTitle">SNMP Login</span><br>
</p>
<p class="SectionBody">See <a href="index_info.html">snmp info page</a></p>
<p class="SectionBody"><span class="SectionTitle">French </span>:
Vérifie par snmp v1 ou v3 l'&eacute;tat des interfaces vrrp : Nokia,
Linkproof, Alt&eacute;on ou l'&eacute;tat d'un cluster Nokia.</p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory<br>
</p>
<p class="SectionBody"><a href="check_snmp_vrrp.pl" class="SectionTitle">Dowload
lastest version : 1.3</a> </p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<p class="SectionBody">If multiple interfaces are selected, all must
be up to get an OK result</p>
<table border="1" cellspacing="5">
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Get help
</td>
<td class="SectionBody" width="387">
<p>./check_snmp_vrrp.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">snmpv3 login</td>
<td class="SectionBody" width="387">./check_snmp_vrrp.pl -H 127.0.0.1
-l login -x passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p>Check vrrp state of a node to be master.
</td>
<td class="SectionBody" width="387">
<p>./check_snmp_vrrp.pl -H 127.0.0.1 -C public <b>-s master</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<div align="right">
<p>Output example :<br>
The ouput is : &lt;vrid&gt;(&lt;state&gt;,&lt;status&gt;,&lt;priority&gt;)
</p>
</div>
</td>
<td class="SectionBody" width="387">Vrid : 10(master/up/100),
1(master/up/100), 3(master/up/100), 2(master/up/100), : All
master :OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">Check vrrp state
of a node to be backup. </td>
<td class="SectionBody" width="387">./check_snmp_vrrp.pl -H 127.0.0.1
-C public <b>-s backup</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">
<p align="right">Output example :
</td>
<td class="SectionBody" width="387">
<p>Vrid : 1(backup/up/95), 3(backup/up/95), 10(backup/up/95),
2(backup/up/95), : All backup :OK</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">Test a Linkproof</td>
<td class="SectionBody" width="387">./check_snmp_vrrp.pl -H 127.0.0.1
-C public -s master <b>-T lp</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="282">Test a Nokia
cluster : 2 cluster members and max 90% load assigned to one
cluster. </td>
<td class="SectionBody" width="387">./check_snmp_vrrp.pl -H 127.0.0.1
-C public <b>-s 2,90%-T ipso</b></td>
</tr>
</table>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.</p>
<p class="NewsItemDate">Output of check_snmp_vrrp.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p class="SectionBody">SNMP VRRP Monitor for Nagios version
1.3<br>
(c)2004-2006 to my cat Ratoune - Author : Patrick Proy
<p>Usage: ./check_snmp_vrrp.pl [-v] -H &lt;host&gt; -C &lt;snmp_community&gt;
[-2] | (-l login -x passwd [-X pass -L &lt;authp&gt;,&lt;privp&gt;])
-s &lt;master|backup|num,%&gt; [-T &lt;nokia|alteon|lp|nsc|ipsocluster&gt;]
[-p &lt;port&gt;] [-t &lt;timeout&gt;] [-V]<br>
-v, --verbose<br>
print extra debugging information (including interface list
on the system)<br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies v1 protocol)<br>
-2, --v2c<br>
Use snmp v2c<br>
-l, --login=LOGIN ; -x, --passwd=PASSWD<br>
Login and auth password for snmpv3 authentication <br>
If no priv password exists, implies AuthNoPriv <br>
-X, --privpass=PASSWD<br>
Priv password for snmpv3 (AuthPriv protocol)<br>
-L, --protocols=&lt;authproto&gt;,&lt;privproto&gt;<br>
&lt;authproto&gt; : Authentication protocol (md5|sha : default
md5)<br>
&lt;privproto&gt; : Priv protocole (des|aes : default des)
<br>
-P, --port=PORT<br>
SNMP port (Default 161)<br>
-T, --type=&lt;nokia|alteon|lp|nsc|ipso&gt;<br>
Type of vrrp router to check<br>
nokia (default) : Nokai vrrp. Should be working for most vrrp
routers<br>
alteon : for Alteon AD4 Loadbalancers<br>
lp : Radware Linkproof<br>
nsc : Nescreen (ScreenOS 5.x NSRP)<br>
ipso : Nokia IPSO clustering<br>
-s, --state=master|backup|num,%<br>
Nokia ipso clustering : number of members, max % assigned
to nodes.<br>
Other : check vrrp interface to be master or backup<br>
-g, --long<br>
Make output long even is all is OK <br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5)<br>
-V, --version<br>
prints version number</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

261
plugins/doc/snmp_windows.html Executable file
View file

@ -0,0 +1,261 @@
<HTML>
<HEAD>
<TITLE>Nagios plugins</TITLE>
<META NAME="Keywords" CONTENT="nagios,plugins,perl,snmp,proy">
<STYLE type="text/css">
<!--
.Default { font-family: verdana,arial,serif; font-size: 10pt; }
.ProgramTitle { font-family: verdana,arial,serif; font-size: 18pt; font-weight: bold;}
.Copyright { font-family: verdana,arial,serif; font-size: 10pt;}
.Email { font-family: verdana,arial,serif; font-size: 10pt;}
.NewsItem { font-family: verdana,arial,serif; font-size: 8pt; }
.NewsItemOdd { font-family: verdana,arial,serif; font-size: 8pt; background-color: #DBDBDB;}
.NewsItemEven { font-family: verdana,arial,serif; font-size: 8pt; background-color: #C4C2C2;}
.NewsItemUrgent { font-family: verdana,arial,serif; font-size: 8pt; background-color: #ccff99;}
.NewsItemDate { font-family: verdana,arial,serif; font-size: 8pt; font-weight: bold; }
.SectionTitle { font-family: verdana,arial,serif; font-size: 9pt; font-weight: bold; text-decoration: underline;}
.SectionBody { font-family: verdana,arial,serif; font-size: 8pt; }
.ModificationDate { font-family: verdana,arial,serif; font-size: 7pt; }
.Disclaimer { font-family: verdana,arial,serif; font-size: 8pt; }
A.SideNavBarItem { font-family: verdana,arial,serif; background-color : black; color: #e7e7e7; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem { font-family: verdana,arial,serif; background-color : black; color: #ffcc66; font-size: 9pt; font-weight: bold; text-decoration: none; }
A.SideNavBarHotItem:Hover { font-family: verdana,arial,serif; background-color : black; color: #ccff33; font-size: 9pt; font-weight: bold; text-decoration: none; }
-->
</STYLE>
</HEAD>
<body background="img/sideback.jpg" bgcolor="#FFFFFF" text="black" class="Default">
<table border="0">
<tr>
<td valign=top>
<!-- Begin Side Bar -->
<table border="0" width="125" valign=top>
<tr>
<td><a href="http://nagios.manubulon.com/" class="SideNavBarItem" >Home</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td><BR>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!-- End Side Bar -->
</td>
<td valign=top>
<table border="0" valign=top>
<tr>
<td class="ProgramTitle"> Snmp windows check</td>
</tr>
<tr>
<td>
<p class="NewsItemDate">Script : check_snmp_win.pl</p>
<p class="SectionTitle"> Last update : Jan 11 2007</p>
</td>
</tr>
<tr>
<td valign="top">
<p class="SectionTitle">Description : </p>
<p class="SectionBody">Checks by snmp v1 or v3 windows specific health
monitoring (service state for now).<br>
<br>
Works on Windows server (2000, 2003) maybe XP and NT.</p>
<p class="SectionBody"> Vérifie par snmp v1 ou v3 si un(des) service
Windows tournent.<br>
<br>
<span class="SectionTitle"> Service checks <br>
</span></p>
<p class="SectionBody">The plugin checks if there if the Windows service(s)
he gets as input are running. <br>
You can provide multiple services, comma separated : <br>
<b>-n &lt;service1&gt;,&lt;service2&gt;</b> </p>
<p class="SectionBody">The script will return : <br>
OK : if &lt;service1&gt; is found (and active) and &lt;service2&gt;
is found (and active). <br>
WARNING : if &lt;service1&gt; and &lt;service2&gt; match <b>more</b>
than 2 active services.<br>
CRITICAL : if &lt;service1&gt; OR &lt;service2&gt; don't match any
active service. </p>
<p class="SectionBody"><b>-N &lt;number&gt; </b>: will return OK if
&lt;number&gt; of active services matches the filter</p>
<p class="SectionBody"><b>-s </b>: will show all active services instead
of the non active ones only</p>
<p class="SectionTitle">Requirements :</p>
<p class="SectionBody"> - Perl in /usr/bin/perl - or just run 'perl
script' <br>
- Net::SNMP<br>
- file 'utils.pm' in plugin diretory<br>
</p>
<p class="SectionBody"><a href="check_snmp_win.pl" class="SectionTitle">Dowload
latest version : 0.6</a> </p>
<p class="SectionBody"><a href="index_commands.html" class="SectionTitle">Configurations
examples</a></p>
<p class="SectionTitle">Examples :</p>
<p class="SectionBody"><br>
All examples below are considering the script is local directory.
Host to be checked is 127.0.0.1 with snmp community &quot;public&quot;.</p>
<p class="SectionBody">If multiple interfaces are selected, all must
be up to get an OK result</p>
<table border="1" cellspacing="5" width="819">
<tr>
<td class="NewsItemDate" valign = top width="262">
<p>Get help
</td>
<td class="SectionBody" width="532">
<p>./check_snmp_win.pl <b>-h</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">snmpv3 login</td>
<td class="SectionBody" width="532">./check_snmp_win.pl -H 127.0.0.1
-l login -x passwd<b></b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<p>Check if at least one process matching dns is running
</td>
<td class="SectionBody" width="532">
<p>./check_snmp_win.pl -H 127.0.0.1 -C public <b>-n dns</b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<p align="right">Result example :
</td>
<td class="SectionBody" width="532">
<p>1 services active (matching &quot;dns&quot;) : OK</p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<p>Check if at least 3 process matching dns are running
</td>
<td class="SectionBody" width="532">
<p>./check_snmp_win.pl -H 127.0.0.1 -C public -n http<b> -N
2 </b></p>
</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<div align="right">Result example : <br>
(&lt;=2 will return warning, 0 critical)</div>
</td>
<td class="SectionBody" width="532">1 services active (matching
&quot;dns&quot;) : CRITICAL</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">Check if dns
and ssh services are running</td>
<td class="SectionBody" width="532">./check_snmp_win.pl -H 127.0.0.1
-C public -n dns,ssh</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<p align="right">Result example : </p>
</td>
<td class="SectionBody" width="532">&quot;dns&quot; active, &quot;ssh&quot;
active : OK</td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">Check if dns
and toto services are running</td>
<td class="SectionBody" width="532">./check_snmp_win.pl -H 127.0.0.1
-C public <b>-n dns,toto</b></td>
</tr>
<tr>
<td class="NewsItemDate" valign = top width="262">
<div align="right">Result example : </div>
</td>
<td class="SectionBody" width="532">&quot;toto&quot; not active
: CRITICAL</td>
</tr>
</table>
<p>&nbsp;</p>
<p class="NewsItemDate"><span class="SectionTitle">Changelog</span>
: On CVS repository on sourceforge : <a href="http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/">http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/</a>.<br>
</p>
<p class="NewsItemDate">Output of check_snmp_win.pl -h</p>
<table border="1" cellspacing="5">
<tr>
<td class="SectionBody" valign = top>
<p>SNMP Windows Monitor for Nagios version 0.6<br>
GPL licence, (c)2004-2005 Patrick Proy</p>
<p>Usage: check_snmp_win [-v] -H &lt;host&gt; -C &lt;snmp_community&gt;
[-2] | (-l login -x passwd) [-p &lt;port&gt;] -n &lt;name&gt;[,&lt;name2]
[-T=service] [-r] [-s] [-N=&lt;n&gt;] [-t &lt;timeout&gt;]
[-V]<br>
-v, --verbose<br>
print extra debugging information (and lists all services)<br>
-h, --help<br>
print this help message<br>
-H, --hostname=HOST<br>
name or IP address of host to check<br>
-C, --community=COMMUNITY NAME<br>
community name for the host's SNMP agent (implies SNMP v1
or v2c with option)<br>
-2, --v2c<br>
Use snmp v2c<br>
-l, --login=LOGIN<br>
Login for snmpv3 authentication (implies v3 protocol with
MD5)<br>
-x, --passwd=PASSWD<br>
Password for snmpv3 authentication<br>
-p, --port=PORT<br>
SNMP port (Default 161)<br>
-T, --type=service<br>
Check type : <br>
- service (default) checks service<br>
-n, --name=NAME[,NAME2...]<br>
Comma separated names of services (perl regular expressions
can be used for every one).<br>
By default, it is not case sensitive.<br>
-N, --number=&lt;n&gt;<br>
Compare matching services with &lt;n&gt; instead of the number
of names provided.<br>
-s, --showall<br>
Show all services in the output, instead of only the non-active
ones.<br>
-r, --noregexp<br>
Do not use regexp to match NAME in service description.<br>
-t, --timeout=INTEGER<br>
timeout for SNMP in seconds (Default: 5)<br>
-V, --version<br>
prints version number<br>
Note : <br>
The script will return <br>
OK if ALL services are in active state,<br>
WARNING if there is more than specified (ex 2 service specified,
3 active services matching), <br>
CRITICAL if at least one of them is non active.<br>
The -n option will allows regexp in perl format <br>
-n &quot;service&quot; will match 'service WINS' 'sevice DNS'
etc...<br>
It is not case sensitive by default : WINS = wins</p>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<p class="SectionBody">This project is hosted on : <br>
<A href="http://sourceforge.net/projects/nagios-snmp"> <IMG src="http://sourceforge.net/sflogo.php?group_id=134917&type=5" width="210" height="62" border="0" alt="SourceForge.net Logo" /></A>
</p>
<p class="SectionBody"> Nagios and the Nagios logo are registered
trademarks of Ethan Galstad.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>&nbsp;</p>
</BODY>
</HTML>

251
plugins/install.sh Executable file
View file

@ -0,0 +1,251 @@
#!/bin/bash
############################## install.sh #####################
# Version : 1.4
# Date : Jan 13 2007
# Author : Patrick Proy ( nagios at proy.org)
# Help : http://www.manubulon.com/nagios/
# Licence : GPL - http://www.fsf.org/licenses/gpl.txt
# TODO :
# Contribs :
#################################################################
#
# USAGE : ./install [<perl script name> | AUTO <dir> <tmp_dir> <perl_dir> [<install_location>] ]
# USAGE : by default all scripts will be installed
#
# REQUIREMENTS : /bin/bash and sed
#
# This script will:
# - Check perl binary (and asks for path)
# - Ask for monitoring plugin path (default /usr/local/icinga/libexec)
# - Ask for temporary file location (default /tmp)
# - Check Net::SNMP version
# - Install plugins in the plugins directory and modify paths if necessary.
############################ script list
PLUGINS="check_snmp_boostedge.pl check_snmp_css.pl check_snmp_linkproof_nhr.pl check_snmp_nsbox.pl check_snmp_vrrp.pl check_snmp_cpfw.pl check_snmp_env.pl check_snmp_load.pl check_snmp_process.pl check_snmp_win.pl check_snmp_css_main.pl check_snmp_int.pl check_snmp_mem.pl check_snmp_storage.pl"
############################ get script to install or install type
if [ $# -gt 0 ] ; then INSTSCRIPT=$1 ; else INSTSCRIPT="all" ; fi
if [ $INSTSCRIPT != "AUTO" ] ; then
############################ Manual installation
echo
echo "###### Manubulon snmp scripts installer ######"
echo
echo "Will install $INSTSCRIPT script(s)"
echo
############################ default values
SRCDIR=$PWD
PERLHOME=`which perl 2>&1`
if [ $? -ne 0 ]; then PERLHOME="" ; fi
PLUGHOME=/usr/local/icinga/libexec
TMPDATA=/tmp
############################ Checking Perl
echo -n "What is your perl location ? [$PERLHOME] "
read USERPERL
if [ "ZZ$USERPERL" != "ZZ" ]; then PERLHOME=$USERPERL ; fi
if [ "z$PERLHOME" == "z" ]; then
echo "Can't find perl binary... exiting"
echo "######### ERROR ########"
exit 1
fi
NETSNMP=`$PERLHOME -e 'if (eval "require Net::SNMP") { print "Yes" ;}'`
if [ $? -ne 0 ] ; then
echo "Error while checking Net::SNMP module"
echo "######### ERROR ########"
exit 1;
fi
if [ "zz$NETSNMP" != "zzYes" ]; then
echo "Module Net::SNMP not found!"
echo "Install it with CPAN or manually : http://www.manubulon.com/nagios/faq.html#FAQ2"
echo "######### ERROR ########"
exit 1;
fi
SNMPVER=`$PERLHOME -e 'require Net::SNMP;print Net::SNMP->VERSION'`
echo "Net::SNMP module version is $SNMPVER [OK]"
GETOPT=`$PERLHOME -e 'if (eval "require Getopt::Long") { print "Yes" ;}'`
if [ "zz$GETOPT" != "zzYes" ]; then
echo "Module Getopt::Long not found!"
echo "Install it with CPAN or manually"
echo "######### ERROR ########"
exit 1;
fi
echo "Module Getopt::Long found [OK]"
############################ Check monitoring plugin directory
echo
echo "What is your monitoring plugin location ? "
read USERPLUG
if [ "z$USERPLUG" != "z" ]; then PLUGHOME=$USERPLUG ; fi
if [ ! -d $PLUGHOME ] ; then
echo "Directory $PLUGHOME does not exist !"
echo "######### ERROR ########"
exit 1
fi
############################ Asking for temp directory
echo
echo "Where do you want the plugins to put temporary data (only used by some plugins) ? "
echo -n "Icinga user must be able to write files in it [$TMPDATA] "
read USERTMP
if [ "z$USERTMP" != "z" ]; then TMPDATA=$USERTMP ; fi
if [ ! -d $TMPDATA ] ; then
echo "Directory $TMPDATA does not exist !"
echo "######### ERROR ########"
exit 1
fi
############################ Looks OK, copying with changes if necessary
TRANS=""
# Change '#!/usr/bin/perl -w'
if [ $PERLHOME != "/usr/bin/perl" ] ; then
TRANS="-r -e s#/usr/bin/perl#$PERLHOME#"
fi
# Change 'my $o_base_dir="/tmp/tmp_Icinga_'
if [ $TMPDATA != "/tmp" ] ; then
if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#"
else TRANS="$TRANS -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#";fi
fi
######################### script install
echo
echo "Will now install $INSTSCRIPT script(s) : "
echo "in directory : $PLUGHOME"
echo "perl : $PERLHOME"
echo "temp directory : $TMPDATA"
echo
echo -n "OK ? [Y/n]"
read INSTOK
if [ "$INSTOK" == "n" ]; then
echo "Aborting....."
echo "######### ERROR ########"
exit 1
fi
ERROR=0
if [ $INSTSCRIPT == "all" ] ; then
for i in $PLUGINS ; do
echo
if [ ! -f $i ] ; then
echo "Can't find source file $i : ##### ERROR #####"
else
echo -n "Installing $i : "
if [ "z$TRANS" == "z" ] ; then
cp $i $PLUGHOME/$i 2>&1
else
sed $TRANS $i > $PLUGHOME/$i 2>&1
fi
if [ $? -ne 0 ] ; then
echo "##### ERROR #####";
rm -f $PLUGHOME/$i
ERROR=1
else
echo "OK"
chmod 755 $PLUGHOME/$i 2>&1
fi
fi
done
else
echo
if [ ! -f $INSTSCRIPT ] ; then
echo "Can't find source file $INSTSCRIPT : ##### ERROR #####"
else
echo -n "Installing $INSTSCRIPT : "
if [ "z$TRANS" == "z" ] ; then
cp $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT
else
sed $TRANS $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT 2>&1
fi
if [ $? -ne 0 ] ; then
echo "##### ERROR #####";
rm -f $PLUGHOME/$INSTSCRIPT
ERROR=1
exit 1;
else
echo "OK"
chmod 755 $PLUGHOME/$INSTSCRIPT 2>&1
fi
fi
fi
echo
if [ $ERROR -eq 1 ] ; then
echo "Installation ended with errors. Check output above"
exit 1;
fi
echo "Installation completed OK"
echo "You can delete all the source files and directory"
echo "Remember to look for informtation at http://www.manubulon.com/nagios/"
exit 0;
else
####################### Silent install with parameters ############
# PARAM AUTO <dir> <tmp_dir> <perl_dir> [<install_location>]
if [ $# -ne 4 ] && [ $# -ne 5 ] ; then exit 1; fi
SRCDIR=$PWD
PERLHOME=$4
PLUGHOME=$2
TMPDATA=$3
INSTALLDIR=$5
TRANS=""
# Change '#!/usr/bin/perl -w'
if [ $PERLHOME != "/usr/bin/perl" ] ; then
TRANS="-r -e s#/usr/bin/perl#$PERLHOME#"
fi
# Change 'my $o_base_dir="/tmp/tmp_Icinga_'
if [ $TMPDATA != "/tmp" ] ; then
if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#"
else TRANS="$TRANS -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#";fi
fi
######################### script install
ERROR=0
if [ "z$INSTALLDIR" != "z" ] ; then
PLUGHOME=$INSTALLDIR
fi
for i in $PLUGINS ; do
if [ ! -f $i ] ; then
ERROR=1
else
if [ "z$TRANS" == "z" ] ; then
cp $i $PLUGHOME/$i 2>&1
else
sed $TRANS $i > $PLUGHOME/$i 2>&1
fi
if [ $? -ne 0 ] ; then
rm -f $PLUGHOME/$i
ERROR=1
else
chmod 755 $PLUGHOME/$i 2>&1
fi
fi
done
if [ $ERROR -eq 1 ] ; then
exit 1;
fi
exit 0;
fi