nagios-snmp-plugins-2.0.0/000077500000000000000000000000001302077243700154305ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/.perltidyrc000066400000000000000000000012541302077243700176140ustar00rootroot00000000000000## basic options --maximum-line-length=120 --indent-columns=4 ## code indentation control --continuation-indentation=4 ## whilespace control --paren-tightness=2 --square-bracket-tightness=2 --block-brace-tightness=0 --nospace-for-semicolon #--add-semicolons --nospace-function-paren ## line break control --cuddled-else #--closing-token-indentation=0 #--nooutdent-long-quotes #--nooutdent-labels #--brace-tightness=1 #--vertical-tightness=0 #--stack-opening-tokens #--stack-closing-tokens --want-break-before="% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=" #--format-skipping-begin="#+\s*no tidy" #--format-skipping-end="#+\s*tidy" nagios-snmp-plugins-2.0.0/README.md000066400000000000000000000036231302077243700167130ustar00rootroot00000000000000# Manubulon SNMP Plugins ## General information Manubulon SNMP plugins is a set of Icinga/Nagios plugins to check hosts/devices using the SNMP protocol. Check [http://nagios.manubulon.com](http://nagios.manubulon.com) for more details. This is a fork using a [cvs2git import](http://sourceforge.net/projects/nagios-snmp/develop) which includes community patches. The original project was last active in 2007 so this project helps collect all patches and feature requests. Feel free to use & distribute it under the original license. ## Requirements * perl in /usr/bin/perl * Perl modules `Net::SNMP` and `Getopt::Long` (RHEL: `perl-Net-SNMP perl-Getopt-Long`) * `icinga` user able to write files in /tmp/ directory Perl, default directory and temp files location can be changed using the install.sh script. `utils.pm` from `Monitoring::Plugin::Perl` is no longer required. ## Documentation The original documentation and sourcecode is located at [http://nagios.manubulon.com](http://nagios.manubulon.com). A website copy was added underneath the `doc/` directory. ## Support You may create [GitHub issues](https://github.com/dnsmichi/manubulon-snmp) as well. I do have a lot of things on my plate so best is to send in a tested (!) patch at the same time. If you want to help maintain this project, just contact me on [twitter](https://twitter.com/dnsmichi) and I'll happily grant commit access. You may head over to [monitoring-portal.org community](http://www.monitoring-portal.org) for questions and feedback. The original support tracker is still located on [sourceforge](https://sourceforge.net/p/nagios-snmp/feature-requests/). ## Development Fork this repository on Github and send in a PR. There's a `.perltidyrc` file in the main repository tree. If you are uncertain about the coding style, create your patch and then run: $ perltidy -b plugins/*.pl This requires the `perltidy` module being installed. nagios-snmp-plugins-2.0.0/doc/000077500000000000000000000000001302077243700161755ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/doc/html/000077500000000000000000000000001302077243700171415ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/doc/html/README.md000066400000000000000000000004751302077243700204260ustar00rootroot00000000000000This directory contains a copy of nagios.manubulon.com with stripped binary files and removed french nagios docs. # wget command wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains nagios.manubulon.com --no-parent http://nagios.manubulon.com nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/000077500000000000000000000000001302077243700231755ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/faq.html000066400000000000000000000367521302077243700246470ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
FAQ

 

Last update : May 25 2007

 

FIRST, look at the web page associated with every script.

Running the scripts :

- The scripts outputs "Can't locate Net/SNMP.pm in @INC....."

- How do I install Net::SNMP perl module

- What are the supported platforms to run the scripts on ?

- How do I get help on the options ?

- Return code of X is out of bounds

- Are these plugins compatible with Nagios 2.0 ?

- ERROR: XXXXXX : Expected OBJECT IDENTIFIER in dotted notation.

- "No Output" using Nagios 2

- Getting : "ERROR: Size table :Message size exceeded buffer maxMsgSize"

- No usable data on file (X rows)

Misc

- Are these scripts secure ?

- How can I get help ? Is there a mailling list ? a forum ?

- Can I donate to help this project ?


The scripts outputs "Can't locate Net/SNMP.pm in @INC....."

You don't have Net::SNMP installed, see below

How do I install Net::SNMP perl module ?

There are 2 ways of doing this

1) By CPAN (best)

on command line, as root :

[your_host]# perl -MCPAN -e shell
cpan shell -- CPAN exploration and modules installation (v1.76)
ReadLine support enabled
cpan> install Net::SNMP

If it's the first time you run CPAN, it will probably ask you some (simple) questions.

CPAN will also ask you to satisfy some dependencies (Crypt::DES, Digest::MD5, etc..).

2) "By hand"

Get the folowings modules (tar.gz format) on www.cpan.org

- Crypt::DES
- Digest::MD5
- Digest::SHA1
- Digest::HMAC
- Net::SNMP

for each one (you must install Net::SNMP at the end) :
tar zxf <module>.tar.gz
cd <module>
perl Makefile.pl
make test
make install

What are the supported platforms to run the scripts on ?

Most Linux, maybe some unixes and maybe Cygwin.
Actually anything you can run perl on.
If you can install the latest Net::SNMP module, then the perl version should be OK.

How do I get help on the options ?

Just run <script> -h on the command line.

Return code of X is out of bounds

Have a look at : http://www.nagios.org/faqs/viewfaq.php?faq_id=17

In case of return code 127, try putting perl in the command line definition :

define command{
command_name check_disk
command_line /usr/bin/perl $USER1$/check_snmp_storage.pl -C $ARG1$ [........]
}

Are these plugins compatible with Nagios 2.0 ?

Yes.

ERROR: XXXXXX : Expected OBJECT IDENTIFIER in dotted notation.

Upgrade your Net::SNMP module version (5 is good, 4 maybe OK, 3 gives this error)
This happens with Debian Woody (Net::SNMP version 3.6).
I have special patches if you can't upgrade : contact me.

"No Output" using Nagios 2

It's a "bug" of embeded perl. It has been corrected in latest Nagios releases.

You can :

- 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). http://nagios.manubulon.com/p1-print.pl.patch

- Upgrade Nagios.

- add "/usr/bin/perl" before the script command so Nagios won't use embeded perl.

Getting : "ERROR: Size table :Message size exceeded buffer maxMsgSize"

Your snmp table is too big.

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).

In other scripts, try adding :

$session->max_msg_size(5000);

After the session has been initialized.

No usable data on file (X rows)

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....

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.

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 "no usable data on file (X rows)".
If you leave the 5 minutes default delta value, the script will need data wich is :
- At least 4 minutes and 30 seconds old (5 min - 10%)
- At most 15 minutes old (3 * 5 min)

You can change this 5 minutes value using the '-d <sec>' option. The script will then look for data which is at least <sec>-10% old and at most 3*<sec>.

This option will only tell to make an average on <sec> seconds, you can run the service every minute with Nagios, it will always get the newest value which is at least <sec>-10% old.
The only thing you must check is that your service will at least run every 15 minutes, or the script will always output "unknown" as the value will be too old for him.


Are these scripts secure ?

Not at all ! You must secure the Nagios server.
Nobody else than the nagios user should be allowed to even think about running these scripts.

How can I get help ? Is there a mailling list ? a forum ?

Go to the sourceforge project page for all this : Nagios-snmp

Can I donate to help this project ?

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...).
You can get my postal address on my resume (www.manubulon.com/cvpproy.htm).
He will answer you when he knows how to write (in several years).

This project is also hosted by :
SourceForge.net Logo

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/img/000077500000000000000000000000001302077243700237515ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/img/sideback.jpg000066400000000000000000000020731302077243700262220ustar00rootroot00000000000000JFIF``ExifII*C    $.' ",#(7),01444'9=82<.342C  2!!22222222222222222222222222222222222222222222222222 @" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?((((((((Sk*wzN%b(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/img/smalllogo7.jpg000066400000000000000000000123321302077243700265340ustar00rootroot00000000000000JFIFCC(" }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?V +_ō[eY|I!i1hhXn互 26[5c )Jo զ6TkH"+O_ɩm]^1z׀6=GөFVF{ibF\r\,!I#5$Ei}]CitgGu=:ٮҮ#xfxQl R |+wn{!%fÞ8%.:O<_k ;#DpGݕo_|PF]_k Ck^Am^ ;&={_ϗK q[>|#gϊ׆$:"My_ۦ닣3CGc1~?O A߄>'w[[:gË2kw7'˻ 5}m;7mG<`gמK_htOZ%|:g5Wp?ʾ/&X4mr `Ӧ(̈w)pA9zD|%|oMzD^-A ٵĞ*։M2[4؀3I[E+ď_>woh0s5-midP^K;Q3 n]ߴK]cO Ѭt=.xg^?Dektm(wae"캆߶NjًeMߍ=QiO8i? t? xD}m[[m-@j1&\ţ8ЯROF;(h5oW_MuAKdwey@aT62qu>)?} (m?/E?s*FMser6n;!Yɫ]ruW # 7? x˷?> Mƺ}1Pl-i<.Dx#x§⏃cj |*7Kk:q!HR/ZNIni srKD9 \w Px7ݥ~= o%_x{VuiB=h Od|/ }s 3 O WI;Yȶd1;ddEs4!ob^9>x;[m{ygEjNX^Qԯ4#M7GSP,I}̚HWu:? mj_uOwp5 !USQ.7Bȍs_B,_-AԾ"~οwèhYRTxW^~[]h?t"{IxfYhHI^2{C;a*<-~v/-Vwx-vO YkvvФ֖%)z.-J~ `eờAx1o|+TF4M7Ki RlQm^lqC7/'j|,> x㇉$~No/"|nic*!o0G8>J~E~Y[jxKG%I}.qjv|蟳?|@Yoxj?SմGN:|iW R@25 W>OOU|$gG| y}KY4QKic4Abܣ$,cRVO@?3F<=|hswxj>񅝤& ]ȓZ/˘c2*H5?iɬaeP]?P58{]3W5)]>;~̐gN3YGUd@GKY8Ld~Rw ]OυwouWU,oϊ|sF/X,o1E( P+/ٚwĿ ?l?woWzό5 ]?O(Ҿ׍]*#*ԩ8;_x*BQT4w߁xW?k !~  :nj.I/p\ tϓ/dl8,NhR]Rʧ$˹[?:k¾#t.>()0^ dj?vzմ/ ik-ė=r͎z?fǿ_F,`4tmWIMUo44&IVޞXZ.c[XԼ[{XEYJM+4-zszQJ~Zc*M?V펗$^1yo5Q3Wq\۩i*Pmc5GeӐ?P a 57sk..%hYrI>Q@_^h-* s'Ֆk0v0}+'_GGx_ߵ?/Jqy#&أSl[r'w@9ڼN(jӯ^ZU_J1xx'5?%MnluN3.Y=(Z[3bx xfm7ōcT:,R0AǘT]WO4KXmh~wu Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
My plugins for Nagios

Last update : Oct 12 2007

Lastest updates :

I've set up a wiki for the FAQ and the nagios config so users can contribute : http://nagios.manubulon.com/wiki

------------

Three scripts have been rewriten in C : check_snmp_int, check_snmp_process, check_snmp_storage
Have a look at the C plugin page

About the scripts


The general idea of these scripts is to check as many things as possible with snmp : disks, memory, load, interface, running procsses, etc...

The other idea is to select (or exclude) disks, interfaces, process using regular expressions

- it is possible to test more than one disk/int/process in one Nagios check (ex : eth* instead of eth0,eth1,eth2,...)

- you only have to provide a unique part of the name to select a disk/int/process (ex : "^C:" instead of "C:\ Label: Serial Number xxxxxxx" makes it easy to use on multiple Windows hosts).

Most of these scripts can output performance data.

Perl plugins main page

Information on useful parts of mibs (currently MIB-2,Net-SNMP,Cisco,CheckPoint).

Configurations examples for Nagios with the scripts.

FAQ

Get support, subscribe to mailing-list, etc..


Go to the perl plugins main page for more details and compatibility matrix
or here is a brief description of the scripts :

You can also download the all the plugins with install script : nagios-snmp-plugins.1.1.1.tgz

Script detail page Description performance
output
Supported platforms / snmp agents Download Version
Full C package

All the rewritten scripts in C :
check_snmp_int, check_snmp_process, check_snmp_storage

    nagios-plugins-snmp-0.6.0.tgz 0.6.0
Full perl package All the scripts with install script in a tgz file or in a rpm file for FC6.    

nagios-snmp-plugins.1.1.1.tgz

nagios-plugins-snmp-extras-1.1-1.noarch.rpm

1.1.1
check_snmp_storage checks storages (disks, swap, memory, etc...) Yes All MIB-2 compliant check_snmp_storage.pl  
check_snmp_int checks interface states, usage on hosts, switch, routers, etc.... Yes All MIB-2 compliant check_snmp_int.pl  
check_snmp_process checks if process are running, the number that are running, memory and cpu used. No All MIB-2 compliant check_snmp_process.pl  
check_snmp_load checks the load or the cpu of a machine Yes Linux, Windows, Cisco, AS400, HP Procurve, LinkProof, Blucoat, Nokia, Fortinet, Netscreen,HP-UX. check_snmp_load.pl  
check_snmp_vrrp checks the interface state of vrrp cluster No Nokia IP (VRRP & Clustering), LinkProof, Alteon check_snmp_vrrp.pl  
check_snmp_cpfw checks Checkpoint Firewall-1 status Yes Checkpoint Firewall-1 check_snmp_cpfw.pl  
check_snmp_mem Checks memory and swap usage Yes Linux/Net-snmp, Cisco, HP Switch check_snmp_mem.pl  
check_snmp_win Checks windows services No Windows check_snmp_win.pl  
check_snmp_css Checks css services state No CSS check_snmp_css.pl  
check_snmp_env Checks environemental status (fan, temp, power supply). No Cisco, Nokia, Bluecoat, IronPort, Foundry check_snmp_env.pl  
check_snmp_nsbox Checks nsbox vhost & diode status. No NetSecureOne Netbox check_snmp_nsbox.pl  
check_snmp_boostedge Checks Boostedge services No Boostedge check_snmp_boostedge.pl  
check_snmp_linkproof_nhr Checks linkproof NHR No Radware Linkproof check_snmp_linkproof_nhr.pl  

Try <script> -h for help.
More information on the main plugin page

Get latest CVS versions : In case I told you so, or you want to see how the plugins will be in next version


To contact me :

Thanks to all of you for your small or big contributions, or simply your feedbacks :

Christoph Maser, Alexius Ludeman, John Vincent, Anti Andreimann, Matteo Contri, Sean Finney, Eric Poelke, Russel Adams, Vincent Carpentier, Kaya, Dimo Velev, Jan Jungmann, DonKiShoot, Makina Corpus.

And all the others I forgot !!


All code here is under GPL licence.

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/index_commands.html000066400000000000000000001474711302077243700270710ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
My plugins for Nagios

Last update : Jun24 2006

This page is been migrated on the wiki : http://nagios.manubulon.com/wiki/index.php/Commands-host-url

It will remain until all has been migrated.

Commands

Here are commands example to use my scripts with nagios.
It's only the basic things you can do, check the help of every script if you need more advanced features especially if you need performance outputs.
The command definitions are complete, but not the service definitions : you must add host name, contact groups, etc....

All these commands use $USER<n>$ macros to put snmp login. The reason for this is that the ressources.cfg file cannot be read by the CGI, preventing your "passwords" to be seen with the config.
You must set the $USER7$ or $USER8$ to make these examples work.
The $USER<n>$ macro are defined in the resources.cfg file

SNMP login with $USER<n>$
About regular expressions

Configuration examples of

check_snmp_boostedge.pl
check_snmp_cpfw.pl
check_snmp_css.pl & check_snmp_css_main.pl
check_snmp_env.pl
check_snmp_linkproof_nhr.pl
check_snmp_load.pl
check_snmp_interface.pl
check_snmp_mem.pl
check_snmp_nsbox.pl
check_snmp_process.pl
check_snmp_storage.pl
check_snmp_vrrp.pl
check_snmp_win.pl

Checks you can make by host type

SNMP login

For more information, you can have a look at information on snmp login

If you are using snmp v1 :
$USER7$=-C <community>

If you are using snmp v2c :
$USER7$=-C <community> -2

or you can use $USER9$ if you need both v1 and v2c.

Examples of snmp v3 login :
AuthNoPriv (md5) :
$USER8$=-l <login> -x <pass>

AuthPriv (md5,aes) :
$USER8$=-l <login> -x <pass> -X <pass> -L md5,aes

About regular expressions

With all these scripts, when you select an interface, a service or process name etc... you use by default regular expresions :
Note : you can disable this by using "-r"

Examples : Don't forget it is perl regular expressions.

Regexp Will match
eth eth0, eth1, eth2 but also Fastethernet0/0 ....
eth[1-9] eth1, eth2, ... eth9 but also eth10, eth11
eth[1-2]$ eth1, eth2 only (not eth11 for ex).
dhcp dhcpc, dhpcd

 

check_snmp_boostedge.pl

Command check_snmp_boostedge
Nagios cmd define command{
command_name check_snmp_boostedge_v1
command_line $USER1$/check_snmp_boostedge.pl -H $HOSTADDRESS$ $USER7$ -s $ARG1$ -n $ARG2$ $ARG3$
}
Arguments ARG1 : Service name (regexp)
ARG2 : Number of services selected by regexp which must be in running & enabled state
ARG3 : additional arguments if needed.
Service

boostedge_services : checks is there is 3 active & enabled service matching "test" with snmp v2c

Nagios service define service {
   name boostedge_services
   check_command check_snmp_boostedge_v1!test!3!-2
}

check_snmp_cpfw.pl

Command check_cpfw1_v3
Nagios cmd define command{
  command_name check_cpfw1_v3
  command_line $USER1$/check_snmp_cpfw.pl -H $HOSTADDRESS$ $USER8$ $ARG1$
}
Arguments ARG1 : all arguments.
Service

checkpoint_verification : checks high availability cluster, with policy "CP_Policy" installed, and warning at 100000 connexions, critical at 200000
CP_Management : checks management station

Nagios service define service {
   name checkpoint_verification
   check_command check_cpfw1_v3!-swa -p CP_Policy -c 100000,200000 -f
}
Nagios service

define service {
   name CP_Management
   service_description CPFW1 management
   check_command check_cpfw1_v3!-sm
}

check_snmp_css.pl & check_snmp_css_main.pl

Command

check_snmp_css_main : get index from the host, services are then checked using check_snmp_css_indexed (snmpv2)
check_snmp_css_indexed : check services indexed by check_snmp_css_main (snmpv2)
check_snmp_css : directly read index & data from the host (snmpv2)

Nagios cmd define command{
  command_name check_snmp_css_main
  command_line $USER1$/check_snmp_css_main.pl -H $HOSTADDRESS$ $USER7$ -2
}
Nagios cmd define command{
  command_name check_snmp_css_indexed
  command_line $USER1$/check_snmp_css.pl -H $HOSTADDRESS$ $USER7$ -2 -d -n $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Nagios cmd define command{
  command_name check_snmp_css
  command_line $USER1$/check_snmp_css.pl -H $HOSTADDRESS$ $USER7$ -2 -n $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Arguments

ARG1 : regexp of service(s) to check
ARG2 : warning level for : minimum number of active & alive service , average response time, number of connexions
ARG3 : critical level for : minimum number of active & alive service , average response time, number of connexions
ARG4 : additional arguments if needed.

Service

css_index_file_create : This is a "fake" service, which only creates index file in /tmp. It normally returns the number of services it indexes, or an error if he can't.
css_verif_TEST : checks at least 2 services mathnig TEST are up. Warning if 1, critical if 0. This service uses the index file created by css_index_file_create, and returns UNKNOWN if it can't find it.
css_verif_TEST2 : checks at least 2 services mathnig TEST2 are up. Warning if 1, critical if 0. This service doesn't use an index file.

Nagios service define service {
   name css_index_file_create
   check_command check_snmp_css_main
}
Nagios service

define service {
   name css_verif_TEST
   check_command check_snmp_css_indexed!"TEST"!1!0
}

Nagios service

define service {
   name css_verif_TEST2
   check_command check_snmp_css!"TEST2"!1!0
}

 

check_snmp_env.pl

Command check_snmp_env (snmpv1)
check_snmp_env_v3 (snmpv3)
Nagios cmd define command{
  command_name check_snmp_env
  command_line $USER1$/check_snmp_env.pl -H $HOSTADDRESS$ $USER7$ -T $ARG1$ $ARG2$
}
Nagios cmd define command{
  command_name check_snmp_env_v3
  command_line $USER1$/check_snmp_env.pl -H $HOSTADDRESS$ $USER8$ -T $ARG1$ $ARG2$
}
Arguments ARG1 : type (cisco|nokia|bc|iron)
ARG2 : additional arguments if needed.
Service

ironport_env : checks ironport fans RPM > 1500 and temp < 70 deg celcius
nokia_env : checks nokia IP fans and power supply status
cisco_env : checks cisco fans and power supply status

Nagios service define service {
   name ironport_env
   check_command check_snmp_env!iron!-F 1500 -c 70
}
Nagios service

define service {
  name nokia_env
  check_command check_snmp_env_v3!nokia
}

Nagios service

define service {
  name cisco_env
  check_command check_snmp_env_v3!cisco
}

check_snmp_linkproof_nhr.pl

Command check_snmp_lp_nhr_v3 (snmpv3 and performance output)
Nagios cmd define command{
  command_name check_snmp_lp_nhr_v3
  command_line $USER1$/check_snmp_linkproof_nhr.pl -H $HOSTADDRESS$ $USER8$ -f
}
Arguments None
Service

linkproof_nhr : returns
WARNING if one nhr at least is in "no new session" or "inactive" mode.
CRITICAL if all nhr are inactive.

Nagios service define service {
   name linkproof_nhr
   check_command check_snmp_lp_nhr_v3
}

check_snmp_load.pl

Command check_snmp_load_v1 : using snmpv1 (or v2 depending on $USER7$ value)
check_snmp_load_v3 : using snmpv3
Command define command{
   command_name check_snmp_load_v1
   command_line $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ $USER7$ -T $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Command define command{
   command_name check_snmp_load_v3
   command_line $USER1$/check_snmp_load.pl -H $HOSTADDRESS$ $USER8$ -T $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Arguments

ARG1 : host type (stand,netsc,netsl,as400,cisco,cata,nsc,fg,bc,nokia,hp,lp,hpux)
ARG2 : warning level
ARG3 : critical level
ARG4 : additional arguments if needed.

Service bluecoat_load : Bluecoat cpu usage
Linux_load : Linux load (1min, 5 min, 15 min)
Cisco_load : Cisco cpu usage
lp_load : Radware Linkproff cpu usage
Service define service {
   name bluecoat_load
   check_command check_snmp_load_v1!bc!95!99
}
Service

define service {
   name Linux_load
   check_command check_snmp_load_v1!netsl!4,3,3!8,5,5
}

Service

define service {
   name Cisco_load
   check_command check_snmp_load_v1!cisco!90,80,60!100,100,100
}

Service define service {
   name lp_load
   check_command check_snmp_load_v1!lp!90!99
}

check_snmp_interface.pl

Command

check_snmp_int_v1 : using snmpv1
check_snmp_int_v3 : using snmpv3

Command define command{
  command_name check_snmp_int_v1
  command_line $USER1$/check_snmp_int.pl -H $HOSTADDRESS$ $USER7$ -n $ARG1$ $ARG2$
}
Command define command{
  command_name check_snmp_int_v3
  command_line $USER1$/check_snmp_int.pl -H $HOSTADDRESS$ $USER8$ -n $ARG1$ $ARG2$
}
Arguments

ARG1 : regexp of interface
ARG2 : additional arguments if needed.

Service check_int_1_6: Checks FastEthernet 1 to 6 are up (snmpv1)
check_int_eth0_bdw : Checks input bandwith on eth1 is < 100 KBytes/s and output is < 50 Kbytes/s (critical at 0,0 means no critical levels). (snmpv3)
Service

define service {
  name check_int_1_6
  check_command check_snmp_int_v1!"FastEthernet-[1-6]"
}

Service define service {
  name check_int_eth0_bdw
  check_command check_snmp_int_v3!eth0!-k -w 100,50 -c 0,0
}

check_snmp_mem.pl

Command check_snmp_mem
Command define command{
  command_name check_snmp_mem_v1
  command_line $USER1$/check_snmp_mem.pl -H $HOSTADDRESS$ $USER7$ $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Command define command{
  command_name check_snmp_mem_v3
  command_line $USER1$/check_snmp_mem.pl -H $HOSTADDRESS$ $USER8$ $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Arguments

ARG1 : Host type (-N, -I, -E)
ARG2 : warning level(s)
ARG3 : critical level(s)
ARG4 : additional arguments if needed.

Service Linux_memory : warning at 95% memory used and 60% swap used, critical at 99% mem and 90% swap
Cisco_mem : warning at 80% used, critical at 99% used.
Service define service {
  name Linux_memory
  check_command check_snmp_mem_v1!-N!95,60!99,90
}
Service

define service {
  name Cisco_mem
  check_command check_snmp_mem_v1!-I!80!99
}

check_snmp_nsbox.pl

Command check_snmp_nsbox (snmpv1 or v2c)
Nagios cmd define command{
command_name check_snmp_nsbox
command_line $USER1$/check_snmp_nsbox.pl -H $HOSTADDRESS$ $USER7$ -d $ARG1$ -s $ARG2$ -n $ARG3$ $ARG4$
}
Arguments

ARG1 : Diode name (regexp)
ARG2 : Vhost name (regexp)
ARG3 : Number of diodes and vhost that must be up
ARG4 : additional arguments if needed.

Service

check_service_nsbox : checks using snmpv2
- 6 diodes matching "diode_name" are up
- 3 vhosts matching "vhost_name" are up

Nagios service define service {
    name check_service_nsbox
    check_command check_snmp_nsbox_v1!diode_name!vhost_name!6,3!-2
}

check_snmp_process.pl

Command check_snmp_process
Command define command{
  command_name check_snmp_process_v1
  command_line $USER1$/check_snmp_process.pl -H $HOSTADDRESS$ $USER7$ -n $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Arguments

ARG1 : regexp of process name
ARG2 : warning level(s)
ARG3 : critical level(s)
ARG4 : additional arguments if needed.

Services proxy_checks : checks with snmpv2 (-2 option) that there is more than 21 process matching "proxy", but no more than 1999 (critical at 20 & 2000)
Check_httpd_all : Checks that process matching "httpd"
- Process number is > 5 and < 100 (or returns warning)
- Process number is > 0 (or returns critical)
- Memory used (by httpd process using the max memory) is < 20 Mbytes or < 30 Mbytes
- Cpu used (by all process together) is < 90% or 99%.
check_crontab : checks crontab is running (critical if not, no warnings).
Service define command {
  name proxy_checks
  check_command check_snmp_process_v1!proxy!21,1999!20,2000!-2
}
Service define command {
  name Check_httpd_all
  check_command check_snmp_process_v1!httpd!5,100!0!-2 -m 20,30 -u 90,99
}
Service

define service {
  name check_crontab
  check_command check_snmp_process!crond!0!0
}

check_snmp_storage.pl

Command check_snmp_storage
Command define command{
  command_name check_snmp_storage_v1
  command_line $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ $USER7$ -m $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Command define command{
  command_name check_snmp_storage_v3
  command_line $USER1$/check_snmp_storage.pl -H $HOSTADDRESS$ $USER8$ -m $ARG1$ -w $ARG2$ -c $ARG3$ $ARG4$
}
Arguments

ARG1 : regexp of storage name
ARG2 : warning level
ARG3 : critical level
ARG4 : additional arguments if needed.

Service Check_LinDisk_home : Checks "/home" mountpoint (and only this one because of -r) usage < 90 and 97 %
 

define service {
  name Check_LinDisk_home
  service_description Verification /home
  check_command check_snmp_storage_v3!/home!90!97!-r
}

Service Win_check_swap : Checks virtual (ram+swap) mem on windows < 60% or 90%
 

define command {
  name Win_check_swap
  service_description Verification swap Windows
  check_command check_snmp_storage_v3!Virtual!60!90
}

Service check_linux_swap : checks Linux swap < 60 and 90%
  define command {
  name check_linux_swap
  service_description Verfication swap linux
  check_command check_snmp_storage_v1!Swap!60!90!
}
Service check_disk_all : Checks that "/", "/opt" , "/var", "/config" mountpoints usage is < 80 and 90%
  define command {
  name check_disk_all
  service_description Verification / /opt /var /config
  check_command check_snmp_storage_v1!"^/$|opt|config|var"!80!90!
}

check_snmp_vrrp.pl

Command check_snmp_vrrp
Command define command{
  command_name check_snmp_vrrp_v1
  command_line $USER1$/check_snmp_vrrp.pl -H $HOSTADDRESS$ $USER7$ -T $ARG1$ -s $ARG2$
}
Command define command{
  command_name check_snmp_vrrp_v3
  command_line $USER1$/check_snmp_vrrp.pl -H $HOSTADDRESS$ $USER8$ -T $ARG1$ -s $ARG2$
}
Arguments

ARG1 : Host type (nokia, alteon, lp, nsc, ipso)
ARG2 : state (master or backup) or number of members, max % assigned to nodes (for ipso).

Service Linkproof_check_vrrp_master : Checks that all interface are in master state
Service

define service {
  name Linkproof_check_vrrp_master
  check_command check_snmp_vrrp_v3!lp!master
}

Service Nokia_check_vrrp_backup : Checks that all interface are in backup state
Service define service {
  name Linkproof_check_vrrp_backup
  check_command check_snmp_vrrp_v3!lp!backup
}
Service Nokia_clustering : checks that nokia cluster has 2 members and that the load assigned to each member < 98%
Service define service {
  name Nokia_clustering
  check_command check_snmp_vrrp_v3!ipso!2,98%
}

check_snmp_win.pl

Command check_snmp_win
Nagios define command {
  command_name check_win
  command_line $USER1$/check_snmp_win.pl -H $HOSTADDRESS$ $USER7$ -n $ARG1$
  # comment community service(s) name
}
Service check_win_dhcp : Checks dhcp service is running
Nagios

define service {
  name check_win_dhcp
  service_description Checks dhcp service is running
  check_command check_win!dhcp
}

Service check_win_reg_spool: Checks registery access & print spool is active (French windows !!)
Nagios

define service {
  name check_win_reg_spool
  service_description Checks registery access & print spool is active
  check_command check_win!"au registre",spouleur
}

Checks you can make by host type

N/A : nothing of this type to check
SNMP : yes with simple snmp query
?? : not tested because useless most of the time.

Specific : name of the script to look at for platform specific checks.

Host type Interface storage load/cpu mem process env specific
Linux Yes Yes Yes Yes Yes No  
Windows Yes Yes Yes Yes Yes No check_snmp_win.pl
Cisco router/switch Yes N/A Yes Yes N/A Yes  
HP router/switch Yes N/A Yes Yes N/A No  
Bluecoat proxy Yes snmp Yes snmp No Yes  
CheckPoint on SPLAT Yes Yes Yes Yes Yes No check_snmp_cpfw.pl
CheckPoint on Nokia IP Yes Yes Yes No ?? No check_snmp_vrrp.pl
Boostedge Yes Yes Yes Yes ?? No check_snmp_boostedge.pl
AS400 Yes Yes Yes Yes No No  
NetsecureOne Netbox Yes Yes Yes ?? Yes No  
Radware Linkproof Yes N/A snmp snmp No No

check_snmp_linkproof_nhr
check_snmp_vrrp.pl

IronPort Yes snmp snmp snmp No Yes  
Cisco CSS Yes ?? Yes Yes No ?? check_snmp_css.pl

 

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/index_info.html000066400000000000000000000542051302077243700262130ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
My plugins for Nagios

Last update : Jan 14 2006

Information on SNMP

Snmp login with v1,v2c, V3

These are interesting parts - for me - of different mibs.

MIB-2
Net-SNMP/UCD-SNMP
Cisco
CheckPoint
Hewlett Packard

 

Snmp login with v1,v2c, V3

There is 3 version of snmp :

V1 : you need a community to log in :
    <script> -C <community>

V2c : you need a community to log in :
    <script> -C <community> -2

V3 : you need a login and password. You can either encrypt data (AuthPriv) or not (AuthNoPriv). Authentication is encrypted in any case : NoAuthNoPriv is not supported, and is useless anyway : use snmpv1 in this case.

AuthNoPriv : Data is sent in clear, login and password are encrypted.
With default protocol (md5) :
    <script> -l login -x passwd
With sha protocol :
    <script> -l login -x passwd -L sha

AuthPriv : Data, login and password are encrypted
With default protocol (md5,des) :
    <script> -l login -x passwd -X privpasswd
With md5 for logging and aes for encrypting :
    <script> -l login -x passwd -X privpasswd -L md5,aes

 


MIB-2

Interface :

1.3.6.1.2.1.2.2.1 : interface table

OID Type Description
.1.X Int Index
.2.X string Description
.3.X ?? Type : 6=ethernet,23=ppp, 24=loopback, 27=atm
.4.X   MTU
.5.X   Speed
.6.X   Phys address
.7.X   Administrative status (1=>'UP',2=>'DOWN',3=>'TESTING')
.8.X   Operational status (cf admin status)
.9.X Counter Input Octets
.13.X Counter Output Octets

Storages :

1.3.6.1.2.1.25.2.2.0 : system memory
1.3.6.1.2.1.25.2.3.1 : storage table

OID Type Description
.1.X Int Index
.2.X OID Type : points on OID
.3.X string Description
.4.X Int Allocation unit
.5.X Int Size
.6.X Int Used
.7.X Counter32 Allocation failures

CPU

1.3.6.1.2.1.25.3.3.1 : CPU table

OID Type Description
.X.4 OID Type (hrProcessorFrwID)
.X.5 Int %used on 1 min (hrProcessorLoad)

 


Net-SNMP

Load

1.3.6.1.4.1.2021.10.1 : load table

OID Type Description
.1.X Int Index
.2.X string Description (Load-1, Load-5, Load 15)
.3.X string Load (decimal)

Memory

1.3.6.1.4.1.2021.4 : memory table

OID Type Description
.1.X Int Index
.2.X string Error name
.3.X Int TotalSwap
.4.X Int AvailSwap
.5.X Int TotalReal
.6.X Int AvailReal
.11.X Int TotalFree
.13.X Int memShared
.14.X Int memBuffer
.15.X Int memCached

CPU

1.3.6.1.4.1.2021.11 : CPU table

OID Type Description
.1.X Int Index
.2.X string Description
.3.X Int SwapIn
.4.X Int SwapOut
.5.X Int IOSent
.6.X Int IOReceive
.7.X Int SysInterrupts
.8.X Int SysContext
.9.X Int CpuUser
.10.X Int CpuSystem
.11.X Int CpuIdle
.50.X Counter32 User
.51.X Counter32 Nice
.52.X Counter32 System
.53.X Counter32 Idle


Cisco

Generic for routers and switch

Cisco CPU load (5min %) : 1.3.6.1.4.1.9.2.1.58.0
Cisco CPU load (1min %) : 1.3.6.1.4.1.9.2.1.57.0
Cisco CPU load (5sec %) : 1.3.6.1.4.1.9.2.1.56.0

Memory :

1.3.6.1.4.1.9.9.48.1 : cisco memory pool
1.3.6.1.4.1.9.9.48.1.1.1 : pool table.poolentry

.1 : type
.2 : name
.3 : alternate
.4 : valid
.5 : used
.6 : free
.7 : max free

Routeurs : 2 entry : memory IO and Processor
Pix : 1 entry PIX Memory


CPU

1.3.6.1.4.1.9.9.109.1.1.1.1 : cpmCPUTotalEntry
1 : index
2 : phys index
3 : total 5s
4 : total 1m
5 : total 5m
6 : total 5s (new)
7 : total 1m (new)
8 : total 5m (new)


Checkpoint

FW : 1.3.6.1.4.1.2620.1.1

.1.0 : Installed : policy state
.2.0 : <string> : filter name
.3.0 : <Mon Oct 4 11:34:08 2004> : date install
.4.0 : Packets Accept (counter)
.5.0 : Packets Rejected (counter)
.6.0 : Packets Dropped (counter)
.7.0 : Packets Logged (counter)
.25.3.0 : Connexions
.25.4.0 : Connexions peak

HA :
1.3.6.1.4.1.2620.1.5.5.0 : yes : ha active
1.3.6.1.4.1.2620.1.5.6.0 : active : ha state
1.3.6.1.4.1.2620.1.5.7.0 : OK : ha blocking state
1.3.6.1.4.1.2620.1.5.11.0 : "Sync only" (Nokia vrp) : ha Working mode
1.3.6.1.4.1.2620.1.5.102.0 : OK : ha status

1.3.6.1.4.1.2620.1.5.13.1 : table status
.1.X.0 : index
.2.X.0 : Nom :
Synchronization
Filter
cphad
fwd
.3.X.0 : State : "OK" / ??
.4.X.0 : haProblemPriority
.5.X.0 : haProblemVerified
.6.X.0 : haProblemDescr


SVN :
1.3.6.1.4.1.2620.1.6.102.0 : OK : SVN status code


Management :

1.3.6.1.4.1.2620.1.7.5.0 : "active" : mgmt state
1.3.6.1.4.1.2620.1.7.6.0 : 1 : mgmt is alive
1.3.6.1.4.1.2620.1.7.102.0 : status descr
1.3.6.1.4.1.2620.1.7.103.0 : status long descr

1.3.6.1.4.1.2620.1.7.7.0 : mgmt table clients :
.1.X.1.0 : index
.1.X.2.0 : client Name
.1.X.3.0 : client host
.1.X.4.0 : mgClientDbLock
.1.X.5.0 : mgApplicationType


Hewlett Packard


1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.6.1 : Free memory
1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0 : CPU
1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.1 : FAN
1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.2 : Power
1.3.6.1.4.1.11.2.14.11.1.2.6.1.4.4 : Temperature

HP Procurve switch memory check

1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1 : HP memory pool
mem pool.1 : memory slot index
mem pool.2 : hpGlobalMemSlabCnt
mem pool.3 : Free segments
mem pool.4 : hpGlobalMemAllocSegCnt
mem pool.5 : Total Bytes
mem pool.6 : Free Bytes
mem pool.7 : hpGlobalMemAllocBytes


This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/index_snmp.html000066400000000000000000000506651302077243700262430ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
My plugins for Nagios

Last update : Oct 10 2007

About

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...

The other idea is to select disks, interfaces, process using regular expressions

- it is possible to test more than one disk/int/process in one Nagios check (ex : eth* instead of eth0,eth1,eth2,...)

- you only have to provide a unique part of the name to select a disk/int/process (ex : "C:" instead of "C:\ Label: Serial Number xxxxxxx" makes it easy to use on multiple Windows hosts).

Most of these scripts can make performance outputs.

Enjoy and give me feedback !

All code here is under GPL licence.

If you want to be informed when I release new versions,
or if you have some advices, feedback, questions, go to the project's sourceforge page : nagios-snmp

Please send me your feedback :
- Test with embeded Perl
- Test on various systems
- Bugs, advices, comments, RFE, etc...
Thank you !

Run the scripts with '-h' to get help.

 

Requirements

- Perl in /usr/bin/perl - if not run 'perl script' or change the path in the scripts first line
- Net::SNMP
- file 'utils.pm' in diretory /usr/local/nagios/libexec or change the line "use libs /usr/local/nagios/libexec/" in the scripts

Configurations examples

Plugins

Bundle of all plugins

Version 1.1.1 : nagios-snmp-plugins.1.1.1.tgz

This bundle contains all the plugins, including an install script useful if you have special Nagios or perl paths.

check_snmp_storage

Download lasted version

 

This scripts checks by snmp (1,2c,3) disks, memory, swap, everthing in hrStorage table.
Disk selection can be done by perl regexp on description, index or type to select one or multiple storages.

Vérifie par snmp v1 ou v3 (merci à V. Carpentier) l'occupation des disques, mais aussi de la swap, de la mémoire, etc.. tout ce qui est disponible en snmp par la table hrStorage.
Les disques sont sélectionnables par expression régulière compatible Perl

Details

check_snmp_int

Download latest version

Checks by snmp (1,2c,3) interface state and usage. Interfaces can be selected by regexp.
It is possible to check the input/output bandwidth and error rate of the interface.

Vérifie par snmp v1 ou v3 l'état des interfaces d'un hôte.
Ce script permet d'utiliser des expressions régulières pour sélectionner les interfaces : ex 'eth' va vérifier eth0, eth1, ...
Il permet également de lister toutes les interfaces disponibles sur la machine cible (option -v).

Details

check_snmp_process

Download latest version

 

Checks by snmp (1,2c,3) the number (can be 1) of processes matching a perl regexp.
The script can also check memory and cpu usage of processes.

Vérifie par snmp v1 ou v3 (idem) le nombre de process sur un hôte.
Ce script permet d'utiliser des expressions régulières pour sélectionner les process.
Il est également possible de vérifier l'utilisation mémoire et CPU de la machine.
Il permet également de lister touts les process disponibles sur la machine cible (option -v).

Details

check_snmp_load

Download latest version

Checks by snmp (1,2c,3) cpu or average load.
Works on Linux, Windows, Cisco, AS400, HP Procurve, LinkProof, Blucoat, Nokia, Fortinet, Netscreen,HP-UX.

Vérifie par snmp (1,2c,3) la charge ou l'ocupation CPU.

Details.

check_snmp_mem

Download latest version

Checks by snmp (1,2c,3) :
- Memory and swap usage on Linux/Net-snmp
- Memory usage on cisco routers or Pix
- Memory usage on HP Procurve switchs
For memory check on other OS (Windows, AS400) see the description page

Vérifcation de
- l'utilisation mémoire et swap sur Linux/Net-snmp
- l'utilisation mémoire sur Cisco (routeurs et Pix).
- l'utilisation mémoire sur Switch Hp Procurve.
Pour d'autres SE (Windows, AS400), aller à la page de description.

Détail

check_snmp_vrrp

Download latest version

Checks the vrrp state of all the interface of a host. You can specify if they must be master or backup.
Supported platforms : Nokia IP (vrrp & clustering), Linkproof, Alteon.

Verifie l'état vrrp des interfaces d'un host.

check_snmp_cpfw

Download latest version

Checks the state of Checkpoint Firewall-1 modules (SVN, HA, FW, MGMT) and active connexions (tested on NG).
Snmp extensions must be activated

Vérifie l'état des modules Checkpoint Fw-1 (HA, SVN, MGMT, FW) et les connexions actives. Testé sur NG-AI R55.
L'extension SNMP doit être activée sur les modules.

Détail

check_snmp_win

Download version : 0.6

Checks windows services state with snmp.

Véifie l'état de services Windows par snmp.

Détail

check_snmp_css

Download version : 1.0

Checks css services state

check_snmp_env

Download latest version

Checks environemental status (fan, temp, power supply) on Cisco, Nokia, Bluecoat, IronPort.

check_snmp_nsbox

Download version : 1.0

Checks nsbox vhost & diode status.

check_snmp_boostedge

Download version : 1.0

Checks Boostedge services

check_snmp_linkproof_nhr

Download version : 1.0

Checks linkproof NHR

Compatibility matrix :

System check_snmp_storage check_snmp_int check_snmp_process check_snmp_mem check_snmp_load
Linux

OK :
- '/home', '/var'
- 'Swap', 'Real Memory'

OK :
- 'eth'
- 'ppp'
OK OK (mem & swap)

OK

Windows

OK :
- '^[CDE]:'

OK OK

NO
See check_snmp_storage for virtual mem

OK
Cisco/HP switch N/A OK :
- 'Giga' : all gigabits
- 'Fast.*0.1[1234]' : checks FastEternet0/11 to 0/14.
N/A OK OK
AS400 OK :
- '-m RAM -s' to get all RAM
- 'System ASP' : Disk
OK OK

NO
See check_snmp_storage

OK
LinkProof N/A OK N/A N/A OK

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/nagios_cert.cer000066400000000000000000000025121302077243700261650ustar00rootroot00000000000000-----BEGIN CERTIFICATE----- MIIDuzCCAqOgAwIBAgIBCzANBgkqhkiG9w0BAQUFADBFMREwDwYDVQQKEwhwcm95 Lm9yZzEPMA0GA1UEAxMGUHJveUNBMR8wHQYJKoZIhvcNAQkBFhBwYXRyaWNrQHBy b3kub3JnMB4XDTA3MDExMTE4MTM0NFoXDTA4MDExMTE4MTM0NFowgYExCzAJBgNV BAYTAkZSMQ4wDAYDVQQIEwVSaG9uZTENMAsGA1UEBxMETHlvbjERMA8GA1UEChMI cHJveS5vcmcxDzANBgNVBAsTBk5hZ2lvczEPMA0GA1UEAxMGTmFnaW9zMR4wHAYJ KoZIhvcNAQkBFg9uYWdpb3NAcHJveS5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0A MIGJAoGBAKSakWwv5g4cpXu2bL6/Aq+29BmY5pmiqOp5mSifYOfCYJfAMOCyeGAI 03GmEYhWaYVvEC2x03u7WhlbR6WzFsIxnFETdarlEHGl94wicyz6PKnwa9X5vkWm VKYgulvz6+jmrWFOyJ+Q60nIU0oAVE+0Erlk7MkFkWw1uthWl7VTAgMBAAGjgfww gfkwHQYDVR0OBBYEFKLfzxeOiNsgM53DMDcpTx7rsIH/MG0GA1UdIwRmMGSAFEE6 rbWSeijSQchCxUCknwDCivOfoUmkRzBFMREwDwYDVQQKEwhwcm95Lm9yZzEPMA0G A1UEAxMGUHJveUNBMR8wHQYJKoZIhvcNAQkBFhBwYXRyaWNrQHByb3kub3JnggEA MAkGA1UdEwQCMAAwLwYDVR0fBCgwJjAkoCKgIIYeaHR0cDovL3d3dy5wcm95Lm9y Zy9wcm95Q0EuY3JsMC0GCWCGSAGG+EIBBAQgFh5odHRwOi8vd3d3LnByb3kub3Jn L3Byb3lDQS5jcmwwDQYJKoZIhvcNAQEFBQADggEBADOEbkwCMCjNi6fkw1GR4cyO wWpHHE2J5en5eh5KIZCsW90vYH2TttjfYk/gnoON3lBsAV+Cisvdx5/LpEuqfZFB GMApyG58oXPzVipytppyOSxGlDkAnAXC9jNRIiZ4lBDXloziTaIPmjVpBM6wuEpY 7pGo1J7B+GOvKLYFYVX+tuOpMlHJtDJbhn2seTr50MaI0uncnqjKpXHO+J205p8b psCEkaZSQZ2EXpX+caCFxy1rjqC49glq/DaaxopQlhkUCvDQRoRoHDXg3EBW0Svx G9emvqbByaf31mUVlIesj8B+Xo8bqRMcEyWfwc7UE94Tzw6Iv2Xl2qFS2wmgMf8= -----END CERTIFICATE----- nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/p1-print.pl.patch000066400000000000000000000020241302077243700263000ustar00rootroot00000000000000--- p1.pl.dist 2006-03-21 11:42:30.000000000 +1100 +++ p1.pl 2006-03-21 11:56:16.000000000 +1100 @@ -69,27 +69,29 @@ sub TIEHANDLE { my ($class) = @_; - my $me ; + my $me = ''; bless \$me, $class; } sub PRINT { my $self = shift; - $$self = substr(join('',@_), 0, 256) ; - # $$self .= substr(join('',@_), 0, 256) ; + # $$self = substr(join('',@_), 0, 256) ; + $$self .= substr(join('',@_), 0, 256) ; } sub PRINTF { my $self = shift; my $fmt = shift; - $$self = substr(sprintf($fmt,@_), 0, 256) ; - # $$self .= substr(sprintf($fmt,@_), 0, 256) ; + # $$self = substr(sprintf($fmt,@_), 0, 256) ; + $$self .= substr(sprintf($fmt,@_), 0, 256) ; } sub READLINE { my $self = shift; + # Omit all lines after the first, per the nagios plugin guidelines + $$self = (split /\n/, $$self)[0]; # Perl code other than plugins may print nothing; in this case return "(No output!)\n". - return $$self ? $$self : "(No output!)\n" ; + return $$self ? substr($$self, 0, 256) : "(No output!)\n" ; } sub CLOSE { nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/package_c.html000066400000000000000000000154131302077243700257640ustar00rootroot00000000000000 Nagios plugins
Home

Plugins in C

Last update : Jun 9 2007

Description :

Three scripts have been rewriten in C : check_snmp_int, check_snmp_process, check_snmp_storage

New features in the C plugins :

- Cache management : the SNMP queries for index search, which are often the biggest ones, can now be cached on disk. Speed gain from this can be up to 10 times on big switches using snmp_int.
- Support for other languages (for now only french po file has been done)

Perl and C plugins have exactly the same options (except -K added in the C plugins), so you can use the same help pages.

download version 0.6.0

How to install :

Requirements to compile : net-snmp-devel

As a non-priviledge user, run ./configure scripts with following arguments :

--prefix=<DIR> [ default : /usr/local/nagios/ ] : Intallation directory. The plugins will go in <DIR>/libexec and the language files in <DIR>/share/locale/...
--with-basetmpdir=<DIR> [default=/tmp] : Where the plugins will put temporary files if needed. Not all the plugins will store temporary files.
--with-cachedir=<DIR> [default=[basetmpdir]/cache] Where the plugins will put cache files with snmp index

Then run :
make

Then, as root :
make install

To create the basetmpdir and cachedir if they don't exist, you can run :
make install-tmp
or create the two directories by hand with nagios user as owner or 777 mode.

That's all !

Details on the caching option

With the new C plugins, you can cache SNMP index queries.

Each time you run a script, it gets all the index table of what you are looking for (interface, storage, etc...).

This can be really big requests for example if you have a core LAN switch with 80 interfaces. As the interface index don't change very often, I added a caching of these queries so the only thing the script does to select an interface is read the cache file on disk.
Also, if you have more than one service on this host, every script (checking the same type of data) will be able to read this file.

All you have to do is put the '-K' option, with the default time validity of the cache file in minutes. The default time to live is 15 minutes, meaning that the index will be read every 15 minutes only.

If you have several services doing the same types of checks on the same host, the index will still be read once only within these 15 minutes.

 

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/robots.txt000066400000000000000000000000161302077243700252430ustar00rootroot00000000000000User-agent: * nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_cpfw.html000066400000000000000000000323041302077243700260610ustar00rootroot00000000000000 Nagios plugins
Home

Snmp Checkpoint FW-1 check

Script : check_snmp_cpfw.pl

Last update : April 19 2007

Description :

Checks by snmp v1, v2c or v3 some modules of Checkpoint FW-1 filtering or management module :

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.

- Firewall (on filtering firewall) :

Checks policy state : must be installed
Can check installed policy name : you mut provide the exact name of the policy (-p = <policy name>)
Can check connections : warning and maximum levels must be provided ( -c=<warn>,<crit>)

- SVN

Checks the svan status code (must be "OK") of SVN

- Management

Checks the management state ("active") and if management is alive.

- High availability

Checks the HA state :
- "active" on IPSO & master on SPLAT (default)
- "standby" on SPLAT
Use check_snmp_vrrp.pl for checks on active/standby or IPSO clusters on IPSO
Check the blocking state ("OK")
Checks the state of all HA softs, usually : Synchronization,Filter, cphad and fwd.

SNMP Login

See snmp info page

Requirements :

- On the Checkpoint Firewall : SNMP extentions must be active

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Configurations examples

Dowload lastest version : 1.2.1

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_cpfw.pl -h

snmpv3 login ./check_snmp_cpfw.pl -H 127.0.0.1 -l login -x passwd .....

Check firewall / HA / SVN - for a HA filtering module -

./check_snmp_cpfw.pl -H 127.0.0.1 -C public -swa

Result example :

FW : OK / SVN : OK / HA : OK / CPFW Status : OK

Check SVN/Mgmt - for a management -

./check_snmp_cpfw.pl -H 127.0.0.1 -C public -sm

Result example :
SVN : OK / MGMT : OK / CPFW Status : OK
Check policy name ./check_snmp_cpfw.pl -H 127.0.0.1 -C public -w -p prod

Result example :

FW : OK / CPFW Status : OK
Same with another policy installed :
FW : Policy installed : Standard / CPFW Status : CRITICAL
Check number of active connection with performance data output ./check_snmp_cpfw.pl -H 127.0.0.1 -C public -w -c 1000,5000 -f
Result example :
FW : OK / CPFW Status : OK | fw_connexions=340

 

Output of check_snmp_cpfw.pl -h

SNMP Checkpoint FW-1 Monitor for Nagios version 1.2.1
GPL Licence, (c)2004-2007 - Patrick Proy

Usage: ./check_snmp_cpfw.pl [-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]
-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
perfparse 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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_css.html000066400000000000000000000330271302077243700257150ustar00rootroot00000000000000 Nagios plugins
Home

Snmp CSS check

Script : check_snmp_css.pl / check_snmp_css_main.pl

Last update : Jan 22 2007

Description :

Checks by snmp v1, v2c or v3 CSS services state

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Checks

This scripts checks status of the CSS services.

Select service(s)
You select services you wan't to check with -n using regular expressions

Put thresholds
You select the warning and critical levels for : <num>,<resp>,<conn>
num : minimum number of active & alive service
resp : average response time in ms
conn : number of connexions

You can choose not to put 1, 2 or 3 numbers.
If you set "-w 3" only the number of active services will be checked.
If you set "-w 3,200" only the number of active services and response time will be checked.

For no warnings, put -1 (ex : -w5,-1,3).
When using negative numbers, dont put space after "-w" : "-w -1,100,6" will not work, "-w-1,100,6" will work.

-d option and check_snmp_css_main.pl

This option is set to make the script read the index from a file instead of on the CSS.

The reason of this option is :
- when you have a lot (> 50) services on the CSS
- you want to check 10 service group consisting of 5 services every 2 minutes.

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.
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.
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 !

How to use it :

Create a service with long inter-delay check executing :

check_snmp_css_main.pl -H <host> <snmp logins> -2 -d /var/tmp
-2 if for using snmpv2c (better to get a lot of data)
-d /var/tmp is to put the temp file to a special directory (default is /tmp).

A file named : Nagios_CSS_<IP Address> will be created

Then you can use your check_snmp_css.pl script just as before but adding the '-d' option with the temp directory if not /tmp.

If the Nagios_CSS_<IP> file is not created when the check_snmp_css script runs, it will then return unknown status.
If the check_snmp_css_main.pl cannot read index, a warning will be returned but the old index file will remain.

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.
The lock file is named : Nagios_CSS_<IP Address>.lock
The lock file format is simple: every line is in format
<OID>:<Service name>

 

Dowload lastest version of check_snmp_css.pl : 1.0

Dowload lastest version of check_snmp_css_main.pl : 1.0

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_css.pl -h

Verbose output ./check_snmp_css.pl -H <IP> -C <com> -v
snmpv3 login ./check_snmp_css.pl -H 127.0.0.1 -l login -x passwd

Output of check_snmp_css.pl -h

 SNMP Cisco CSS monitor for Nagios version 1.0
(c)2004-2006 Patrick Proy

Usage: ./check_snmp_css.pl [-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]
-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

Output of check_snmp_css_main.pl -h

 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 <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 
       [-d directory] [-p <port>] [-t <timeout>] [-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=<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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_env.html000066400000000000000000000321041302077243700257100ustar00rootroot00000000000000 Nagios plugins
Home

Snmp env check

Script : check_snmp_env.pl

Last update : April 19 2007

Description :

Checks by snmp v1, v2c or v3 environemental parameters such as fan, power supply, temperature

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Checks

The script will make the following checks depending on host type.
Either the threshold is directly set by the hardware manufacturer, or you must set them with an option.

This table shows what the script CAN check, depending on hardware version the sensors might not be there.
The script will return "UNKNOWN" if no sensors can be found.

If no option is specified in this table, it means the script uses the threshold of the snmp table.

Host type Option Power supply Fan Voltage Temperature Disks
Cisco cisco Yes Yes No (working on it) No (working on it) No
Nokia Ipso nokia Yes Yes No. Yes No
Bluecoat bc Yes Yes Yes Yes Yes
IronPort iron Yes Yes, option '-F' in RPM No Yes, option '-c' in Celcius No
Foundry Foundry Yes No (bug in snmp agent) No Yes No

Note : Bluecoat provides an "other" sensor which is tested also. But I never saw a Bluecoat reporting it.

 

Dowload lastest version : 1.2

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_env.pl -h

Verbose output ./check_snmp_env.pl -H <IP> -C <com> -v
snmpv3 login ./check_snmp_env.pl -H 127.0.0.1 -l login -x passwd

Check Cisco for all sensors

./check_snmp_env.pl -H 127.0.0.1 -C public -T cisco

Check Nokia for all sensors ./check_snmp_env.pl -H 127.0.0.1 -C public -T nokia
checks ironport fans RPM > 1500 and temp < 70 deg celcius ./check_snmp_env.pl -H 127.0.0.1 -C public -T iron -F 1500 -c 70

Output of check_snmp_env.pl -h


SNMP environmental Monitor for Nagios version 1.2
GPL Licence, (c)2006-2007 Patrick Proy

Usage: ./check_snmp_env.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -T (cisco|nokia|bc|iron|foundry) [-F <rpm>] [-c <celcius>] [-f] [-t <timeout>] [-V]
-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=cisco|nokia|bc|iron|foundry
Environemental check :
cisco : voltage,temp,fan,power supply status
will try to check everything present
nokia : fan and power supply
bc : fans, power supply, voltage, disks
iron : fans, power supply, temp
foundry : power supply, temp
-F, --fan=<rpm>
Minimum fan rpm value
-c, --celcius=<celcius>
Maximum temp in degree celcius
-f, --perfparse
Perfparse compatible output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_int.html000066400000000000000000000642241302077243700257220ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
Snmp interface check

Script : check_snmp_int.pl

Last update : May 24 2007

Description :

Checks by snmp (v1, v2c or v3) host interface state and usage.

Interfaces can be selected by regexp ( 'eth' will check eth0, eth1, eth2, ...).
If multiple interfaces are selected, all must be up to get an OK result

Vrifie par snmp v1, v2c ou v3 l'état des interfaces d'un hôte, leur utilisation (bande passante, erreurs, pertes) et sortir des informations de performances.
Ce script permet d'utiliser des expressions régulières pour sélectionner les interfaces : ex 'eth' va vérifier eth0, eth1, ...
Il permet galement de lister toutes les interfaces disponibles sur la machine cible (option -v) pour voir leur nom en SNMP.
Pour les francophones, je ferais un manuel en Français quand j'aurais le temps... (et toute aide est bienvenue).

Standard checks

The script will check interface operationnal status using the MIB-II table. The interface is (are) selected by the -n option.
This option will be treated as a regular expression (eth will match eth0, eth1, eth2...). You can disable this with the -r option : the interface will be selected if it's description exactly matches the name given by -n

The interfaces are selected by their description in the MIB-II table.
To see how interface looks like by snmp, you can list all of them with the '-v' switch.

The script will return OK if ALL interfaces selected are UP, or CRITICAL if at least one interface is down.

You can make the script return a OK value when all interfaces are down (and CRITICAL when at least one is up) with the -i option.

You can make the same tests on administrative status instead with the -a option.

If you have ISDN interface, and want that DORMANT state returns ok, put -D.

To make output shorter, specially when you have multiple interface, you can put the -s option.
It will get only the first <n> caracters of the interface descrition. If the number is negative then get the last <n> caracters.

Ex : EL20005 3Com Gigabit NIC (3C2000 Family)
-s 4 will output : "EL20".
-s -4 will output : "ily)".

Performance output

-f option : activate performance output (default the In/out octet as a counter).
-e option : in/out errors and discarded packets. -f must also be set.
-S option : Include speed in performance output in bits/s as '<interface_name>_speed_bps'
-y option : output performance data in % of interface speed
-Y
option : output performance data in bits/s or Bytes/s (depending on -B)

Note : -y and -Y options need the usage check to ba active (-k)

Warning : the counters needed by -e are not always available on all machines (ex Nokia IP)

Usage check (-k)


A temporary file will be created in "/tmp" by default : this can be changed at the beginning of the script.
The file name will be : tmp_Nagios_int.<host IP>.<Interface name>. One file will be created by interface.

The status UNKNOWN is returned when the script doesn't have enough information (see -d option).

You will have to tell the warning and critical levels, separated with "," and you can use decimal (ex : 10.3).
For standard checks (no "-q" option) :
-w <In warn>,<Out warn> -c <In warn>,<Out warn>
In warn : warning level for incomming traffic
Out warn : warning level for outgoing traffic
In crit : critical level for incomming traffic
Out crit : critical level for outgoing traffic

The unit for the check depends on the -B, -M and -G option :

  -B set -B not set
-M & -G not set
Kbps
KBps
-M set
Mbps
MBps
-G set
Gbps
GBps

It is possible to put warning and critical levels with -b option.
0 means no warning or critical level checks

When the extended checks are activated (-q option), the warning levels are
-w <In bytes>,<Out bytes>,<In error>,<Out error>,<In disc>,<Out disc> -c <In warn>,<Out warn>, .....
In error : warn/crit level in inboud error/minute
Out error : warn/crit level in outbound error/minute
In disc : warn/crit level in inboud discarded packets/minute
Out disc : warn/crit level in outbound discarded packets/minute

-k : activates the standard usage feature
-q : activates the extended usage
-d : delta in seconds (default is 300s)
-w : warning levels
-c : critical levels

-d: delta time
You can put the delta time as an option : the "delta" 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.
Here is an example : Check interval of 2 minutes and delta of 4min

T0 : value 1 : can't calculate usage
T0+2 : value 2 : can't calculate usage
T0+4 : value 3 : usage=(value3-value1)/((T0+4)-T0)
T0+6 : value 4 : usage=(value4-value2)/((T0+6)-T0+2)
(Yes I know TO+4-T0=4, it's just to explain..)
.........

The script will allow 10% less of the delta and 300% more than delta as a correct interval.
For example, with a delta of 5 minutes, the acceptable interval will be between 4'30" and 15 minutes.

Msg size option (-o option)

In case you get a "ERROR: running table : Message size exceeded maxMsgSize" 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.

--label option

This option just put label before the speed output :
Without : eth1:UP (10.3Kbps/4.4Kbps), eth0:UP (10.9Kbps/16.4Kbps):2 UP: OK
With : eth1:UP (in=14.4Kbps/out=6.2Kbps), eth0:UP (in=15.3Kbps/out=22.9Kbps):2 UP: OK

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Dowload latest version : 1.4.8

Configuration examples

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

If multiple interfaces are selected, all must be up to get an OK result

Get help

./check_snmp_int.pl -h

List all interfaces ./check_snmp_int.pl -H 127.0.0.1 -C public -n zzzz -v
snmpv3 login ./check_snmp_int.pl -H 127.0.0.1 -l login -w passwd

Check eth0 interface is up

./check_snmp_int.pl -H 127.0.0.1 -C public -n eth0 -r

Check that all eth interface are up

./check_snmp_int.pl -H 127.0.0.1 -C public -n eth

Check that all ppp interface are down

./check_snmp_int.pl -H 127.0.0.1 -C public -n ppp -i

Check that all eth interface are administratively up

./check_snmp_int.pl -H 127.0.0.1 -C public -n eth -a

Check that FastEternet0/11 to 0/14 are up (Cisco)

./check_snmp_int.pl -H 127.0.0.1 -C public -n "Fast.*0.1[1234]"

Check the eth0 usage
Note : no critical inbound (0)
./check_snmp_int.pl -H 127.0.0.1 -C public -n eth0 -k -w 200,400 -c 0,600

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Output of check_snmp_int.pl -h

SNMP Network Interface Monitor for Nagios version 1.4.8
GPL licence, (c)2004-2007 Patrick Proy

Usage: ./check_snmp_int.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>) [-p <port>] -n <name in desc_oid> [-i -a -D] [-r] [-f[eSyY]] [-k[qBMGu] -g -w<warn levels> -c<crit levels> -d<delta>] [-o <octet_length>] [-t <timeout>] [-s] --label [-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 v1 protocol)
-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)
-n, --name=NAME
Name in description OID (eth0, ppp0 ...).
This is treated as a regexp : -n eth will match eth0,eth1,...
Test it before, because there are known bugs (ex : trailling /)
-r, --noregexp
Do not use regexp to match NAME in description OID
-i, --inverse
Make critical when up
-a, --admin
Use administrative status instead of operational
-D, --dormant
Dormant state is an OK state
-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.
-f, --perfparse
Perfparse compatible output (no output when interface is down).
-e, --error
Add error & discard to Perfparse output
-S, --intspeed
Include speed in performance output in bits/s
-y, --perfprct ; -Y, --perfspeed
-y : output performance data in % of max speed
-Y : output performance data in bits/s or Bytes/s (depending on -B)
-k, --perfcheck ; -q, --extperfcheck
-k check the input/ouput bandwidth of the interface
-q also check the error and discard input/output
--label
Add label before speed in output : in=, out=, errors-out=, etc...
-g, --64bits
Use 64 bits counters instead of the standard counters when checking
bandwidth & performance data for interface >= 1Gbps.
You must use snmp v2c or v3 to get 64 bits counters.
-d, --delta=seconds
make an average of <delta> seconds (default 300=5min)
-B, --kbits
Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s
-G, --giga ; -M, --mega ; -u, --prct
-G : Make the warning and critical levels in Gbps (with -B) or GBps
-M : Make the warning and critical levels in Mbps (with -B) or MBps
-u : Make the warning and critical levels in % of reported interface speed.
-w, --warning=input,output[,error in,error out,discard in,discard out]
warning level for input / output bandwidth (0 for no warning)
unit depends on B,M,G,u options
warning for error & discard input / output in error/min (need -q)
-c, --critical=input,output[,error in,error out,discard in,discard out]
critical level for input / output bandwidth (0 for no critical)
unit depends on B,M,G,u options
critical for error & discard input / output in error/min (need -q)
-s, --short=int
Make the output shorter : only the first <n> chars of the interface(s)
If the number is negative, then get the <n> LAST caracters.
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number
Note : when multiple interface are selected with regexp,
all be must be up (or down with -i) to get an OK result.

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_load.html000066400000000000000000000335171302077243700260500ustar00rootroot00000000000000 Nagios plugins
Home

Snmp load check

Script : check_snmp_load.pl

Last update : Sept 5 2006

Description :

Checks by snmp v1, v2c or v3 cpu or average load.
Works on Windows, Linux/Unix, AS400, Cisco, Cisco catalyst, HP Procurve, LinkProof, Blucoat, Nokia, Fortinet, Netscreen.

Check types are selected by the -T option :

-T value
System
-w & -c values
netsl Linux : load provided by Net SNMP 3 values : load average on 1 min, 5 min, 15 min (absolute)
netsc Linux : CPU usage given by net-snmp 1 value in %
as400 as400 CPU usage 1 value in %
cisco cisco CPU usage 3 values : CPU average on 5sec, 1 min & 5 min (%)
cata cisco catalyst CPU usage 3 values : CPU average on 5sec, 1 min & 5 min (%)
nsc Netscreen CPU usage 3 values : CPU average on 5sec, 1 min & 5 min (%)
fg Fortigate CPU usage 1 value in %
bc bluecoat CPU usage 1 value in %
nokia nokia CPU usage 1 value in %
hp HP procurve switch CPU usage 1 value in %
lp Linkproof CPU usage 1 value in %
hpux HP-UX load 3 values : load average on 1 min, 5 min, 15 min

Vérifie par snmp v1,v2c ou v3 la charge ou l'ocupation CPU.

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory

Dowload lastest version : 1.3.2

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

If multiple interfaces are selected, all must be up to get an OK result

Get help

./check_snmp_load.pl -h

Check loads on linux with Net-SNMP : checks the 1, 5 and 15 minutes load average.

./check_snmp_load.pl -H 127.0.0.1 -C public -w 3,3,2 -c 4,4,3 -T netsl

Check cpu load (generic) : checks the %used CPU for the last minute

./check_snmp_load.pl -H 127.0.0.1 -C public -w 98% -c 99%

Check cpu load on AS/400

./check_snmp_load.pl -H 127.0.0.1 -C public -w 98% -c 99% -T as400

Output of check_snmp_load.pl -h

SNMP Load & CPU Monitor for Nagios version 1.3
(c)2004-2006 Patrick Proy

Usage: ./check_snmp_load.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -w <warn level> -c <crit level> -T=[stand|netsl|netsc|as400|cisco|cata|nsc|fg|bc|nokia|hp|lp] [-f] [-t <timeout>] [-V]
-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)
-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
netsc : cpu usage given by net-snmp (100-idle)
as400 : as400 CPU usage
cisco : Cisco 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
-f, --perfparse
Perfparse compatible output
-t, --timeout=INTEGER
timeout for SNMP in seconds (Default: 5)
-V, --version
prints version number

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_mem.html000066400000000000000000000265001302077243700257010ustar00rootroot00000000000000 Nagios plugins
Home

Snmp memory check

Script : check_snmp_mem.pl

Last update : Sept 4 2006

Description :

Checks by snmp v1, v2c or v3 :

- Memory and swap usage on Linux given by Net-snmp.
It checks memory and swap usage independantly : one warning and critical level for each of them.

- Memory usage on cisco routers or Pix : the plugin will add all of the memory pool and then checks the warning and critical levels.
On cisco routeurs, it will add 'IO' and 'Processor' memory
On Pix, it will check the memory used (one memory pool only on Pix).

- Memory usage on HP Procurve switch.
Memory segments will be added then the free memory will be checked.

Vérification de :
- l'utilisation mémoire et swap sur Linux/Net-snmp
- l'utilisation mémoire sur Cisco (routeurs et Pix).
Pour d'autres SE (Windows, AS400), lire la suite.

Checking memory for other os :

AS/400 : use the check_snmp_storage command to check the RAM

./check_snmp_storage.pl -H <IP> -C <community> -m RAM -s -w <warn%> -c <crit%>

Windows : use the check_snmp_storage command to check the virtual memory (RAM+Swap)

./check_snmp_storage.pl -H <IP> -C <community> -m "^Virtual Memory$" -w <warn%> -c <crit%>

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Dowload lastest version : 1.1

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_mem.pl -h

Verbose output ./check_snmp_mem.pl -H <IP> -C <com> -w 80 -c 81 -v
snmpv3 login ./check_snmp_mem.pl -H 127.0.0.1 -l login -x passwd

 

Unix/Linux

%used of
- RAM < 99% and 100%
- Swap : < 20% and 30%

./check_snmp_mem.pl -H <IP> -C <com> -w 99,20 -c 100,30

Same with no warning levels for memory

./check_snmp_mem.pl -H <IP> -C <com> -w 0,20 -c 100,30

Check memory on Cisco

./check_snmp_mem.pl -H <IP> -C <com> -I -w 90% -c 98%

Output of check_snmp_mem.pl -h <


SNMP Memory Monitor for Nagios version 1.1

(c)2004-2006 - Patrick Proy



Usage: ./check_snmp_mem.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>])  [-p <port>] -w <warn level> -c <crit level> [-I|-N|-E] [-f] [-m] [-t <timeout>] [-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=<authproto>,<privproto>

   <authproto> : Authentication protocol (md5|sha : default md5)

   <privproto> : 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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_process.html000066400000000000000000000475061302077243700266120ustar00rootroot00000000000000 Nagios plugins
Home

Snmp process check

Script : check_snmp_process.pl

Last update : Jun 09 2007

Description :

Checks by snmp v1 or v3 if a process is running and how many instances are running (minimum & maximum).
It is also possible to check memory and cpu used by one or a group of process

Works on Windows, Linux/Unix, AS400.

Vrifie par snmp v1 ou v3 si un process tourne et combien d'instances de ce process tournent (minimum et maximum).
Il est également possible de vérifier la mémoire et le cpu utilisé.

Standard checks

The plugin checks if there is at least one process matching the filter (-n option) when no warning or critical levels are set.
The filter is treated as a regular expression by default, but you can deactivate this (-r)

With the following options, you can add to your process selection :

-f : get full path of the script instead of only it's name

-A : add parameters with the script name

Option how the script will see the process
None named
-f /usr/sbin/named
-A named -u named -t /var/named/chroot
-f -A /usr/sbin/named -u named -t /var/named/chroot

Warning : the -f & -A option will not function properly for Windows hosts (the snmp agent don't give this information)

You can use -w and -c options to set the warning and critical levels :
-w <minW>,<maxW> : with minW and maxW the minimum and maximum number of processes.

-c <minC>,<maxC> : same thing
Of course : minC <= minW < maxW <=maxC

You can omit <maxW> and <maxC>


Saying N is the current number of processes
- N < minC : critical
- minC < N <=minW : warning
- minW< N <= maxW : OK
- maxW< N <= maxC : warning
- maxC < N : critical

Memory checks

The -m option can check the memory used by the selected processes.
By default, this will select the process wich use the maximum memory. The -a switch will make an average

Ex : -m 7,20 will send a warning if a process uses more than 7 Mb, and critical for more than 20Mb.

CPU checks

When you use the -u option, a temporary file will be created in "/tmp" by default : this can be changed at the beginning of the script.
The file name will be : tmp_Nagios_proc.<host IP>.<process filter>.

The -u option will add all the cpu used by all selected process and the make the check

-u 91,95 : will send a warning if more than 91% of cpu is used, and critical if more than 95% is used.

On multiprocessor hosts, the % of cpu use can be > 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).

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.
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.

Msg size option (-o option)

In case you get a "ERROR: running table : Message size exceeded maxMsgSize" 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.

SNMP Login

See snmp info page

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory

Dowload latest version : 1.5

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

If multiple interfaces are selected, all must be up to get an OK result

Get help

./check_snmp_process.pl -h

snmpv3 login ./check_snmp_process.pl -H 127.0.0.1 -l login -x passwd

Check if at least one process matching http is running

./check_snmp_process.pl -H 127.0.0.1 -C public -n http

Result example :

3 process matching http : > 0 : OK

Check if at least 3 process matching http are running

./check_snmp_process.pl -H 127.0.0.1 -C public -n http -w 2 -c 0

Result example :
(<=2 will return warning, 0 critical)
3 process matching httpd : > 2 : OK
Check if at least one process named "httpd" exists (no regexp) ./check_snmp_process.pl -H 127.0.0.1 -C public -n http -r

Result example :

3 process named httpd : > 0 : OK
Check process by their full path : check process of /opt/soft/bin/ (at least one) ./check_snmp_process.pl -H 127.0.0.1 -C public -n /opt/soft/bin/ -f
Check that at least 3 process but not more than 8 are running ./check_snmp_process.pl -H 127.0.0.1 -C public -n http -w 3,8 -c 0,15
Same checks + checks maximum memory used by process (in Mb) : warning and critical levels ./check_snmp_process.pl -H 127.0.0.1 -C public -n http -w 3,8 -c 0,15 -m 9,25
Same check but sum all CPU used by all selected process ./check_snmp_process.pl -H 127.0.0.1 -C public -n http -w 3,8 -c 0,15 -m 9,25 -u 70,99

Output of check_snmp_process.pl -h

SNMP Process Monitor for Nagios version 1.5
GPL licence, (c)2004-2006 Patrick Proy

Usage: ./check_snmp_process.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd) [-p <port>] -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]
-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)
-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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_storage.html000066400000000000000000000661041302077243700265730ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
Snmp storage check

Script : check_snmp_storage.pl

Last update : Jun 09 2007

Description :

This scripts checks by snmp (V1 and v3) disks, memory, swap, everthing in hrStorage table.
Storages selection can be done :
- by perl regexp on description or index (-m)
- and (optional) by storage type (-q) : Other, Ram, VirtualMemory, FixedDisk, RemovableDisk, FloppyDisk, CompactDisk, RamDisk, FlashMemory, NetworkDisk

One or multiple storages can be selected.
It is also possible to sum all selected storages (-s)

Warning and critical levels can be checked based on :
- Percent of disk used
- Percent of disk left
- MB left
- MB used

Output options (-S):

-S can have 3 options : <type>[,<where>,<cut>]
<type> : Make the output shorter :
0 : only print the global result except the disk in warning or critical
1 : Don't print all info for every disk
<where> : (optional) if = 1, put the OK/WARN/CRIT at the beginning
<cut> : take the <n> first caracters or <n> last if n<0

With the following disks : /home : 51% used and / : 90% used

Option used Warning Output
  99% /home: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB) (<99%) : OK
  90% /home: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S0 90% All selected storages (<99%) : OK
-S0 99% /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S1 90% /home: 51% /: 90% (<99%) : OK
-S1 99% /home: 51% /: 90%used(5781MB/6390MB) (>90%) : WARNING
-S0,1 90% OK : (<99%) All selected storages
-S0,1 90% WARNING : (>90%) /: 90%used(5781MB/6390MB)
-S1,,2 99% /h: 51% /: 90% (<99%) : OK
-S1,,-2 99% me: 51% /: 90% (<99%) : OK
-S0,1,-2 30% WARNING : (>30%) me: 51%used(1012MB/1969MB) /: 90%used(5781MB/6390MB)

Performance output (-f option)

The performance will remove any weird caracters ( `~!$%^&*'"<>|?,(= ) ) from the drive name.

Msg size option (-o option)

In case you get a "ERROR: running table : Message size exceeded maxMsgSize" 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.

SNMP Login

See snmp info page

---
Vrifie par snmp v1 ou v3 l'occupation des disques, mais aussi de la swap, de la mmoire, etc.. tout ce qui est disponible en snmp par la table hrStorage.
Les disques sont sélectionnables par expression régulière compatible Perl

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

Dowload lastest version : 1.3.3

Configurations examples

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

Get help

./check_snmp_storage.pl -h

List all storage ./check_snmp_storage.pl -H 127.0.0.1 -C public -m zzzz -w 80 -c 81 -v
snmpv3 login ./check_snmp_storage.pl -H 127.0.0.1 -l login -x passwd

Unix/Linux

%used of /home is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 80% -c 90%

%free of /home is above 10% and 5%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 10% -c 5% -T pl

Mb used of /home is less than 800 Mb and 900 Mb

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 800 -c 900 -T bu

Mb free of /home is above 100Mb and 30Mb

./check_snmp_storage.pl -H 127.0.0.1 -C public -m /home -w 100 -c 30 -T bl

All mountpoints have %used less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m / -w 80% -c 90%

%used of / mountpoint only is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m / -r -w 80% -c 90%

%used of mountpoint index 1 only is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m 1 -p -w 80% -c 90%

Swap %used is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m Swap -w 80% -c 90%

Memory %used is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m "Real Memory" -w 80% -c 90%

 

Windows

%used of C is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^C: -w 80% -c 90%

%used of C, D and E is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^[CDE]: -w 80% -c 90%

%used of C+D+E is less than 80% and 90%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m ^[CDE]: -s -w 80% -c 90%

 

AS/400 specific

Sum of all memory storages is less than 90% and 95%

./check_snmp_storage.pl -H 127.0.0.1 -C public -m RAM -s -w 80% -c 90%

Output of check_snmp_storage.pl -h

SNMP Disk Monitor for Nagios version 1.3.3
(c)2004-2007 Patrick Proy

Usage: check_snmp_storage [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) [-p <port>] -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>]
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)
-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
Perfparse compatible 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


This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_vrrp.html000066400000000000000000000353341302077243700261210ustar00rootroot00000000000000 Nagios plugins
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios Home
Nagios Plugins
Oreon project
NagiosExchange
Opsyx forum
Forum 2037
-----------
Others :
-----------
SourceForge.net Logo
Snmp vrrp check

Script : check_snmp_vrrp.pl

Last update : Sept 4 2006

Description :

Checks by snmp v1, v2c or v3 the vrrp status of all vrrp enabled interfaces.
Works on
- Nokia IP with ipso 3.X , 4.X in VRRP mode.
- Nokia IP with ipso 3.X , 4.X in clustering mode.
- Radware Linkproof
- Alteon AD4 Loadbalancers

Depending on the state you put as option ("master" or "backup") the script will get all the vrrp enables interface and check they are in this state.
If not, it will retrun a critical status
By default, it will check Nokia IP platforms using vrrp, you can test other platforms with the '-T' option :

- Alteon
- Linkproof (VRRP)
- Nokia clustering.

Nokia clustering check

Nokia clustering check does not have a master & backup state. Instead, the plugin will check :

- The number of cluster member
- The % load on each cluster.

For example -s 2,90 will issue
- A critical level if there is not 2 members.
- A warning level if more than 90% is assigned to one cluster member.

To have a long output, put the '-g' option.

SNMP Login

See snmp info page

French : Vrifie par snmp v1 ou v3 l'état des interfaces vrrp : Nokia, Linkproof, Altéon ou l'état d'un cluster Nokia.

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory

Dowload lastest version : 1.3

Configurations examples

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

If multiple interfaces are selected, all must be up to get an OK result

Get help

./check_snmp_vrrp.pl -h

snmpv3 login ./check_snmp_vrrp.pl -H 127.0.0.1 -l login -x passwd

Check vrrp state of a node to be master.

./check_snmp_vrrp.pl -H 127.0.0.1 -C public -s master

Output example :
The ouput is : <vrid>(<state>,<status>,<priority>)

Vrid : 10(master/up/100), 1(master/up/100), 3(master/up/100), 2(master/up/100), : All master :OK
Check vrrp state of a node to be backup. ./check_snmp_vrrp.pl -H 127.0.0.1 -C public -s backup

Output example :

Vrid : 1(backup/up/95), 3(backup/up/95), 10(backup/up/95), 2(backup/up/95), : All backup :OK

Test a Linkproof ./check_snmp_vrrp.pl -H 127.0.0.1 -C public -s master -T lp
Test a Nokia cluster : 2 cluster members and max 90% load assigned to one cluster. ./check_snmp_vrrp.pl -H 127.0.0.1 -C public -s 2,90%-T ipso

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Output of check_snmp_vrrp.pl -h

SNMP VRRP Monitor for Nagios version 1.3
(c)2004-2006 to my cat Ratoune - Author : Patrick Proy

Usage: ./check_snmp_vrrp.pl [-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>] [-p <port>] [-t <timeout>] [-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 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) : Nokai 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
-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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/doc/html/nagios.manubulon.com/snmp_windows.html000066400000000000000000000307001302077243700266120ustar00rootroot00000000000000 Nagios plugins
Home

Snmp windows check

Script : check_snmp_win.pl

Last update : Jan 11 2007

Description :

Checks by snmp v1 or v3 windows specific health monitoring (service state for now).

Works on Windows server (2000, 2003) maybe XP and NT.

Vrifie par snmp v1 ou v3 si un(des) service Windows tournent.

Service checks

The plugin checks if there if the Windows service(s) he gets as input are running.
You can provide multiple services, comma separated :
-n <service1>,<service2>

The script will return :
OK : if <service1> is found (and active) and <service2> is found (and active).
WARNING : if <service1> and <service2> match more than 2 active services.
CRITICAL : if <service1> OR <service2> don't match any active service.

-N <number> : will return OK if <number> of active services matches the filter

-s : will show all active services instead of the non active ones only

Requirements :

- Perl in /usr/bin/perl - or just run 'perl script'
- Net::SNMP
- file 'utils.pm' in plugin diretory

Dowload latest version : 0.6

Configurations examples

Examples :


All examples below are considering the script is local directory. Host to be checked is 127.0.0.1 with snmp community "public".

If multiple interfaces are selected, all must be up to get an OK result

Get help

./check_snmp_win.pl -h

snmpv3 login ./check_snmp_win.pl -H 127.0.0.1 -l login -x passwd

Check if at least one process matching dns is running

./check_snmp_win.pl -H 127.0.0.1 -C public -n dns

Result example :

1 services active (matching "dns") : OK

Check if at least 3 process matching dns are running

./check_snmp_win.pl -H 127.0.0.1 -C public -n http -N 2

Result example :
(<=2 will return warning, 0 critical)
1 services active (matching "dns") : CRITICAL
Check if dns and ssh services are running ./check_snmp_win.pl -H 127.0.0.1 -C public -n dns,ssh

Result example :

"dns" active, "ssh" active : OK
Check if dns and toto services are running ./check_snmp_win.pl -H 127.0.0.1 -C public -n dns,toto
Result example :
"toto" not active : CRITICAL

 

Changelog : On CVS repository on sourceforge : http://nagios-snmp.cvs.sourceforge.net/nagios-snmp/plugins/.

Output of check_snmp_win.pl -h

SNMP Windows Monitor for Nagios version 0.6
GPL licence, (c)2004-2005 Patrick Proy

Usage: check_snmp_win [-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]
-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

This project is hosted on :
SourceForge.net Logo

Nagios and the Nagios logo are registered trademarks of Ethan Galstad.

 

nagios-snmp-plugins-2.0.0/icingaexchange.yml000066400000000000000000000003771302077243700211170ustar00rootroot00000000000000name: manubulon-snmp description: "file:///README.md" url: "https://github.com/dnsmichi/manubulon-snmp" tags: SNMP,Storage,Network,Windows,NAS vendor: Linux,Cisco,HP,Fortinet,Juniper target: Operating System,Snmp,Storage,Network type: Plugin license: gpl nagios-snmp-plugins-2.0.0/plugins/000077500000000000000000000000001302077243700171115ustar00rootroot00000000000000nagios-snmp-plugins-2.0.0/plugins/Changelog000066400000000000000000000072321302077243700207270ustar00rootroot00000000000000################################ 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. nagios-snmp-plugins-2.0.0/plugins/INSTALL000066400000000000000000000012271302077243700201440ustar00rootroot00000000000000Installation: ------------- 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 " 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. nagios-snmp-plugins-2.0.0/plugins/LICENSE000066400000000000000000000354301302077243700201230ustar00rootroot00000000000000 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 nagios-snmp-plugins-2.0.0/plugins/README000066400000000000000000000031711302077243700177730ustar00rootroot00000000000000Nagios 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. nagios-snmp-plugins-2.0.0/plugins/check_snmp_boostedge.pl000077500000000000000000000310731302077243700236220ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) -s -n [-p ] [-f] [-t ] [-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 "" 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 < Regexp of service to select -n, --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=, : Authentication protocol (md5|sha : default md5) : 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"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_cpfw.pl000077500000000000000000000511151302077243700226050ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) [-s] [-w [-p=pol_name] [-c=warn,crit]] [-m] [-a [standby] ] [-f] [-p ] [-t ] [-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 <, : Authentication protocol (md5|sha : default md5) : 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; nagios-snmp-plugins-2.0.0/plugins/check_snmp_css.pl000077500000000000000000000500101302077243700224270ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) -n [-d directory] [-w ,, -c ,,] [-p ] [-f] [-t ] [-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 "" 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 < regexp to select service -w, --warning=,, 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 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=,resp>, 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=, : Authentication protocol (md5|sha : default md5) : 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 () { 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"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_css_main.pl000077500000000000000000000240241302077243700234410ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) [-d directory] [-p ] [-t ] [-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 < 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=, : Authentication protocol (md5|sha : default md5) : 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"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_env.pl000077500000000000000000001237431302077243700224450ustar00rootroot00000000000000#!/usr/bin/perl -w ############################## check_snmp_env ################# # Version : 1.3 # Date : May 24 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 : Fredrik Vocks ################################################################# # # Help : ./check_snmp_env.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); my @Nagios_state = ("UNKNOWN", "OK", "WARNING", "CRITICAL"); # Nagios states coding # SNMP Datas # CISCO-ENVMON-MIB my $ciscoEnvMonMIB = "1.3.6.1.4.1.9.9.13"; # Cisco env base table my %CiscoEnvMonState = (1, "normal", 2, "warning", 3, "critical", 4, "shutdown", 5, "notPresent", 6, "notFunctioning"); # Cisco states my %CiscoEnvMonNagios = (1, 1, 2, 2, 3, 3, 4, 3, 5, 0, 6, 3); # Nagios states returned for CIsco states (coded see @Nagios_state). my $ciscoVoltageTable = $ciscoEnvMonMIB . ".1.2.1"; # Cisco voltage table my $ciscoVoltageTableIndex = $ciscoVoltageTable . ".1"; #Index table my $ciscoVoltageTableDesc = $ciscoVoltageTable . ".2"; #Description my $ciscoVoltageTableValue = $ciscoVoltageTable . ".3"; #Value my $ciscoVoltageTableState = $ciscoVoltageTable . ".7"; #Status # CiscoEnvMonVoltageStatusEntry ::= # 1 ciscoEnvMonVoltageStatusIndex Integer32 (0..2147483647), # 2 ciscoEnvMonVoltageStatusDescr DisplayString, # 3 ciscoEnvMonVoltageStatusValue CiscoSignedGauge, # 4 ciscoEnvMonVoltageThresholdLow Integer32, # 5 ciscoEnvMonVoltageThresholdHigh Integer32, # 6 ciscoEnvMonVoltageLastShutdown Integer32, # 7 ciscoEnvMonVoltageState CiscoEnvMonState my $ciscoTempTable = $ciscoEnvMonMIB . ".1.3.1"; # Cisco temprature table my $ciscoTempTableIndex = $ciscoTempTable . ".1"; #Index table my $ciscoTempTableDesc = $ciscoTempTable . ".2"; #Description my $ciscoTempTableValue = $ciscoTempTable . ".3"; #Value my $ciscoTempTableState = $ciscoTempTable . ".6"; #Status # CiscoEnvMonTemperatureStatusEntry ::= # ciscoEnvMonTemperatureStatusIndex Integer32 (0..2147483647), # ciscoEnvMonTemperatureStatusDescr DisplayString, # ciscoEnvMonTemperatureStatusValue Gauge32, # ciscoEnvMonTemperatureThreshold Integer32, # ciscoEnvMonTemperatureLastShutdown Integer32, # ciscoEnvMonTemperatureState CiscoEnvMonState my $ciscoFanTable = $ciscoEnvMonMIB . ".1.4.1"; # Cisco fan table my $ciscoFanTableIndex = $ciscoFanTable . ".1"; #Index table my $ciscoFanTableDesc = $ciscoFanTable . ".2"; #Description my $ciscoFanTableState = $ciscoFanTable . ".3"; #Status # CiscoEnvMonFanStatusEntry ::= # ciscoEnvMonFanStatusIndex Integer32 (0..2147483647), # ciscoEnvMonFanStatusDescr DisplayString, # ciscoEnvMonFanState CiscoEnvMonState my $ciscoPSTable = $ciscoEnvMonMIB . ".1.5.1"; # Cisco power supply table my $ciscoPSTableIndex = $ciscoPSTable . ".1"; #Index table my $ciscoPSTableDesc = $ciscoPSTable . ".2"; #Description my $ciscoPSTableState = $ciscoPSTable . ".3"; #Status # CiscoEnvMonSupplyStatusEntry ::= # ciscoEnvMonSupplyStatusIndex Integer32 (0..2147483647), # ciscoEnvMonSupplyStatusDescr DisplayString, # ciscoEnvMonSupplyState CiscoEnvMonState, # ciscoEnvMonSupplySource INTEGER # Nokia env mib my $nokia_temp_tbl = "1.3.6.1.4.1.94.1.21.1.1.5"; my $nokia_temp = "1.3.6.1.4.1.94.1.21.1.1.5.0"; my $nokia_fan_table = "1.3.6.1.4.1.94.1.21.1.2"; my $nokia_fan_status = "1.3.6.1.4.1.94.1.21.1.2.1.1.2"; my $nokia_ps_table = "1.3.6.1.4.1.94.1.21.1.3"; my $nokia_ps_temp = "1.3.6.1.4.1.94.1.21.1.3.1.1.2"; my $nokia_ps_status = "1.3.6.1.4.1.94.1.21.1.3.1.1.3"; # Bluecoat env mib my @bc_SensorCode = ( "", "ok", "unknown", "not-installed", "voltage-low-warning", "voltage-low-critical", "no-power", "voltage-high-warning", "voltage-high-critical", "voltage-high-severe", "temperature-high-warning", "temperature-high-critical", "temperature-high-severe", "fan-slow-warning", "fan-slow-critical", "fan-stopped" ); # BC element status returned by MIB my @bc_status_nagios = (3, 0, 3, 3, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2); # nagios status equivallent to BC status my @bc_SensorStatus = ("", "ok", "unavailable", "nonoperational"); # ok(1),unavailable(2),nonoperational(3) my @bc_mesure = ("", "", "", "Enum", "volts", "celsius", "rpm"); my @bc_DiskStatus = ("", "present", "initializing", "inserted", "offline", "removed", "not-present", "empty", "bad", "unknown"); my @bc_dsk_status_nagios = (3, 0, 0, 1, 1, 1, 2, 2, 2, 3); my $bc_sensor_table = "1.3.6.1.4.1.3417.2.1.1.1.1.1"; # sensor table my $bc_sensor_units = "1.3.6.1.4.1.3417.2.1.1.1.1.1.3"; # cf bc_mesure my $bc_sensor_Scale = "1.3.6.1.4.1.3417.2.1.1.1.1.1.4"; # * 10^value my $bc_sensor_Value = "1.3.6.1.4.1.3417.2.1.1.1.1.1.5"; # value my $bc_sensor_Code = "1.3.6.1.4.1.3417.2.1.1.1.1.1.6"; # bc_SensorCode my $bc_sensor_Status = "1.3.6.1.4.1.3417.2.1.1.1.1.1.7"; # bc_SensorStatus my $bc_sensor_Name = "1.3.6.1.4.1.3417.2.1.1.1.1.1.9"; # name my $bc_dsk_table = "1.3.6.1.4.1.3417.2.2.1.1.1.1"; #disk table my $bc_dsk_status = "1.3.6.1.4.1.3417.2.2.1.1.1.1.3"; # cf bc_DiskStatus my $bc_dsk_vendor = "1.3.6.1.4.1.3417.2.2.1.1.1.1.5"; # cf bc_DiskStatus my $bc_dsk_serial = "1.3.6.1.4.1.3417.2.2.1.1.1.1.8"; # cf bc_DiskStatus # Ironport env mib my $iron_ps_table = "1.3.6.1.4.1.15497.1.1.1.8"; # ps table my $iron_ps_status = "1.3.6.1.4.1.15497.1.1.1.8.1.2"; # ps status #powerSupplyNotInstalled(1), powerSupplyHealthy(2), powerSupplyNoAC(3), powerSupplyFaulty(4) my @iron_ps_status_name = ("", "powerSupplyNotInstalled", "powerSupplyHealthy", "powerSupplyNoAC", "powerSupplyFaulty"); my @iron_ps_status_nagios = (3, 3, 0, 2, 2); my $iron_ps_ha = "1.3.6.1.4.1.15497.1.1.1.8.1.3"; # ps redundancy status #powerSupplyRedundancyOK(1), powerSupplyRedundancyLost(2) my @iron_ps_ha_name = ("", "powerSupplyRedundancyOK", "powerSupplyRedundancyLost"); my @iron_ps_ha_nagios = (3, 0, 1); my $iron_ps_name = "1.3.6.1.4.1.15497.1.1.1.8.1.4"; # ps name my $iron_tmp_table = "1.3.6.1.4.1.15497.1.1.1.9"; # temp table my $iron_tmp_celcius = "1.3.6.1.4.1.15497.1.1.1.9.1.2"; # temp in celcius my $iron_tmp_name = "1.3.6.1.4.1.15497.1.1.1.9.1.3"; # name my $iron_fan_table = "1.3.6.1.4.1.15497.1.1.1.10"; # fan table my $iron_fan_rpm = "1.3.6.1.4.1.15497.1.1.1.10.1.2"; # fan speed in RPM my $iron_fan_name = "1.3.6.1.4.1.15497.1.1.1.10.1.3"; # fan name # Foundry BigIron Router Switch (FOUNDRY-SN-AGENT-MIB) my $foundry_temp = "1.3.6.1.4.1.1991.1.1.1.1.18.0"; # Chassis temperature in Deg C *2 my $foundry_temp_warn = "1.3.6.1.4.1.1991.1.1.1.1.19.0"; # Chassis warn temperature in Deg C *2 my $foundry_temp_crit = "1.3.6.1.4.1.1991.1.1.1.1.20.0"; # Chassis warn temperature in Deg C *2 my $foundry_ps_table = "1.3.6.1.4.1.1991.1.1.1.2.1"; # PS table my $foundry_ps_desc = "1.3.6.1.4.1.1991.1.1.1.2.1.1.2"; # PS desc my $foundry_ps_status = "1.3.6.1.4.1.1991.1.1.1.2.1.1.3"; # PS status my $foundry_fan_table = "1.3.6.1.4.1.1991.1.1.1.3.1"; # FAN table my $foundry_fan_desc = "1.3.6.1.4.1.1991.1.1.1.3.1.1.2"; # FAN desc my $foundry_fan_status = "1.3.6.1.4.1.1991.1.1.1.3.1.1.3"; # FAN status my @foundry_status = (3, 0, 2); # oper status : 1:other, 2: Normal, 3: Failure # Linux Net-SNMP with LM-SENSORS my $linux_temp = "1.3.6.1.4.1.2021.13.16.2.1"; # temperature table my $linux_temp_descr = "1.3.6.1.4.1.2021.13.16.2.1.2"; # temperature entry description my $linux_temp_value = "1.3.6.1.4.1.2021.13.16.2.1.3"; # temperature entry value (mC) my $linux_fan = "1.3.6.1.4.1.2021.13.16.3.1"; # fan table my $linux_fan_descr = "1.3.6.1.4.1.2021.13.16.3.1.2"; # fan entry description my $linux_fan_value = "1.3.6.1.4.1.2021.13.16.3.1.3"; # fan entry value (RPM) my $linux_volt = "1.3.6.1.4.1.2021.13.16.4.1"; # voltage table my $linux_volt_descr = "1.3.6.1.4.1.2021.13.16.4.1.2"; # voltage entry description my $linux_volt_value = "1.3.6.1.4.1.2021.13.16.4.1.3"; # voltage entry value (mV) my $linux_misc = "1.3.6.1.4.1.2021.13.16.4.1"; # misc table my $linux_misc_descr = "1.3.6.1.4.1.2021.13.16.4.1.2"; # misc entry description my $linux_misc_value = "1.3.6.1.4.1.2021.13.16.4.1.3"; # misc entry value # 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 # check type my $o_check_type = "cisco"; # default Cisco my @valid_types = ("cisco", "nokia", "bc", "iron", "foundry", "linux"); my $o_temp = undef; # max temp my $o_fan = undef; # min fan speed # 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_env version : $VERSION\n"; } sub print_usage { print "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] -T (cisco|nokia|bc|iron|foundry|linux) [-F ] [-c ] [-f] [-t ] [-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 help { print "\nSNMP environmental Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; print "GPL License, (c)2006-2007 Patrick Proy\n\n"; print_usage(); print <, : Authentication protocol (md5|sha : default md5) : Priv protocole (des|aes : default des) -P, --port=PORT SNMP port (Default 161) -T, --type=cisco|nokia|bc|iron|foundry Environemental check : cisco : All Cisco equipements : voltage,temp,fan,power supply (will try to check everything in the env mib) nokia : Nokia IP platforms : fan and power supply bc : BlueCoat platforms : fans, power supply, voltage, disks iron : IronPort platforms : fans, power supply, temp foundry : Foundry Network platforms : power supply, temp linux : Net-SNMP with LM-SENSORS : temp, fan, volt, misc -F, --fan= Minimum fan rpm value (only needed for 'iron' & 'linux') -c, --celcius= Maximum temp in degree celcius (only needed for 'iron' & 'linux') -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, 'T:s' => \$o_check_type, 'type:s' => \$o_check_type, 'F:i' => \$o_fan, 'fan:i' => \$o_fan, 'c:i' => \$o_temp, 'celcius:i' => \$o_temp ); # 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"}; } } } ########## 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); } $SIG{'ALRM'} = sub { print "No answer from host\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; ########### Cisco env checks ############## if ($o_check_type eq "cisco") { verb("Checking cisco env"); # Get load table my $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($ciscoEnvMonMIB) : $session->get_table(Baseoid => $ciscoEnvMonMIB); if (!defined($resultat)) { printf("ERROR: Description table : %s.\n", $session->error); $session->close; exit $ERRORS{"UNKNOWN"}; } $session->close; # Get env data index my (@voltindex, @tempindex, @fanindex, @psindex) = (undef, undef, undef, undef); my ($voltexist, $tempexist, $fanexist, $psexist) = (0, 0, 0, 0); my @oid = undef; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$ciscoVoltageTableDesc/) { @oid = split(/\./, $key); $voltindex[$voltexist++] = pop(@oid); } if ($key =~ /$ciscoTempTableDesc/) { @oid = split(/\./, $key); $tempindex[$tempexist++] = pop(@oid); } if ($key =~ /$ciscoFanTableDesc/) { @oid = split(/\./, $key); $fanindex[$fanexist++] = pop(@oid); } if ($key =~ /$ciscoPSTableDesc/) { @oid = split(/\./, $key); $psindex[$psexist++] = pop(@oid); } } if (($voltexist == 0) && ($tempexist == 0) && ($fanexist == 0) && ($psexist == 0)) { print "No Environemental data found : UNKNOWN"; exit $ERRORS{"UNKNOWN"}; } my $perf_output = ""; # Get the data my ($i, $cur_status) = (undef, undef); my $volt_global = 0; my %volt_status; if ($fanexist != 0) { for ($i = 0; $i < $voltexist; $i++) { $cur_status = $$resultat{ $ciscoVoltageTableState . "." . $voltindex[$i] }; verb($$resultat{ $ciscoVoltageTableDesc . "." . $voltindex[$i] }); verb($cur_status); if (!defined($cur_status)) { ### Error TODO $volt_global = 1; } if (defined($$resultat{ $ciscoVoltageTableValue . "." . $voltindex[$i] })) { $perf_output .= " '" . $$resultat{ $ciscoVoltageTableDesc . "." . $voltindex[$i] } . "'="; $perf_output .= $$resultat{ $ciscoVoltageTableValue . "." . $voltindex[$i] }; } if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { $volt_global = 1; $volt_status{ $$resultat{ $ciscoVoltageTableDesc . "." . $voltindex[$i] } } = $cur_status; } } } my $temp_global = 0; my %temp_status; if ($tempexist != 0) { for ($i = 0; $i < $tempexist; $i++) { $cur_status = $$resultat{ $ciscoTempTableState . "." . $tempindex[$i] }; verb($$resultat{ $ciscoTempTableDesc . "." . $tempindex[$i] }); verb($cur_status); if (!defined($cur_status)) { ### Error TODO $temp_global = 1; } if (defined($$resultat{ $ciscoTempTableValue . "." . $tempindex[$i] })) { $perf_output .= " '" . $$resultat{ $ciscoTempTableDesc . "." . $tempindex[$i] } . "'="; $perf_output .= $$resultat{ $ciscoTempTableValue . "." . $tempindex[$i] }; } if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { $temp_global = 1; $temp_status{ $$resultat{ $ciscoTempTableDesc . "." . $tempindex[$i] } } = $cur_status; } } } my $fan_global = 0; my %fan_status; if ($fanexist != 0) { for ($i = 0; $i < $fanexist; $i++) { $cur_status = $$resultat{ $ciscoFanTableState . "." . $fanindex[$i] }; verb($$resultat{ $ciscoFanTableDesc . "." . $fanindex[$i] }); verb($cur_status); if (!defined($cur_status)) { ### Error TODO $fan_global = 1; } if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { $fan_global = 1; $fan_status{ $$resultat{ $ciscoFanTableDesc . "." . $fanindex[$i] } } = $cur_status; } } } my $ps_global = 0; my %ps_status; if ($psexist != 0) { for ($i = 0; $i < $psexist; $i++) { $cur_status = $$resultat{ $ciscoPSTableState . "." . $psindex[$i] }; if (!defined($cur_status)) { ### Error TODO $fan_global = 1; } if ($Nagios_state[$CiscoEnvMonNagios{$cur_status}] ne "OK") { $ps_global = 1; $ps_status{ $$resultat{ $ciscoPSTableDesc . "." . $psindex[$i] } } = $cur_status; } } } my $global_state = 0; my $output = ""; if ($fanexist != 0) { if ($fan_global == 0) { $output .= $fanexist . " Fan OK"; $global_state = 1 if ($global_state == 0); } else { foreach (keys %fan_status) { $output .= "Fan " . $_ . ":" . $CiscoEnvMonState{ $fan_status{$_} } . " "; if ($global_state < $CiscoEnvMonNagios{ $fan_status{$_} }) { $global_state = $CiscoEnvMonNagios{ $fan_status{$_} }; } } } } if ($psexist != 0) { $output .= ", " if ($output ne ""); if ($ps_global == 0) { $output .= $psexist . " ps OK"; $global_state = 1 if ($global_state == 0); } else { foreach (keys %ps_status) { $output .= "ps " . $_ . ":" . $CiscoEnvMonState{ $ps_status{$_} } . " "; if ($global_state < $CiscoEnvMonNagios{ $ps_status{$_} }) { $global_state = $CiscoEnvMonNagios{ $ps_status{$_} }; } } } } if ($voltexist != 0) { $output .= ", " if ($output ne ""); if ($volt_global == 0) { $output .= $voltexist . " volt OK"; $global_state = 1 if ($global_state == 0); } else { foreach (keys %volt_status) { $output .= "volt " . $_ . ":" . $CiscoEnvMonState{ $volt_status{$_} } . " "; if ($global_state < $CiscoEnvMonNagios{ $volt_status{$_} }) { $global_state = $CiscoEnvMonNagios{ $volt_status{$_} }; } } } } if ($tempexist != 0) { $output .= ", " if ($output ne ""); if ($temp_global == 0) { $output .= $tempexist . " temp OK"; $global_state = 1 if ($global_state == 0); } else { foreach (keys %temp_status) { $output .= "temp " . $_ . ":" . $CiscoEnvMonState{ $temp_status{$_} } . " "; if ($global_state < $CiscoEnvMonNagios{ $temp_status{$_} }) { $global_state = $CiscoEnvMonNagios{ $temp_status{$_} }; } } } } #print $output," : ",$Nagios_state[$global_state]," | ",$perf_output,"\n"; print $output, " : ", $Nagios_state[$global_state], "\n"; $exit_val = $ERRORS{ $Nagios_state[$global_state] }; exit $exit_val; } ############# Nokia checks if ($o_check_type eq "nokia") { verb("Checking nokia env"); my $resultat; # status : 0=ok, 1=nok, 2=temp prb my ($fan_status, $ps_status, $temp_status) = (0, 0, 0); my ($fan_exist, $ps_exist, $temp_exist) = (0, 0, 0); my ($num_fan, $num_ps) = (0, 0); my ($num_fan_nok, $num_ps_nok) = (0, 0); my $global_status = 0; my $output = ""; # get temp $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($nokia_temp_tbl) : $session->get_table(Baseoid => $nokia_temp_tbl); if (defined($resultat)) { verb("temp found"); $temp_exist = 1; if ($$resultat{$nokia_temp} != 1) { $temp_status = 2; $global_status = 1; $output = "Temp CRITICAL "; } else { $output = "Temp OK "; } } # Get fan table $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($nokia_fan_table) : $session->get_table(Baseoid => $nokia_fan_table); if (defined($resultat)) { $fan_exist = 1; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$nokia_fan_status/) { if ($$resultat{$key} != 1) { $fan_status = 1; $num_fan_nok++ } $num_fan++; } } if ($fan_status == 0) { $output .= ", " . $num_fan . " fan OK"; } else { $output .= ", " . $num_fan_nok . "/" . $num_fan . " fan CRITICAL"; $global_status = 2; } } # Get ps table $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($nokia_ps_table) : $session->get_table(Baseoid => $nokia_ps_table); if (defined($resultat)) { $ps_exist = 1; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$nokia_ps_status/) { if ($$resultat{$key} != 1) { $ps_status = 1; $num_ps_nok++; } $num_ps++; } if ($key =~ /$nokia_ps_temp/) { if ($$resultat{$key} != 1) { if ($ps_status == 0) { $ps_status = 2; $num_ps_nok++; } } } } if ($ps_status == 0) { $output .= ", " . $num_ps . " ps OK"; } elsif ($ps_status == 2) { $output .= ", " . $num_ps_nok . "/" . $num_ps . " ps WARNING (temp)"; if ($global_status != 2) { $global_status = 1; } } else { $output .= ", " . $num_ps_nok . "/" . $num_ps . " ps CRITICAL"; $global_status = 2; } } $session->close; verb("status : $global_status"); if (($fan_exist + $ps_exist + $temp_exist) == 0) { print "No environemental informations found : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } if ($global_status == 0) { print $output. " : all OK\n"; exit $ERRORS{"OK"}; } if ($global_status == 1) { print $output. " : WARNING\n"; exit $ERRORS{"WARNING"}; } if ($global_status == 2) { print $output. " : CRITICAL\n"; exit $ERRORS{"CRITICAL"}; } } ############# Bluecoat checks if ($o_check_type eq "bc") { verb("Checking bluecoat env"); my $resultat; my $global_status = 0; my ($num_fan, $num_other, $num_volt, $num_temp, $num_disk) = (0, 0, 0, 0, 0); my ($num_fan_ok, $num_other_ok, $num_volt_ok, $num_temp_ok, $num_disk_ok) = (0, 0, 0, 0, 0); my $output = ""; my $output_perf = ""; # get sensor table $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($bc_sensor_table) : $session->get_table(Baseoid => $bc_sensor_table); if (defined($resultat)) { verb("sensor table found"); my ($sens_name, $sens_status, $sens_value, $sens_unit) = (undef, undef, undef, undef); foreach my $key (keys %$resultat) { if ($key =~ /$bc_sensor_Name/) { $sens_name = $$resultat{$key}; $key =~ s/$bc_sensor_Name//; $sens_unit = $$resultat{ $bc_sensor_units . $key }; if ($$resultat{ $bc_sensor_Status . $key } != 1) { # sensor not operating : output and status unknown if ($output ne "") { $output .= ", "; } $output .= $sens_name . " sensor " . $bc_SensorStatus[$$resultat{ $bc_sensor_Status . $key }]; if ($global_status == 0) { $global_status = 3; } } else { # Get status $sens_status = $bc_status_nagios[$$resultat{ $bc_sensor_Code . $key }]; if ($sens_status != 0) { # warn/critical/unknown : output if ($output ne "") { $output .= ", "; } $output .= $sens_name . ":" . $bc_SensorCode[$sens_status]; set_status($sens_status, $global_status); } } if (defined($o_perf)) { if ($output_perf ne "") { $output_perf .= " "; } $output_perf .= "'" . $sens_name . "'="; my $perf_value = $$resultat{ $bc_sensor_Value . $key } * 10**$$resultat{ $bc_sensor_Scale . $key }; $output_perf .= $perf_value; } ### FAN if ($bc_mesure[$sens_unit] eq "rpm") { $num_fan++; if ($sens_status == 0) { $num_fan_ok++; } } elsif ($bc_mesure[$sens_unit] eq "celsius") { $num_fan++; if ($sens_status == 0) { $num_temp_ok++; } } elsif ($bc_mesure[$sens_unit] eq "volts") { $num_volt++; if ($sens_status == 0) { $num_volt_ok++; } } else { $num_other++; if ($sens_status == 0) { $num_other_ok++; } } } } } # Get disk table $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($bc_dsk_table) : $session->get_table(Baseoid => $bc_dsk_table); if (defined($resultat)) { foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); my ($dsk_name, $dsk_status) = (undef, undef, undef); if ($key =~ /$bc_dsk_status/) { $num_disk++; $dsk_status = $bc_dsk_status_nagios[$$resultat{$key}]; if ($dsk_status != 0) { $key =~ s/$bc_dsk_status//; $dsk_name = $$resultat{ $bc_dsk_vendor . $key } . "(" . $$resultat{ $bc_dsk_serial . $key } . ")"; if ($output ne "") { $output .= ", "; } $output .= $dsk_name . ":" . $bc_DiskStatus[$$resultat{ $bc_dsk_status . $key }]; set_status($dsk_status, $global_status); } else { $num_disk_ok++; } } } } if ($num_fan + $num_other + $num_volt + $num_temp + $num_disk == 0) { print "No information found : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } if ($output ne "") { $output .= ", "; } if ($num_fan_ok != 0) { $output .= $num_fan_ok . " fan OK "; } if ($num_other_ok != 0) { $output .= $num_other_ok . " other OK "; } if ($num_volt_ok != 0) { $output .= $num_volt_ok . " voltage OK "; } if ($num_temp_ok != 0) { $output .= $num_temp_ok . " temp OK "; } if ($num_disk_ok != 0) { $output .= $num_disk_ok . " disk OK "; } if (defined($o_perf)) { $output_perf = " | " . $output_perf; } if ($global_status == 3) { print $output, " : UNKNOWN", $output_perf, "\n"; exit $ERRORS{"UNKNOWN"}; } if ($global_status == 2) { print $output, " : CRITICAL", $output_perf, "\n"; exit $ERRORS{"CRITICAL"}; } if ($global_status == 1) { print $output, " : WARNING", $output_perf, "\n"; exit $ERRORS{"WARNING"}; } print $output, " : OK", $output_perf, "\n"; exit $ERRORS{"OK"}; } ############# Ironport checks if ($o_check_type eq "iron") { verb("Checking Ironport env"); my $resultat; # status : 0=ok, 1=warn, 2=crit my ($fan_status, $ps_status, $temp_status) = (0, 0, 0); my ($fan_exist, $ps_exist, $temp_exist) = (0, 0, 0); my ($num_fan, $num_ps, $num_temp) = (0, 0, 0); my ($num_fan_nok, $num_ps_nok, $num_temp_nok) = (0, 0, 0); my $global_status = 0; my $output = ""; # get temp if $o_temp is defined if (defined($o_temp)) { verb("Checking temp < $o_temp"); $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($iron_tmp_table) : $session->get_table(Baseoid => $iron_tmp_table); if (defined($resultat)) { verb("temp found"); $temp_exist = 1; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$iron_tmp_celcius/) { verb("Status : $$resultat{$key}"); if ($$resultat{$key} > $o_temp) { my @index_oid = split(/\./, $key); my $index_oid_key = pop(@index_oid); $output .= ",Temp : " . $$resultat{ $iron_tmp_name . "." . $index_oid_key } . " : " . $$resultat{$key} . " C"; $temp_status = 2; $num_temp_nok++; } $num_temp++; } } if ($temp_status == 0) { $output .= ", " . $num_temp . " temp < " . $o_temp . " OK"; } else { $output .= ", " . $num_temp_nok . "/" . $num_temp . " temp probes CRITICAL"; $global_status = 2; } } } # Get fan status if $o_fan is defined if (defined($o_fan)) { verb("Checking fan > $o_fan"); $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($iron_fan_table) : $session->get_table(Baseoid => $iron_fan_table); if (defined($resultat)) { verb("fan found"); $fan_exist = 1; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$iron_fan_rpm/) { verb("Status : $$resultat{$key}"); if ($$resultat{$key} < $o_fan) { my @index_oid = split(/\./, $key); my $index_oid_key = pop(@index_oid); $output .= ",Fan " . $$resultat{ $iron_fan_name . "." . $index_oid_key } . " : " . $$resultat{$key} . " RPM"; $fan_status = 2; $num_fan_nok++; } $num_fan++; } } if ($fan_status == 0) { $output .= ", " . $num_fan . " fan > " . $o_fan . " OK"; } else { $output .= ", " . $num_fan_nok . "/" . $num_fan . " fans CRITICAL"; $global_status = 2; } } } # Get power supply status verb("Checking PS"); $resultat = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($iron_ps_table) : $session->get_table(Baseoid => $iron_ps_table); if (defined($resultat)) { verb("ps found"); $ps_exist = 1; foreach my $key (keys %$resultat) { verb("OID : $key, Desc : $$resultat{$key}"); if ($key =~ /$iron_ps_status/) { verb("Status : $iron_ps_status_name[$$resultat{$key}]"); if ($iron_ps_status_nagios[$$resultat{$key}] != 0) { my @index_oid = split(/\./, $key); my $index_oid_key = pop(@index_oid); $output .= ",PS " . $$resultat{ $iron_ps_name . "." . $index_oid_key } . " : " . $iron_ps_status_name[$$resultat{$key}]; $ps_status = 2; $num_ps_nok++; } $num_ps++; } } if ($ps_status == 0) { $output .= ", " . $num_ps . " ps OK"; } else { $output .= ", " . $num_ps_nok . "/" . $num_ps . " ps CRITICAL"; $global_status = 2; } } $session->close; verb("status : $global_status"); if (($fan_exist + $ps_exist + $temp_exist) == 0) { print "No environemental informations found : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } $output =~ s/^,//; if ($global_status == 0) { print $output. " : all OK\n"; exit $ERRORS{"OK"}; } if ($global_status == 1) { print $output. " : WARNING\n"; exit $ERRORS{"WARNING"}; } if ($global_status == 2) { print $output. " : CRITICAL\n"; exit $ERRORS{"CRITICAL"}; } } ########### Foundry env checks ############## if ($o_check_type eq "foundry") { verb("Checking foundry env"); my $global_status = 0; # status to UNKNOWN my $output = ""; # Get temperature my @foundry_temp_oid = ($foundry_temp, $foundry_temp_warn, $foundry_temp_crit); my $result_temp = $session->get_request(Varbindlist => \@foundry_temp_oid); my $temp_found = 0; if (defined($result_temp)) { $temp_found = 1; #Temp found $output = "Temp : " . $$result_temp{$foundry_temp} / 2; if ($$result_temp{$foundry_temp} > $$result_temp{$foundry_temp_crit}) { # Temp above critical $output .= " > " . $$result_temp{$foundry_temp_crit} / 2 . " : CRITICAL"; $global_status = 3; } elsif ($$result_temp{$foundry_temp} > $$result_temp{$foundry_temp_warn}) { # Temp above warning $output .= " > " . $$result_temp{$foundry_temp_warn} / 2 . " : WARNING"; $global_status = 2; } else { $output .= " < " . $$result_temp{$foundry_temp_warn} / 2 . " : OK"; $global_status = 1; } } # Get PS table (TODO : Bug in FAN table, see with Foundry). my $result_ps = (version->parse(Net::SNMP->VERSION) < 4) ? $session->get_table($foundry_ps_table) : $session->get_table(Baseoid => $foundry_ps_table); my $ps_num = 0; if (defined($result_ps)) { $output .= ", " if defined($output); foreach my $key (keys %$result_ps) { verb("OID : $key, Desc : $$result_ps{$key}"); if ($$result_ps{$key} =~ /$foundry_ps_desc/) { $ps_num++; my @oid_list = split(/\./, $key); my $index_ps = pop(@oid_list); $index_ps = $foundry_ps_status . "." . $index_ps; if (defined($$result_ps{$index_ps})) { if ($$result_ps{$index_ps} == 3) { $output .= "PS " . $$result_ps{$key} . " : FAILURE"; $global_status = 3; } elsif ($$result_ps{$index_ps} == 2) { $global_status = 1 if ($global_status == 0); } else { $output .= "ps " . $$result_ps{$key} . " : OTHER"; } } else { $output .= "ps " . $$result_ps{$key} . " : UNDEFINED STATUS"; } } } } $session->close; if (($ps_num + $temp_found) == 0) { print "No data found : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } if ($global_status == 1) { print $output. " : all OK\n"; exit $ERRORS{"OK"}; } if ($global_status == 2) { print $output. " : WARNING\n"; exit $ERRORS{"WARNING"}; } if ($global_status == 3) { print $output. " : CRITICAL\n"; exit $ERRORS{"CRITICAL"}; } print $output. " : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } ########### Cisco env checks ############## if ($o_check_type eq "linux") { verb("Checking linux env"); print "Not implemented yet : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } print "Unknown check type : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_int.pl000077500000000000000000001205541302077243700224440ustar00rootroot00000000000000#!/usr/bin/perl -w ############################## check_snmp_int ############## my $VERSION = "2.0.0"; # Date : Oct 10 2007 # Author : Patrick Proy ( patrick at proy.org ) # Help : http://nagios.manubulon.com # License : GPL - http://www.fsf.org/licenses/gpl.txt # Contrib : J. Jungmann, S. Probst, R. Leroy, M. Berger # TODO : # Maybe put base directory for performance as an option ################################################################# # # Help : ./check_snmp_int.pl -h # use strict; use Net::SNMP; use Getopt::Long; ############### BASE DIRECTORY FOR TEMP FILE ######## my $o_base_dir = "/tmp/tmp_Icinga_int."; my $file_history = 200; # number of data to keep in files. # Icinga specific my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); # split big SNMP requests to smaller ones my $snmp_splice_size = 50; # SNMP Datas my $inter_table = '.1.3.6.1.2.1.2.2.1'; my $index_table = '1.3.6.1.2.1.2.2.1.1'; my $descr_table = '1.3.6.1.2.1.2.2.1.2'; my $name_table = '1.3.6.1.2.1.31.1.1.1.1'; my $alias_table = '.1.3.6.1.2.1.31.1.1.1.18'; my $oper_table = '1.3.6.1.2.1.2.2.1.8.'; my $admin_table = '1.3.6.1.2.1.2.2.1.7.'; my $speed_table = '1.3.6.1.2.1.2.2.1.5.'; my $speed_table_64 = '1.3.6.1.2.1.31.1.1.1.15.'; my $in_octet_table = '1.3.6.1.2.1.2.2.1.10.'; my $in_octet_table_64 = '1.3.6.1.2.1.31.1.1.1.6.'; my $in_error_table = '1.3.6.1.2.1.2.2.1.14.'; my $in_discard_table = '1.3.6.1.2.1.2.2.1.13.'; my $out_octet_table = '1.3.6.1.2.1.2.2.1.16.'; my $out_octet_table_64 = '1.3.6.1.2.1.31.1.1.1.10.'; my $out_error_table = '1.3.6.1.2.1.2.2.1.20.'; my $out_discard_table = '1.3.6.1.2.1.2.2.1.19.'; my %status = ( 1 => 'UP', 2 => 'DOWN', 3 => 'TESTING', 4 => 'UNKNOWN', 5 => 'DORMANT', 6 => 'NotPresent', 7 => 'lowerLayerDown' ); # Globals # Standard options my $o_host = undef; # hostname my $o_port = 161; # port my $o_descr = undef; # description filter my $o_help = undef; # wan't some help ? my $o_admin = undef; # admin status instead of oper my $o_inverse = undef; # Critical when up my $o_dormant = undef; # Dormant state is OK my $o_down = undef; # Down state is OK my $o_verb = undef; # verbose mode my $o_version = undef; # print version my $o_noreg = undef; # Do not use Regexp for name my $o_short = undef; # set maximum of n chars to be displayed my $o_label = undef; # add label before speed (in, out, etc...). # Performance data options my $o_perf = undef; # Output performance data my $o_perfe = undef; # Output discard/error also in perf data my $o_perfs = undef; # include speed in performance output (-S) my $o_perfp = undef; # output performance data in % of max speed (-y) my $o_perfr = undef; # output performance data in bits/s or Bytes/s (-Y) # Speed/error checks my $o_checkperf = undef; # checks in/out/err/disc values my $o_delta = 300; # delta of time of perfcheck (default 5min) my $o_ext_checkperf = undef; # extended perf checks (+error+discard) my $o_warn_opt = undef; # warning options my $o_crit_opt = undef; # critical options my $o_kbits = undef; # Warn and critical in Kbits instead of KBytes my @o_warn = undef; # warning levels of perfcheck my @o_crit = undef; # critical levels of perfcheck my $o_highperf = undef; # Use 64 bits counters my $o_meg = undef; # output in MBytes or Mbits (-M) my $o_gig = undef; # output in GBytes or Gbits (-G) my $o_prct = undef; # output in % of max speed (-u) my $o_use_ifname = undef; # use IF-MIB::ifName instead of IF-MIB::ifDescr my $o_use_ifalias = undef; # use IF-MIB::ifAlias instead of IF-MIB::ifDescr my $o_timeout = undef; # Timeout (Default 5) # SNMP Message size parameter (Makina Corpus contrib) my $o_octetlength = undef; # Login options specific my $o_community = undef; # community my $o_version2 = undef; #use snmp v2c 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 # Readable names for counters (M. Berger contrib) my @countername = ("in=", "out=", "errors-in=", "errors-out=", "discard-in=", "discard-out="); my $checkperf_out_desc; # functions 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 = ) { 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 p_version { print "check_snmp_int version : $VERSION\n"; } sub print_usage { print "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,) [-p ] -n [-N -A -i -a -D --down] [-r] [-f[eSyY]] [-k[qBMGu] -g -w -c -d] [-o ] [-t ] [-s] --label [-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 Network Interface Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; print "GPL license, (c)2004-2007 Patrick Proy\n\n"; print_usage(); print <, : Authentication protocol (md5|sha : default md5) : Priv protocole (des|aes : default des) -P, --port=PORT SNMP port (Default 161) -n, --name=NAME Name in description OID (eth0, ppp0 ...). This is treated as a regexp : -n eth will match eth0,eth1,... Test it before, because there are known bugs (ex : trailling /) -r, --noregexp Do not use regexp to match NAME in description OID -N, --use-ifname Use IF-MIB::ifName as source for NIC name instead of IF-MIB::ifDescr -A, --use-ifalias Use IF-MIB::ifAlias as source for NIC name instead of IF-MIB::ifDescr -i, --inverse Make critical when up -a, --admin Use administrative status instead of operational -D, --dormant Dormant state is an OK state --down Down state is an OK state -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. -f, --perfparse, --perfdata Performance data output (no output when interface is down). -e, --error Add error & discard to Perfparse output -S, --intspeed Include speed in performance output in bits/s -y, --perfprct ; -Y, --perfspeed -y : output performance data in % of max speed -Y : output performance data in bits/s or Bytes/s (depending on -B) -k, --perfcheck ; -q, --extperfcheck -k check the input/ouput bandwidth of the interface -q also check the error and discard input/output --label Add label before speed in output : in=, out=, errors-out=, etc... -g, --64bits Use 64 bits counters instead of the standard counters when checking bandwidth & performance data for interface >= 1Gbps. You must use snmp v2c or v3 to get 64 bits counters. -d, --delta=seconds make an average of seconds (default 300=5min) -B, --kbits Make the warning and critical levels in K|M|G Bits/s instead of K|M|G Bytes/s -G, --giga ; -M, --mega ; -u, --prct -G : Make the warning and critical levels in Gbps (with -B) or GBps -M : Make the warning and critical levels in Mbps (with -B) or MBps -u : Make the warning and critical levels in % of reported interface speed. -w, --warning=input,output[,error in,error out,discard in,discard out] warning level for input / output bandwidth (0 for no warning) unit depends on B,M,G,u options warning for error & discard input / output in error/min (need -q) -c, --critical=input,output[,error in,error out,discard in,discard out] critical level for input / output bandwidth (0 for no critical) unit depends on B,M,G,u options critical for error & discard input / output in error/min (need -q) -s, --short=int Make the output shorter : only the first chars of the interface(s) If the number is negative, then get the LAST caracters. -t, --timeout=INTEGER timeout for SNMP in seconds (Default: 5) -V, --version prints version number Note : when multiple interface are selected with regexp, all be must be up (or down with -i) to get an OK result. 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, 'n:s' => \$o_descr, 'name:s' => \$o_descr, 'N' => \$o_use_ifname, 'use-ifname' => \$o_use_ifname, 'A' => \$o_use_ifalias, 'use-ifalias' => \$o_use_ifalias, '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, 'i' => \$o_inverse, 'inverse' => \$o_inverse, 'a' => \$o_admin, 'admin' => \$o_admin, 'r' => \$o_noreg, 'noregexp' => \$o_noreg, 'V' => \$o_version, 'version' => \$o_version, 'f' => \$o_perf, 'perfparse' => \$o_perf, 'perfdata' => \$o_perf, 'e' => \$o_perfe, 'error' => \$o_perfe, 'k' => \$o_checkperf, 'perfcheck' => \$o_checkperf, 'q' => \$o_ext_checkperf, 'extperfcheck' => \$o_ext_checkperf, 'w:s' => \$o_warn_opt, 'warning:s' => \$o_warn_opt, 'c:s' => \$o_crit_opt, 'critical:s' => \$o_crit_opt, 'B' => \$o_kbits, 'kbits' => \$o_kbits, 's:i' => \$o_short, 'short:i' => \$o_short, 'g' => \$o_highperf, '64bits' => \$o_highperf, 'S' => \$o_perfs, 'intspeed' => \$o_perfs, 'y' => \$o_perfp, 'perfprct' => \$o_perfp, 'Y' => \$o_perfr, 'perfspeed' => \$o_perfr, 'M' => \$o_meg, 'mega' => \$o_meg, 'G' => \$o_gig, 'giga' => \$o_gig, 'u' => \$o_prct, 'prct' => \$o_prct, 'o:i' => \$o_octetlength, 'octetlength:i' => \$o_octetlength, 'label' => \$o_label, 'd:i' => \$o_delta, 'delta:i' => \$o_delta, 'D' => \$o_dormant, 'dormant' => \$o_dormant, 'down' => \$o_down ); if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } if (!defined($o_descr) || !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_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 snmpv2c or v3 with 64 bit counters if (defined($o_highperf) && (!defined($o_version2) && defined($o_community))) { print "Can't get 64 bit counters with snmp version 1\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if (defined($o_highperf)) { if (eval "require bigint") { use bigint; } else { print "Need bigint module for 64 bit counters\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } } # check if -e without -f if (defined($o_perfe) && !defined($o_perf)) { print "Cannot output error without -f option!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if (defined($o_perfr) && defined($o_perfp)) { print "-Y and -y options are exclusives\n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if ((defined($o_perfr) || defined($o_perfp)) && !defined($o_checkperf)) { print "Cannot put -Y or -y options without perf check option (-k) \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if (defined($o_short)) { #TODO maybe some basic tests ? caracters return empty string } if (defined($o_checkperf)) { @o_warn = split(/,/, $o_warn_opt); if (defined($o_ext_checkperf) && ($#o_warn != 5)) { print "6 warning levels for extended checks \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if (!defined($o_ext_checkperf) && ($#o_warn != 1)) { print "2 warning levels for bandwidth checks \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } @o_crit = split(/,/, $o_crit_opt); #verb(" $o_crit_opt :: $#o_crit : @o_crit"); if (defined($o_ext_checkperf) && ($#o_crit != 5)) { print "6 critical levels for extended checks \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } if (!defined($o_ext_checkperf) && ($#o_crit != 1)) { print "2 critical levels for bandwidth checks \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } for (my $i = 0; $i <= $#o_warn; $i++) { if (($o_crit[$i] != 0) && ($o_warn[$i] > $o_crit[$i])) { print "Warning must be < Critical level \n"; print_usage(); exit $ERRORS{"UNKNOWN"}; } } if ( (defined($o_meg) && defined($o_gig)) || (defined($o_meg) && defined($o_prct)) || (defined($o_gig) && defined($o_prct))) { print "-M -G and -u options are exclusives\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"}; } } ########## 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, -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, -authpassword => $o_passwd, -authprotocol => $o_authproto, -privpassword => $o_privpass, -privprotocol => $o_privproto, -timeout => $o_timeout ); } } else { if (defined($o_version2)) { # SNMPv2c 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"}; } 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"); } # Get description table my $query_table = $descr_table; if (defined($o_use_ifalias) and defined($o_use_ifname)) { printf("ERROR: Options -N and -A are exclusive. Please select only one.\n"); $session->close; exit $ERRORS{"UNKNOWN"}; } if (defined($o_use_ifname)) { $query_table = $name_table; } if (defined($o_use_ifalias)) { $query_table = $alias_table; } my $resultat = $session->get_table(Baseoid => $query_table); if (!defined($resultat)) { printf("ERROR: Description table : %s.\n", $session->error); $session->close; exit $ERRORS{"UNKNOWN"}; } my @tindex = undef; my @oids = undef; my @descr = undef; my ( @oid_perf, @oid_perf_outoct, @oid_perf_inoct, @oid_perf_inerr, @oid_perf_outerr, @oid_perf_indisc, @oid_perf_outdisc ) = (undef, undef, undef, undef, undef, undef, undef); my @oid_speed = undef; my @oid_speed_high = undef; my $num_int = 0; # Change to 64 bit counters if option is set : if (defined($o_highperf)) { $out_octet_table = $out_octet_table_64; $in_octet_table = $in_octet_table_64; } # Select interface 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 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}; # Get rid of special caracters (specially for Windows) $descr[$num_int] =~ s/[[:cntrl:]]//g; # put the admin or oper oid in an array $oids[$num_int] = defined($o_admin) ? $admin_table . $tindex[$num_int] : $oper_table . $tindex[$num_int]; # Put the performance oid if (defined($o_perf) || defined($o_checkperf)) { $oid_perf_inoct[$num_int] = $in_octet_table . $tindex[$num_int]; $oid_perf_outoct[$num_int] = $out_octet_table . $tindex[$num_int]; $oid_speed[$num_int] = $speed_table . $tindex[$num_int]; $oid_speed_high[$num_int] = $speed_table_64 . $tindex[$num_int]; if (defined($o_ext_checkperf) || defined($o_perfe)) { $oid_perf_indisc[$num_int] = $in_discard_table . $tindex[$num_int]; $oid_perf_outdisc[$num_int] = $out_discard_table . $tindex[$num_int]; $oid_perf_inerr[$num_int] = $in_error_table . $tindex[$num_int]; $oid_perf_outerr[$num_int] = $out_error_table . $tindex[$num_int]; } } verb("Name : $descr[$num_int], Index : $tindex[$num_int]"); $num_int++; } } # No interface found -> error if ($num_int == 0) { print "ERROR : Unknown interface $o_descr\n"; exit $ERRORS{"UNKNOWN"}; } my $result = undef; # Add performance oids if requested if (defined($o_perf) || defined($o_checkperf)) { @oids = (@oids, @oid_perf_outoct, @oid_perf_inoct, @oid_speed); if (defined($o_highperf)) { @oids = (@oids, @oid_speed_high); } if (defined($o_ext_checkperf) || defined($o_perfe)) { @oids = (@oids, @oid_perf_inerr, @oid_perf_outerr, @oid_perf_indisc, @oid_perf_outdisc); } } # Get the requested oid values while (my @oids_part = splice(@oids, 0, $snmp_splice_size)) { my $result_part = $session->get_request(Varbindlist => \@oids_part); if (!defined($result_part)) { printf("ERROR: Status/statistics table : %s.\n ", $session->error); $session->close; exit $ERRORS{"UNKNOWN"}; } $result = defined($result) ? { %$result, %$result_part } : $result_part; } $session->close; my $num_ok = 0; my @checkperf_out = undef; my @checkperf_out_raw = undef; ### Bandwidth test variables my $temp_file_name; my ($return, @file_values) = (undef, undef); my $n_rows = 0; my $n_items_check = (defined($o_ext_checkperf)) ? 7 : 3; my $timenow = time; my $trigger = $timenow - ($o_delta - ($o_delta / 10)); my $trigger_low = $timenow - 3 * $o_delta; my ($old_value, $old_time) = undef; my $speed_unit = undef; my $speed_real = undef; # speed of interface using either standard or highperf mib. # define the OK value depending on -i option my $ok_val = defined($o_inverse) ? 2 : 1; my $final_status = 0; my ($print_out, $perf_out) = (undef, undef); # make all checks and output for all interfaces for (my $i = 0; $i < $num_int; $i++) { $print_out .= ", " if (defined($print_out)); $perf_out .= " " if (defined($perf_out)); my $usable_data = 1; # Get the status of the current interface my $int_status = defined($o_admin) ? $$result{ $admin_table . $tindex[$i] } : $$result{ $oper_table . $tindex[$i] }; # Make the bandwith & error checks if necessary if (defined($o_checkperf) && $int_status == 1) { $temp_file_name = $descr[$i]; $temp_file_name =~ s/[ ;\/]/_/g; $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"); # Get the speed in normal or highperf speed counters if ($$result{ $oid_speed[$i] } == 4294967295) { # Too high for this counter (cf IF-MIB) if (!defined($o_highperf) && (defined($o_prct) || defined($o_perfs) || defined($o_perfp))) { print "Cannot get interface speed with standard MIB, use highperf mib (-g) : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } if (defined($$result{ $oid_speed_high[$i] }) && $$result{ $oid_speed_high[$i] } != 0) { $speed_real = $$result{ $oid_speed_high[$i] } * 1000000; } else { print "Cannot get interface speed using highperf mib : UNKNOWN\n"; exit $ERRORS{"UNKNOWN"}; } } else { $speed_real = $$result{ $oid_speed[$i] }; } verb("Interface speed : $speed_real"); #make the checks if the file is OK if ($return == 0) { my $j = $n_rows - 1; @checkperf_out = undef; @checkperf_out_raw = undef; do { if ($file_values[$j][0] < $trigger) { if ($file_values[$j][0] > $trigger_low) { # Define the speed metric ( K | M | G ) (Bits|Bytes) or % my $speed_metric = undef; if (defined($o_prct)) { # in % of speed # Speed is in bits/s, calculated speed is in Bytes/s $speed_metric = $speed_real / 800; $speed_unit = "%"; } else { if (defined($o_kbits)) { # metric in bits if (defined($o_meg)) { # in Mbit/s = 1000000 bit/s $speed_metric = 125000; # (1000/8) * 1000 $speed_unit = "Mbps"; } elsif (defined($o_gig)) { # in Gbit/s = 1000000000 bit/s $speed_metric = 125000000; # (1000/8) * 1000 * 1000 $speed_unit = "Gbps"; } else { # in Kbits $speed_metric = 125; # ( 1000/8 ) $speed_unit = "Kbps"; } } else { # metric in byte if (defined($o_meg)) { # in Mbits $speed_metric = 1048576; # 1024^2 $speed_unit = "MBps"; } elsif (defined($o_gig)) { # in Mbits $speed_metric = 1073741824; # 1024^3 $speed_unit = "GBps"; } else { $speed_metric = 1024; # 1024^3 $speed_unit = "KBps"; } } } # check if the counter is back to 0 after 2^32 / 2^64. # First set the modulus depending on highperf counters or not my $overfl_mod = defined($o_highperf) ? 18446744073709551616 : 4294967296; # Check counter (s) my $overfl = ($$result{ $oid_perf_inoct[$i] } >= $file_values[$j][1]) ? 0 : $overfl_mod; $checkperf_out_raw[0] = (($overfl + $$result{ $oid_perf_inoct[$i] } - $file_values[$j][1]) / ($timenow - $file_values[$j][0])); $checkperf_out[0] = $checkperf_out_raw[0] / $speed_metric; $overfl = ($$result{ $oid_perf_outoct[$i] } >= $file_values[$j][2]) ? 0 : $overfl_mod; $checkperf_out_raw[1] = (($overfl + $$result{ $oid_perf_outoct[$i] } - $file_values[$j][2]) / ($timenow - $file_values[$j][0])); $checkperf_out[1] = $checkperf_out_raw[1] / $speed_metric; if (defined($o_ext_checkperf)) { $checkperf_out[2] = (($$result{ $oid_perf_inerr[$i] } - $file_values[$j][3]) / ($timenow - $file_values[$j][0])) * 60; $checkperf_out[3] = (($$result{ $oid_perf_outerr[$i] } - $file_values[$j][4]) / ($timenow - $file_values[$j][0])) * 60; $checkperf_out[4] = (($$result{ $oid_perf_indisc[$i] } - $file_values[$j][5]) / ($timenow - $file_values[$j][0])) * 60; $checkperf_out[5] = (($$result{ $oid_perf_outdisc[$i] } - $file_values[$j][6]) / ($timenow - $file_values[$j][0])) * 60; } } } $j--; } while (($j >= 0) && (!defined($checkperf_out[0]))); } # Put the new values in the array and write the file $file_values[$n_rows][0] = $timenow; $file_values[$n_rows][1] = $$result{ $oid_perf_inoct[$i] }; $file_values[$n_rows][2] = $$result{ $oid_perf_outoct[$i] }; if (defined($o_ext_checkperf)) { # Add other values (error & disc) $file_values[$n_rows][3] = $$result{ $oid_perf_inerr[$i] }; $file_values[$n_rows][4] = $$result{ $oid_perf_outerr[$i] }; $file_values[$n_rows][5] = $$result{ $oid_perf_indisc[$i] }; $file_values[$n_rows][6] = $$result{ $oid_perf_outdisc[$i] }; } $n_rows++; $return = write_file($temp_file_name, $n_rows, $n_items_check, @file_values); verb("Write file returned : $return"); # Print the basic status if (defined($o_short)) { my $short_desc = undef; if ($o_short < 0) { $short_desc = substr($descr[$i], $o_short); } else { $short_desc = substr($descr[$i], 0, $o_short); } $print_out .= sprintf("%s:%s", $short_desc, $status{$int_status}); } else { $print_out .= sprintf("%s:%s", $descr[$i], $status{$int_status}); } if ($return != 0) { # On error writing, return Unknown status $final_status = 3; $print_out .= " !!Unable to write file " . $temp_file_name . " !! "; } # print the other checks if it was calculated if (defined($checkperf_out[0])) { $print_out .= " ("; # check 2 or 6 values depending on ext_check_perf my $num_checkperf = (defined($o_ext_checkperf)) ? 6 : 2; for (my $l = 0; $l < $num_checkperf; $l++) { # Set labels if needed $checkperf_out_desc = (defined($o_label)) ? $countername[$l] : ""; verb("Interface $i, check $l : $checkperf_out[$l]"); if ($l != 0) { $print_out .= "/"; } if (($o_crit[$l] != 0) && ($checkperf_out[$l] > $o_crit[$l])) { $final_status = 2; $print_out .= sprintf("CRIT %s%.1f", $checkperf_out_desc, $checkperf_out[$l]); } elsif (($o_warn[$l] != 0) && ($checkperf_out[$l] > $o_warn[$l])) { $final_status = ($final_status == 2) ? 2 : 1; $print_out .= sprintf("WARN %s%.1f", $checkperf_out_desc, $checkperf_out[$l]); } else { $print_out .= sprintf("%s%.1f", $checkperf_out_desc, $checkperf_out[$l]); } if ($l == 0 || $l == 1) { $print_out .= $speed_unit; } } $print_out .= ")"; } else { # Return unknown when no data $print_out .= " No usable data on file (" . $n_rows . " rows) "; $final_status = 3; $usable_data = 0; } } else { if (defined($o_short)) { my $short_desc = undef; if ($o_short < 0) { $short_desc = substr($descr[$i], $o_short); } else { $short_desc = substr($descr[$i], 0, $o_short); } $print_out .= sprintf("%s:%s", $short_desc, $status{$int_status}); } else { $print_out .= sprintf("%s:%s", $descr[$i], $status{$int_status}); } } # Get rid of special caracters for performance in description $descr[$i] =~ s/'\/\(\)/_/g; if (($int_status == $ok_val) || (defined($o_down) && $int_status == 2) || (defined($o_dormant) && $int_status == 5)) { $num_ok++; } if (($int_status == 1) && defined($o_perf)) { if (defined($o_perfp)) { # output in % of speed if ($usable_data == 1) { my $warn_factor = 1; if (!defined($o_prct)) { # warn&crit in K|M|G B|bps -> put warn_factor to make % $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000; if (!defined($o_kbits)) { $warn_factor *= 8; } $warn_factor /= $speed_real; $warn_factor *= 100; # now turn into displayed % : 0,1 = 10% } $perf_out .= "'" . $descr[$i] . "_in_prct'="; $perf_out .= sprintf("%.0f", $checkperf_out_raw[0] * 800 / $speed_real) . "%;"; $perf_out .= ($o_warn[0] != 0) ? sprintf("%.0f", $o_warn[0] * $warn_factor) . ";" : ";"; $perf_out .= ($o_crit[0] != 0) ? sprintf("%.0f", $o_crit[0] * $warn_factor) . ";" : ";"; $perf_out .= "0;100 "; $perf_out .= "'" . $descr[$i] . "_out_prct'="; $perf_out .= sprintf("%.0f", $checkperf_out_raw[1] * 800 / $speed_real) . "%;"; $perf_out .= ($o_warn[1] != 0) ? sprintf("%.0f", $o_warn[1] * $warn_factor) . ";" : ";"; $perf_out .= ($o_crit[1] != 0) ? sprintf("%.0f", $o_crit[1] * $warn_factor) . ";" : ";"; $perf_out .= "0;100 "; } } elsif (defined($o_perfr)) { # output in bites or Bytes /s if ($usable_data == 1) { if (defined($o_kbits)) { # bps # put warning and critical levels into bps or Bps my $warn_factor; if (defined($o_prct)) { # warn&crit in % -> put warn_factor to 1% of speed in bps $warn_factor = $speed_real / 100; } else { # just convert from K|M|G bps $warn_factor = (defined($o_meg)) ? 1000000 : (defined($o_gig)) ? 1000000000 : 1000; } $perf_out .= "'" . $descr[$i] . "_in_bps'="; $perf_out .= sprintf("%.0f", $checkperf_out_raw[0] * 8) . ";"; $perf_out .= ($o_warn[0] != 0) ? $o_warn[0] * $warn_factor . ";" : ";"; $perf_out .= ($o_crit[0] != 0) ? $o_crit[0] * $warn_factor . ";" : ";"; $perf_out .= "0;" . $speed_real . " "; $perf_out .= "'" . $descr[$i] . "_out_bps'="; $perf_out .= sprintf("%.0f", $checkperf_out_raw[1] * 8) . ";"; $perf_out .= ($o_warn[1] != 0) ? $o_warn[1] * $warn_factor . ";" : ";"; $perf_out .= ($o_crit[1] != 0) ? $o_crit[1] * $warn_factor . ";" : ";"; $perf_out .= "0;" . $speed_real . " "; } else { # Bps my $warn_factor; if (defined($o_prct)) { # warn&crit in % -> put warn_factor to 1% of speed in Bps $warn_factor = $speed_real / 800; } else { # just convert from K|M|G bps $warn_factor = (defined($o_meg)) ? 1048576 : (defined($o_gig)) ? 1073741824 : 1024; } $perf_out .= "'" . $descr[$i] . "_in_Bps'=" . sprintf("%.0f", $checkperf_out_raw[0]) . ";"; $perf_out .= ($o_warn[0] != 0) ? $o_warn[0] * $warn_factor . ";" : ";"; $perf_out .= ($o_crit[0] != 0) ? $o_crit[0] * $warn_factor . ";" : ";"; $perf_out .= "0;" . $speed_real / 8 . " "; $perf_out .= "'" . $descr[$i] . "_out_Bps'=" . sprintf("%.0f", $checkperf_out_raw[1]) . ";"; $perf_out .= ($o_warn[1] != 0) ? $o_warn[1] * $warn_factor . ";" : ";"; $perf_out .= ($o_crit[1] != 0) ? $o_crit[1] * $warn_factor . ";" : ";"; $perf_out .= "0;" . $speed_real / 8 . " "; } } } else { # output in octet counter $perf_out .= "'" . $descr[$i] . "_in_octet'=" . $$result{ $oid_perf_inoct[$i] } . "c "; $perf_out .= "'" . $descr[$i] . "_out_octet'=" . $$result{ $oid_perf_outoct[$i] } . "c "; } if (defined($o_perfe)) { $perf_out .= "'" . $descr[$i] . "_in_error'=" . $$result{ $oid_perf_inerr[$i] } . "c "; $perf_out .= "'" . $descr[$i] . "_in_discard'=" . $$result{ $oid_perf_indisc[$i] } . "c "; $perf_out .= "'" . $descr[$i] . "_out_error'=" . $$result{ $oid_perf_outerr[$i] } . "c "; $perf_out .= "'" . $descr[$i] . "_out_discard'=" . $$result{ $oid_perf_outdisc[$i] } . "c "; } if (defined($o_perfs)) { $perf_out .= "'" . $descr[$i] . "_speed_bps'=" . $speed_real; } } } # Only a few ms left... alarm(0); # Check if all interface are OK if ($num_ok == $num_int) { if ($final_status == 0) { print $print_out, ":", $num_ok, " UP: OK"; if (defined($o_perf)) { print " | ", $perf_out; } print "\n"; exit $ERRORS{"OK"}; } elsif ($final_status == 1) { print $print_out, ":(", $num_ok, " UP): WARNING"; if (defined($o_perf)) { print " | ", $perf_out; } print "\n"; exit $ERRORS{"WARNING"}; } elsif ($final_status == 2) { print $print_out, ":(", $num_ok, " UP): CRITICAL"; if (defined($o_perf)) { print " | ", $perf_out; } print "\n"; exit $ERRORS{"CRITICAL"}; } else { print $print_out, ":(", $num_ok, " UP): UNKNOWN"; if (defined($perf_out)) { print " | ", $perf_out; } print "\n"; exit $ERRORS{"UNKNOWN"}; } } # else print the not OK interface number and exit (return is always critical if at least one int is down). print $print_out, ": ", $num_int - $num_ok, " int NOK : CRITICAL"; if (defined($perf_out)) { print " | ", $perf_out; } print "\n"; exit $ERRORS{"CRITICAL"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_linkproof_nhr.pl000077500000000000000000000267471302077243700245350ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-f] [-t ] [-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 <, : Authentication protocol (md5|sha : default md5) : 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"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_load.pl000077500000000000000000000677761302077243700226110ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -w -c -T=[stand|netsl|netsc|as400|cisco|cata|nsc|fg|bc|nokia|hp|lp|hpux] [-f] [-t ] [-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 <, : Authentication protocol (md5|sha : default md5) : 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; nagios-snmp-plugins-2.0.0/plugins/check_snmp_mem.pl000077500000000000000000000531671302077243700224350ustar00rootroot00000000000000#!/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 -H -m "^Virtual Memory$" -w -c # 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 -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-P ] -w -c [-I|-N|-E] [-f] [-m -b] [-t ] [-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 <, : Authentication protocol (md5|sha : default md5) : 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}; } nagios-snmp-plugins-2.0.0/plugins/check_snmp_nsbox.pl000077500000000000000000000337101302077243700230000ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd [-X pass -L ,]) -d -s -n , [-p ] [-f] [-t ] [-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 "" 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 <, : Authentication protocol (md5|sha : default md5) : Priv protocole (des|aes : default des) -d, --diode= Diode selection by regexp -s, --vhost= Vhost selection by regexp -n, --number=, 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"}; nagios-snmp-plugins-2.0.0/plugins/check_snmp_process.pl000077500000000000000000000750521302077243700233320ustar00rootroot00000000000000#!/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 -C [-2] | (-l login -x passwd) [-p ] [-P ] -n [-w [,] -c [,max_proc] ] [-m, -a -u, -d ] [-t ] [-o ] [-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 = ) { 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 <, : Authentication protocol (md5|sha : default md5) : 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 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 :