├── doc ├── html │ ├── nagios.manubulon.com │ │ ├── robots.txt │ │ ├── snmp_int.html │ │ ├── snmp_vrrp.html │ │ ├── img │ │ │ ├── sideback.jpg │ │ │ └── smalllogo7.jpg │ │ ├── snmp_process.html │ │ ├── snmp_storage.html │ │ ├── snmp_windows.html │ │ ├── p1-print.pl.patch │ │ ├── nagios_cert.cer │ │ ├── package_c.html │ │ ├── snmp_mem.html │ │ ├── snmp_env.html │ │ ├── snmp_css.html │ │ ├── snmp_cpfw.html │ │ ├── snmp_load.html │ │ └── faq.html │ └── README.md ├── 01-About.md ├── 02-Installation.md └── 03-Configuration.md ├── icingaexchange.yml ├── .perltidyrc ├── .github └── ISSUE_TEMPLATE.md ├── README.md ├── CHANGELOG.md ├── plugins ├── install.sh ├── check_snmp_css_main.pl ├── check_snmp_linkproof_nhr.pl ├── check_snmp_boostedge.pl ├── check_snmp_win.pl └── check_snmp_nsbox.pl └── LICENSE /doc/html/nagios.manubulon.com/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_int.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/snmp_int.html -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_vrrp.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/snmp_vrrp.html -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/img/sideback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/img/sideback.jpg -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_process.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/snmp_process.html -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_storage.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/snmp_storage.html -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_windows.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/snmp_windows.html -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/img/smalllogo7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SteScho/manubulon-snmp/HEAD/doc/html/nagios.manubulon.com/img/smalllogo7.jpg -------------------------------------------------------------------------------- /icingaexchange.yml: -------------------------------------------------------------------------------- 1 | name: manubulon-snmp 2 | description: "file:///README.md" 3 | url: "https://github.com/dnsmichi/manubulon-snmp" 4 | tags: SNMP,Storage,Network,Windows,NAS 5 | vendor: Linux,Cisco,HP,Fortinet,Juniper 6 | target: Operating System,Snmp,Storage,Network 7 | type: Plugin 8 | license: gpl 9 | -------------------------------------------------------------------------------- /doc/html/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a copy of nagios.manubulon.com 2 | with stripped binary files and removed french nagios docs. 3 | 4 | # wget command 5 | 6 | wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains nagios.manubulon.com --no-parent http://nagios.manubulon.com 7 | -------------------------------------------------------------------------------- /.perltidyrc: -------------------------------------------------------------------------------- 1 | ## basic options 2 | --maximum-line-length=120 3 | --indent-columns=4 4 | 5 | ## code indentation control 6 | --continuation-indentation=4 7 | 8 | ## whilespace control 9 | --paren-tightness=2 10 | --square-bracket-tightness=2 11 | --block-brace-tightness=0 12 | --nospace-for-semicolon 13 | #--add-semicolons 14 | --nospace-function-paren 15 | 16 | ## line break control 17 | --cuddled-else 18 | 19 | #--closing-token-indentation=0 20 | #--nooutdent-long-quotes 21 | #--nooutdent-labels 22 | #--brace-tightness=1 23 | #--vertical-tightness=0 24 | #--stack-opening-tokens 25 | #--stack-closing-tokens 26 | --want-break-before="% + - * / x != == >= <= =~ !~ < > | & = **= += *= &= <<= &&= -= /= |= >>= ||= //= .= %= ^= x=" 27 | #--format-skipping-begin="#+\s*no tidy" 28 | #--format-skipping-end="#+\s*tidy" 29 | -------------------------------------------------------------------------------- /doc/01-About.md: -------------------------------------------------------------------------------- 1 | # About Manubulon SNMP Plugins 2 | 3 | Manubulon SNMP plugins is a set of Icinga/Nagios plugins 4 | to check hosts/devices using the SNMP protocol. 5 | 6 | Please find more insights in the following chapters: 7 | 8 | * [Installation](02-Installation.md) 9 | * [Configuration](03-Configuration.md) 10 | * [Plugins](04-Plugins.md) 11 | 12 | 13 | 14 | ## History 15 | 16 | These plugins have been written by Patrick Proy several years ago. 17 | 18 | Many community members still use them, but development and patches 19 | stopped. 20 | 21 | I've used these plugins in my previous job, and decided to fork them 22 | into this repository. Many patches have been applied, and put into 23 | official releases for packagers. 24 | 25 | This is reflected by moving each plugin into a v2.x version although 26 | there are not so many changes. 27 | 28 | I don't have a test system/hardware nor do much with these plugins these days. 29 | Still this repository allows community members to send in their patches 30 | and discuss bugs and feature requests. 31 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/p1-print.pl.patch: -------------------------------------------------------------------------------- 1 | --- p1.pl.dist 2006-03-21 11:42:30.000000000 +1100 2 | +++ p1.pl 2006-03-21 11:56:16.000000000 +1100 3 | @@ -69,27 +69,29 @@ 4 | 5 | sub TIEHANDLE { 6 | my ($class) = @_; 7 | - my $me ; 8 | + my $me = ''; 9 | bless \$me, $class; 10 | } 11 | 12 | sub PRINT { 13 | my $self = shift; 14 | - $$self = substr(join('',@_), 0, 256) ; 15 | - # $$self .= substr(join('',@_), 0, 256) ; 16 | + # $$self = substr(join('',@_), 0, 256) ; 17 | + $$self .= substr(join('',@_), 0, 256) ; 18 | } 19 | 20 | sub PRINTF { 21 | my $self = shift; 22 | my $fmt = shift; 23 | - $$self = substr(sprintf($fmt,@_), 0, 256) ; 24 | - # $$self .= substr(sprintf($fmt,@_), 0, 256) ; 25 | + # $$self = substr(sprintf($fmt,@_), 0, 256) ; 26 | + $$self .= substr(sprintf($fmt,@_), 0, 256) ; 27 | } 28 | 29 | sub READLINE { 30 | my $self = shift; 31 | + # Omit all lines after the first, per the nagios plugin guidelines 32 | + $$self = (split /\n/, $$self)[0]; 33 | # Perl code other than plugins may print nothing; in this case return "(No output!)\n". 34 | - return $$self ? $$self : "(No output!)\n" ; 35 | + return $$self ? substr($$self, 0, 256) : "(No output!)\n" ; 36 | } 37 | 38 | sub CLOSE { 39 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/nagios_cert.cer: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDuzCCAqOgAwIBAgIBCzANBgkqhkiG9w0BAQUFADBFMREwDwYDVQQKEwhwcm95 3 | Lm9yZzEPMA0GA1UEAxMGUHJveUNBMR8wHQYJKoZIhvcNAQkBFhBwYXRyaWNrQHBy 4 | b3kub3JnMB4XDTA3MDExMTE4MTM0NFoXDTA4MDExMTE4MTM0NFowgYExCzAJBgNV 5 | BAYTAkZSMQ4wDAYDVQQIEwVSaG9uZTENMAsGA1UEBxMETHlvbjERMA8GA1UEChMI 6 | cHJveS5vcmcxDzANBgNVBAsTBk5hZ2lvczEPMA0GA1UEAxMGTmFnaW9zMR4wHAYJ 7 | KoZIhvcNAQkBFg9uYWdpb3NAcHJveS5vcmcwgZ8wDQYJKoZIhvcNAQEBBQADgY0A 8 | MIGJAoGBAKSakWwv5g4cpXu2bL6/Aq+29BmY5pmiqOp5mSifYOfCYJfAMOCyeGAI 9 | 03GmEYhWaYVvEC2x03u7WhlbR6WzFsIxnFETdarlEHGl94wicyz6PKnwa9X5vkWm 10 | VKYgulvz6+jmrWFOyJ+Q60nIU0oAVE+0Erlk7MkFkWw1uthWl7VTAgMBAAGjgfww 11 | gfkwHQYDVR0OBBYEFKLfzxeOiNsgM53DMDcpTx7rsIH/MG0GA1UdIwRmMGSAFEE6 12 | rbWSeijSQchCxUCknwDCivOfoUmkRzBFMREwDwYDVQQKEwhwcm95Lm9yZzEPMA0G 13 | A1UEAxMGUHJveUNBMR8wHQYJKoZIhvcNAQkBFhBwYXRyaWNrQHByb3kub3JnggEA 14 | MAkGA1UdEwQCMAAwLwYDVR0fBCgwJjAkoCKgIIYeaHR0cDovL3d3dy5wcm95Lm9y 15 | Zy9wcm95Q0EuY3JsMC0GCWCGSAGG+EIBBAQgFh5odHRwOi8vd3d3LnByb3kub3Jn 16 | L3Byb3lDQS5jcmwwDQYJKoZIhvcNAQEFBQADggEBADOEbkwCMCjNi6fkw1GR4cyO 17 | wWpHHE2J5en5eh5KIZCsW90vYH2TttjfYk/gnoON3lBsAV+Cisvdx5/LpEuqfZFB 18 | GMApyG58oXPzVipytppyOSxGlDkAnAXC9jNRIiZ4lBDXloziTaIPmjVpBM6wuEpY 19 | 7pGo1J7B+GOvKLYFYVX+tuOpMlHJtDJbhn2seTr50MaI0uncnqjKpXHO+J205p8b 20 | psCEkaZSQZ2EXpX+caCFxy1rjqC49glq/DaaxopQlhkUCvDQRoRoHDXg3EBW0Svx 21 | G9emvqbByaf31mUVlIesj8B+Xo8bqRMcEyWfwc7UE94Tzw6Iv2Xl2qFS2wmgMf8= 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Expected Behavior 4 | 5 | 6 | 7 | ## Current Behavior 8 | 9 | 10 | 11 | ## Possible Solution 12 | 13 | 14 | 15 | ## Steps to Reproduce (for bugs) 16 | 17 | 18 | 1. 19 | 2. 20 | 3. 21 | 4. 22 | 23 | ## Context 24 | 25 | 26 | 27 | ## Your Environment 28 | 29 | * Version used (e.g. `check_snmp_int.pl -V`): 30 | * Perl version (`perl -v`): 31 | * Operating System and version: 32 | * Monitoring system (e.g. `icinga2 --version`): 33 | * CheckCommand and Service configuration: 34 | * Full command line executed by Icinga, if relevant: 35 | 36 | -------------------------------------------------------------------------------- /doc/02-Installation.md: -------------------------------------------------------------------------------- 1 | # Manubulon SNMP Plugins Installation 2 | 3 | The plugins rely on the `Net::SNMP` Perl library for fetching 4 | data from SNMP enabled hosts. 5 | 6 | ## Prerequisites 7 | 8 | ### RHEL/CentOS EPEL Repository 9 | 10 | RHEL/CentOS requires the EPEL repository: 11 | 12 | ``` 13 | yum -y install epel-release 14 | yum makecache 15 | ``` 16 | 17 | If you are using RHEL you need enable the `optional` repository and then install 18 | the [EPEL rpm package](https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F). 19 | 20 | ## Perl Dependencies 21 | 22 | Debian/Ubuntu: 23 | 24 | ``` 25 | apt-get -y install libnet-snmp-perl libcrypt-des-perl libcrypt-rijndael-perl libdigest-hmac-perl 26 | ``` 27 | 28 | RHEL/CentOS/Fedora: 29 | 30 | ``` 31 | yum -y install perl-Net-SNMP perl-Getopt-Long perl-Crypt-DES perl-Crypt-Rijndael perl-Digest-HMAC 32 | ``` 33 | 34 | ## Plugin Setup 35 | 36 | Debian/Ubuntu: 37 | 38 | ``` 39 | install -o root -g root -m755 plugins/*.pl /usr/lib/nagios/plugins/ 40 | ``` 41 | 42 | RHEL/CentOS/Fedora: 43 | 44 | ``` 45 | install -o root -g root -m755 plugins/*.pl /usr/lib64/nagios/plugins/ 46 | ``` 47 | 48 | Proceed with inspecting the plugins `--help` parameter in [this chapter](04-Plugins.md). 49 | 50 | Next up: Integrate the plugins into your monitoring by adding [configuration](03-Configuration.md). 51 | 52 | ## Advanced Hints 53 | 54 | Perl, default directory and temp files location can be changed using the install.sh script. 55 | 56 | `utils.pm` from `Monitoring::Plugin::Perl` is no longer required. 57 | 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Manubulon SNMP Plugins 2 | 3 | #### Table of Contents 4 | 5 | 1. [About](#about) 6 | 2. [License](#license) 7 | 3. [Support](#support) 8 | 4. [Requirements](#requirements) 9 | 5. [Installation](#installation) 10 | 6. [Configuration](#configuration) 11 | 7. [FAQ](#faq) 12 | 8. [Thanks](#thanks) 13 | 9. [Contributing](#contributing) 14 | 15 | ## About 16 | 17 | Manubulon SNMP plugins is a set of Icinga/Nagios plugins 18 | to check hosts/devices using the SNMP protocol. 19 | 20 | ### Plugin Overview 21 | 22 | Plugin | Description 23 | ------------------------------|---------------------------------------- 24 | check\_snmp\_storage | Storage checks (disks, swap, memory, etc.) 25 | check\_snmp\_int | Interface states, usage on hosts, switches, routers, etc. 26 | check\_snmp\_process | Running processes, their number, used CPU and memory. 27 | check\_snmp\_load | Load/CPU checks 28 | check\_snmp\_mem | Memory and swap usage 29 | check\_snmp\_env | Environmental status of fan, temp, power supplies. 30 | check\_snmp\_vrrp | Interface state of a VRRP cluster 31 | check\_snmp\_cpfw | Checkpoint Firewall-1 status 32 | check\_snmp\_win | Windows services 33 | check\_snmp\_css | CSS service states 34 | check\_snmp\_nsbox | Nsbox VHost and diode status 35 | check\_snmp\_boostedge | Boostedge services 36 | check\_snmp\_linkproof\_ndr | Linkproof NHR 37 | 38 | ## License 39 | 40 | These plugins are licensed under the terms of the GNU General Public License. 41 | You will find a copy of this license in the LICENSE file included in the source package. 42 | 43 | ## Support 44 | 45 | ## Requirements 46 | 47 | * Perl in `/usr/bin/perl` 48 | * Perl modules 49 | [Net::SNMP](http://search.cpan.org/~dtown/Net-SNMP-v6.0.1/lib/Net/SNMP.pm) and 50 | [Getopt::Long](http://search.cpan.org/~jv/Getopt-Long-2.49.1/lib/Getopt/Long.pm) 51 | * `icinga` user able to write files in /tmp/ directory 52 | * SNMP v3 authentication: Perl modules 53 | [Crypt::DES](http://search.cpan.org/~dparis/Crypt-DES-2.07/DES.pm), 54 | [Crypt::Rijndael](http://search.cpan.org/~leont/Crypt-Rijndael-1.13/Rijndael.pm) and 55 | [Digest::HMAC](http://search.cpan.org/~gaas/Digest-HMAC-1.03/lib/Digest/HMAC.pm) 56 | 57 | ## Installation 58 | 59 | Detailed installation instructions can be found [here](doc/02-Installation.md). 60 | 61 | ## Configuration 62 | 63 | Proceed [here](doc/03-Configuration.md) to get details on the configuration with Icinga 2, Icinga 1.x, etc. 64 | 65 | ## FAQ 66 | 67 | 68 | ## Thanks 69 | 70 | Patrick Proy for creating and maintaining the original plugins. 71 | [Michael Friedrich](https://twitter.com/dnsmichi) for maintaing the CVS import and adding community patches. 72 | 73 | ## Contributing 74 | 75 | Fork this repository on GitHub and send in a PR. 76 | 77 | There's a `.perltidyrc` file in the main repository tree. If you are uncertain about the coding style, 78 | create your patch and then run: 79 | 80 | ``` 81 | $ perltidy -b plugins/*.pl 82 | ``` 83 | 84 | This requires the `perltidy` module being installed. 85 | -------------------------------------------------------------------------------- /doc/03-Configuration.md: -------------------------------------------------------------------------------- 1 | # Manubulon SNMP Plugins Configuration 2 | 3 | Each plugin requires a command definition which defines the command line parameters 4 | and arguments passed from service checks. 5 | 6 | * [Icinga 2](03-Configuration.md#manubulon-snmp-plugins-configuration-icinga-2) integration 7 | * [Icinga 1.x/Naemon/Nagios](03-Configuration.md#manubulon-snmp-plugins-configuration-icinga-1) integration 8 | 9 | ## Icinga 2 10 | 11 | The Icinga 2 Template Library (ITL) already provides many [CheckCommand definitions](https://www.icinga.com/docs/icinga2/latest/doc/10-icinga-template-library/#plugin-check-commands-for-manubulon-snmp) 12 | out of the box. This enables you to just use the CheckCommand object and focus 13 | on your service apply rules. 14 | 15 | ### Icinga 2: Best Practices 16 | 17 | Best practice is to store the credentials in a separate constant: 18 | 19 | ``` 20 | vim /etc/icinga2/constants.conf 21 | 22 | const ManubulonSnmpCommunity = "icingasnmpro" 23 | ``` 24 | 25 | Define a generic SNMP service template and set common attributes. 26 | 27 | ``` 28 | template Service "snmp-template" { 29 | vars.snmp_community = ManubulonSnmpCommunity 30 | } 31 | ``` 32 | ### Icinga 2: Apply Rules 33 | 34 | 35 | Define service apply rules like this: 36 | 37 | ``` 38 | apply Service "snmp-memory" { 39 | import "snmp-template" 40 | check_command = "snmp-memory" 41 | 42 | vars.snmp_warn = "50,0" 43 | vars.snmp_crit = "80,0" 44 | 45 | assign where "snmp" in host.groups 46 | } 47 | 48 | apply Service "snmp-storage /var" { 49 | import "snmp-template" 50 | check_command = "snmp-storage" 51 | 52 | vars.snmp_warn = "50" 53 | vars.snmp_crit = "80" 54 | vars.snmp_storage_name = "/var" 55 | 56 | assign where "snmp" in host.groups 57 | } 58 | 59 | apply Service "snmp-storage" { 60 | import "snmp-template" 61 | check_command = "snmp-storage" 62 | 63 | vars.snmp_warn = "50" 64 | vars.snmp_crit = "80" 65 | 66 | assign where "snmp" in host.groups 67 | } 68 | ``` 69 | 70 | ### Icinga 2: Apply For Rules 71 | 72 | A more complex example using apply for rules is to store the 73 | monitored storage disks on the host. This allows to generate 74 | service objects in a more efficient way. 75 | 76 | ``` 77 | object Host "snmp-host" { 78 | check_command = "hostalive" 79 | 80 | vars.snmp_storage["/"] = { 81 | snmp_warn = "80" 82 | snmp_crit = "90" 83 | } 84 | vars.snmp_storage["/var"] = { 85 | snmp_warn = "60" 86 | snmp_crit = "90" 87 | } 88 | } 89 | 90 | apply Service "snmp-storage-" for (storage_name => config in host.vars.snmp_storage) { 91 | import "snmp-template" 92 | 93 | display_name = "Storage: " + storage_name 94 | 95 | vars += config 96 | vars.snmp_storage_name = storage_name 97 | } 98 | ``` 99 | 100 | 101 | ## Icinga 1.x/Naemon/Nagios 102 | 103 | You need to write a check command definition and use that in your service definitions. 104 | Please refer to [this documentation](http://nagios.manubulon.com/index_commands.html). 105 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [2.1.0](https://github.com/dnsmichi/manubulon-snmp/tree/2.1.0) (2017-10-12) 4 | [Full Changelog](https://github.com/dnsmichi/manubulon-snmp/compare/v2.0.0...2.1.0) 5 | 6 | **Implemented enhancements:** 7 | 8 | - Cisco SMB switch [\#30](https://github.com/dnsmichi/manubulon-snmp/issues/30) 9 | - Allow output for NagVis "weathermap" lines [\#22](https://github.com/dnsmichi/manubulon-snmp/issues/22) 10 | - Enhance and write better documentation [\#40](https://github.com/dnsmichi/manubulon-snmp/pull/40) ([dnsmichi](https://github.com/dnsmichi)) 11 | - Escape dot in perfdata labels [\#39](https://github.com/dnsmichi/manubulon-snmp/pull/39) ([mj84](https://github.com/mj84)) 12 | - \[\#30\] add support for cisco small business switches \(tested with SG500\) [\#31](https://github.com/dnsmichi/manubulon-snmp/pull/31) ([spali](https://github.com/spali)) 13 | - Allow output for NagVis "weathermap" lines [\#26](https://github.com/dnsmichi/manubulon-snmp/pull/26) ([miken32](https://github.com/miken32)) 14 | - Add SNMP v3 authentication dependencies and distro-specific Perl module packages [\#23](https://github.com/dnsmichi/manubulon-snmp/pull/23) ([virtualtam](https://github.com/virtualtam)) 15 | 16 | **Fixed bugs:** 17 | 18 | - check\_snmp\_load.pl =\> SNMPv3 do not use the -p \(port\) option [\#27](https://github.com/dnsmichi/manubulon-snmp/issues/27) 19 | - Fix typos in documentation [\#29](https://github.com/dnsmichi/manubulon-snmp/pull/29) ([moepot](https://github.com/moepot)) 20 | - The -p \(port\) option was forgotten in some cases [\#28](https://github.com/dnsmichi/manubulon-snmp/pull/28) ([Niflou](https://github.com/Niflou)) 21 | - Fix check\_snmp\_int.pl temp file name [\#25](https://github.com/dnsmichi/manubulon-snmp/pull/25) ([waja](https://github.com/waja)) 22 | 23 | **Closed issues:** 24 | 25 | - Have waiting info always [\#4](https://github.com/dnsmichi/manubulon-snmp/issues/4) 26 | 27 | ## [v2.0.0](https://github.com/dnsmichi/manubulon-snmp/tree/v2.0.0) (2016-11-25) 28 | **Implemented enhancements:** 29 | 30 | - check\_snmp\_load.pl - Linux load multiple CPUs [\#6](https://github.com/dnsmichi/manubulon-snmp/issues/6) 31 | - Ignore DOWN state and big snmp requests [\#19](https://github.com/dnsmichi/manubulon-snmp/pull/19) ([SteScho](https://github.com/SteScho)) 32 | 33 | **Fixed bugs:** 34 | 35 | - check\_snmp\_process.pl does not honour timeout \(-t\) [\#21](https://github.com/dnsmichi/manubulon-snmp/issues/21) 36 | 37 | **Closed issues:** 38 | 39 | - Apply a programming style to the plugins [\#20](https://github.com/dnsmichi/manubulon-snmp/issues/20) 40 | - Get rid of utils.pm [\#10](https://github.com/dnsmichi/manubulon-snmp/issues/10) 41 | - Net::SNMP version string no longer numeric in CentOS 7 [\#9](https://github.com/dnsmichi/manubulon-snmp/issues/9) 42 | - fortigate 4.3 support for check\_snmp\_load [\#7](https://github.com/dnsmichi/manubulon-snmp/issues/7) 43 | 44 | **Merged pull requests:** 45 | 46 | - Not all Systems have connections [\#18](https://github.com/dnsmichi/manubulon-snmp/pull/18) ([SteScho](https://github.com/SteScho)) 47 | - Add the -A/--use-ifalias option to do name lookup from ifAlias [\#17](https://github.com/dnsmichi/manubulon-snmp/pull/17) ([darksoul42](https://github.com/darksoul42)) 48 | - pnp need perf-data with always same order [\#16](https://github.com/dnsmichi/manubulon-snmp/pull/16) ([SteScho](https://github.com/SteScho)) 49 | - pnp need perf-data with always same order [\#15](https://github.com/dnsmichi/manubulon-snmp/pull/15) ([SteScho](https://github.com/SteScho)) 50 | - Add -N/--use-ifname option to switch name lookup from ifDescr to ifName [\#14](https://github.com/dnsmichi/manubulon-snmp/pull/14) ([darksoul42](https://github.com/darksoul42)) 51 | - Fix, check\_snmtp\_load output [\#12](https://github.com/dnsmichi/manubulon-snmp/pull/12) ([casvcasv](https://github.com/casvcasv)) 52 | - making checks executable [\#8](https://github.com/dnsmichi/manubulon-snmp/pull/8) ([morgajel](https://github.com/morgajel)) 53 | - Add Cisco Nexus Devices capability for load [\#3](https://github.com/dnsmichi/manubulon-snmp/pull/3) ([pasancario](https://github.com/pasancario)) 54 | - Fix typo protcol vs. protocol [\#2](https://github.com/dnsmichi/manubulon-snmp/pull/2) ([waja](https://github.com/waja)) 55 | - Fix error writing tmp file using plugin with remote unix system [\#1](https://github.com/dnsmichi/manubulon-snmp/pull/1) ([TheCry](https://github.com/TheCry)) 56 | 57 | 58 | 59 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* 60 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/package_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nagios plugins 6 | 7 | 8 | 9 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 98 | 99 | 180 | 181 | 182 | 183 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Home

82 | 83 |
94 | 95 | 96 | 97 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 114 | 115 | 116 | 117 | 118 | 119 | 157 | 158 | 159 | 160 | 161 | 174 | 175 | 176 | 177 |
Plugins in C

Last update : Jun 9 2007

112 | 113 |
120 | 121 |

Description :

122 | 123 |

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

124 | 125 |

New features in the C plugins :
126 |
127 | - 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.
128 | - Support for other languages (for now only french po file has been done)

129 |

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

130 |

download version 0.6.0

131 |

How to install :

132 |

Requirements to compile : net-snmp-devel

133 |

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

134 |

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

140 |

Then run :
141 | make

142 |

Then, as root :
143 | make install

144 |

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

147 |

That's all !

148 |

Details on the caching option

149 |

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

150 |

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

151 |

This can be really big requests for example if you have a core LAN switch with 80 interfaces. 152 | 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.
153 | 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.

154 |

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.

155 |

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.

156 |

 

162 | 163 |

This project is hosted on :
164 | 165 | http://sourceforge.net/projects/nagios-snmp 166 | 167 |

168 | 169 |

Nagios and the Nagios logo are registered 170 | 171 | trademarks of Ethan Galstad.

172 | 173 |
178 | 179 |
184 | 185 |

 

186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /plugins/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################## install.sh ##################### 3 | # Version : 1.4 4 | # Date : Jan 13 2007 5 | # Author : Patrick Proy ( nagios at proy.org) 6 | # Help : http://www.manubulon.com/nagios/ 7 | # Licence : GPL - http://www.fsf.org/licenses/gpl.txt 8 | # TODO : 9 | # Contribs : 10 | ################################################################# 11 | # 12 | # USAGE : ./install [ | AUTO [] ] 13 | # USAGE : by default all scripts will be installed 14 | # 15 | # REQUIREMENTS : /bin/bash and sed 16 | # 17 | # This script will: 18 | # - Check perl binary (and asks for path) 19 | # - Ask for monitoring plugin path (default /usr/local/icinga/libexec) 20 | # - Ask for temporary file location (default /tmp) 21 | # - Check Net::SNMP version 22 | # - Install plugins in the plugins directory and modify paths if necessary. 23 | 24 | ############################ script list 25 | PLUGINS="check_snmp_boostedge.pl check_snmp_css.pl check_snmp_linkproof_nhr.pl check_snmp_nsbox.pl check_snmp_vrrp.pl check_snmp_cpfw.pl check_snmp_env.pl check_snmp_load.pl check_snmp_process.pl check_snmp_win.pl check_snmp_css_main.pl check_snmp_int.pl check_snmp_mem.pl check_snmp_storage.pl" 26 | ############################ get script to install or install type 27 | 28 | if [ $# -gt 0 ] ; then INSTSCRIPT=$1 ; else INSTSCRIPT="all" ; fi 29 | 30 | if [ $INSTSCRIPT != "AUTO" ] ; then 31 | ############################ Manual installation 32 | echo 33 | echo "###### Manubulon snmp scripts installer ######" 34 | echo 35 | echo "Will install $INSTSCRIPT script(s)" 36 | echo 37 | 38 | ############################ default values 39 | 40 | SRCDIR=$PWD 41 | PERLHOME=`which perl 2>&1` 42 | if [ $? -ne 0 ]; then PERLHOME="" ; fi 43 | 44 | PLUGHOME=/usr/local/icinga/libexec 45 | TMPDATA=/tmp 46 | ############################ Checking Perl 47 | 48 | echo -n "What is your perl location ? [$PERLHOME] " 49 | read USERPERL 50 | if [ "ZZ$USERPERL" != "ZZ" ]; then PERLHOME=$USERPERL ; fi 51 | 52 | if [ "z$PERLHOME" == "z" ]; then 53 | echo "Can't find perl binary... exiting" 54 | echo "######### ERROR ########" 55 | exit 1 56 | fi 57 | 58 | NETSNMP=`$PERLHOME -e 'if (eval "require Net::SNMP") { print "Yes" ;}'` 59 | if [ $? -ne 0 ] ; then 60 | echo "Error while checking Net::SNMP module" 61 | echo "######### ERROR ########" 62 | exit 1; 63 | fi 64 | 65 | if [ "zz$NETSNMP" != "zzYes" ]; then 66 | echo "Module Net::SNMP not found!" 67 | echo "Install it with CPAN or manually : http://www.manubulon.com/nagios/faq.html#FAQ2" 68 | echo "######### ERROR ########" 69 | exit 1; 70 | fi 71 | 72 | SNMPVER=`$PERLHOME -e 'require Net::SNMP;print Net::SNMP->VERSION'` 73 | echo "Net::SNMP module version is $SNMPVER [OK]" 74 | 75 | GETOPT=`$PERLHOME -e 'if (eval "require Getopt::Long") { print "Yes" ;}'` 76 | if [ "zz$GETOPT" != "zzYes" ]; then 77 | echo "Module Getopt::Long not found!" 78 | echo "Install it with CPAN or manually" 79 | echo "######### ERROR ########" 80 | exit 1; 81 | fi 82 | echo "Module Getopt::Long found [OK]" 83 | 84 | ############################ Check monitoring plugin directory 85 | 86 | echo 87 | echo "What is your monitoring plugin location ? " 88 | read USERPLUG 89 | 90 | if [ "z$USERPLUG" != "z" ]; then PLUGHOME=$USERPLUG ; fi 91 | if [ ! -d $PLUGHOME ] ; then 92 | echo "Directory $PLUGHOME does not exist !" 93 | echo "######### ERROR ########" 94 | exit 1 95 | fi 96 | 97 | ############################ Asking for temp directory 98 | 99 | echo 100 | echo "Where do you want the plugins to put temporary data (only used by some plugins) ? " 101 | echo -n "Icinga user must be able to write files in it [$TMPDATA] " 102 | read USERTMP 103 | 104 | if [ "z$USERTMP" != "z" ]; then TMPDATA=$USERTMP ; fi 105 | 106 | if [ ! -d $TMPDATA ] ; then 107 | echo "Directory $TMPDATA does not exist !" 108 | echo "######### ERROR ########" 109 | exit 1 110 | fi 111 | 112 | ############################ Looks OK, copying with changes if necessary 113 | 114 | TRANS="" 115 | # Change '#!/usr/bin/perl -w' 116 | if [ $PERLHOME != "/usr/bin/perl" ] ; then 117 | TRANS="-r -e s#/usr/bin/perl#$PERLHOME#" 118 | fi 119 | 120 | # Change 'my $o_base_dir="/tmp/tmp_Icinga_' 121 | if [ $TMPDATA != "/tmp" ] ; then 122 | if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#" 123 | else TRANS="$TRANS -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#";fi 124 | fi 125 | 126 | ######################### script install 127 | 128 | echo 129 | echo "Will now install $INSTSCRIPT script(s) : " 130 | echo "in directory : $PLUGHOME" 131 | echo "perl : $PERLHOME" 132 | echo "temp directory : $TMPDATA" 133 | echo 134 | echo -n "OK ? [Y/n]" 135 | read INSTOK 136 | 137 | if [ "$INSTOK" == "n" ]; then 138 | echo "Aborting....." 139 | echo "######### ERROR ########" 140 | exit 1 141 | fi 142 | 143 | ERROR=0 144 | 145 | if [ $INSTSCRIPT == "all" ] ; then 146 | for i in $PLUGINS ; do 147 | echo 148 | if [ ! -f $i ] ; then 149 | echo "Can't find source file $i : ##### ERROR #####" 150 | else 151 | echo -n "Installing $i : " 152 | if [ "z$TRANS" == "z" ] ; then 153 | cp $i $PLUGHOME/$i 2>&1 154 | else 155 | sed $TRANS $i > $PLUGHOME/$i 2>&1 156 | fi 157 | if [ $? -ne 0 ] ; then 158 | echo "##### ERROR #####"; 159 | rm -f $PLUGHOME/$i 160 | ERROR=1 161 | else 162 | echo "OK" 163 | chmod 755 $PLUGHOME/$i 2>&1 164 | fi 165 | fi 166 | done 167 | else 168 | echo 169 | if [ ! -f $INSTSCRIPT ] ; then 170 | echo "Can't find source file $INSTSCRIPT : ##### ERROR #####" 171 | else 172 | echo -n "Installing $INSTSCRIPT : " 173 | if [ "z$TRANS" == "z" ] ; then 174 | cp $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT 175 | else 176 | sed $TRANS $INSTSCRIPT > $PLUGHOME/$INSTSCRIPT 2>&1 177 | fi 178 | if [ $? -ne 0 ] ; then 179 | echo "##### ERROR #####"; 180 | rm -f $PLUGHOME/$INSTSCRIPT 181 | ERROR=1 182 | exit 1; 183 | else 184 | echo "OK" 185 | chmod 755 $PLUGHOME/$INSTSCRIPT 2>&1 186 | fi 187 | fi 188 | fi 189 | 190 | echo 191 | if [ $ERROR -eq 1 ] ; then 192 | echo "Installation ended with errors. Check output above" 193 | exit 1; 194 | fi 195 | 196 | echo "Installation completed OK" 197 | echo "You can delete all the source files and directory" 198 | echo "Remember to look for informtation at http://www.manubulon.com/nagios/" 199 | exit 0; 200 | 201 | else 202 | ####################### Silent install with parameters ############ 203 | # PARAM AUTO [] 204 | if [ $# -ne 4 ] && [ $# -ne 5 ] ; then exit 1; fi 205 | 206 | SRCDIR=$PWD 207 | PERLHOME=$4 208 | PLUGHOME=$2 209 | TMPDATA=$3 210 | INSTALLDIR=$5 211 | 212 | TRANS="" 213 | # Change '#!/usr/bin/perl -w' 214 | if [ $PERLHOME != "/usr/bin/perl" ] ; then 215 | TRANS="-r -e s#/usr/bin/perl#$PERLHOME#" 216 | fi 217 | 218 | # Change 'my $o_base_dir="/tmp/tmp_Icinga_' 219 | if [ $TMPDATA != "/tmp" ] ; then 220 | if [ "z$TRANS" == "z" ]; then TRANS="-r -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#" 221 | else TRANS="$TRANS -e s#/tmp/tmp_Icinga#$TMPDATA/tmp_Icinga#";fi 222 | fi 223 | 224 | ######################### script install 225 | ERROR=0 226 | if [ "z$INSTALLDIR" != "z" ] ; then 227 | PLUGHOME=$INSTALLDIR 228 | fi 229 | for i in $PLUGINS ; do 230 | if [ ! -f $i ] ; then 231 | ERROR=1 232 | else 233 | if [ "z$TRANS" == "z" ] ; then 234 | cp $i $PLUGHOME/$i 2>&1 235 | else 236 | sed $TRANS $i > $PLUGHOME/$i 2>&1 237 | fi 238 | if [ $? -ne 0 ] ; then 239 | rm -f $PLUGHOME/$i 240 | ERROR=1 241 | else 242 | chmod 755 $PLUGHOME/$i 2>&1 243 | fi 244 | fi 245 | done 246 | if [ $ERROR -eq 1 ] ; then 247 | exit 1; 248 | fi 249 | exit 0; 250 | fi 251 | 252 | -------------------------------------------------------------------------------- /plugins/check_snmp_css_main.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | ############################## check_snmp_css_main.pl ################# 3 | # Version : 1.0 4 | # Date : 27 Sept 2006 5 | # Author : Patrick Proy ( patrick at proy.org) 6 | # Help : http://www.manubulon.com/nagios/ 7 | # License : GPL - http://www.fsf.org/licenses/gpl.txt 8 | # Changelog : 9 | # Contributors : 10 | ################################################################# 11 | # 12 | # Help : ./check_snmp_css.pl -h 13 | # 14 | 15 | use strict; 16 | use Net::SNMP; 17 | use Getopt::Long; 18 | 19 | # Icinga specific 20 | my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); 21 | 22 | # SNMP Datas 23 | 24 | my $css_svc_table = "1.3.6.1.4.1.9.9.368.1.15.2.1"; # Svc table 25 | my $css_svc_name = "1.3.6.1.4.1.9.9.368.1.15.2.1.1"; # Service Name / apSvcName 26 | my $css_svc_index = "1.3.6.1.4.1.9.9.368.1.15.2.1.2"; # apSvcIndex 27 | my $css_svc_enable = "1.3.6.1.4.1.9.9.368.1.15.2.1.12"; # apSvcEnable 28 | 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) 29 | my $css_svc_maxconn = "1.3.6.1.4.1.9.9.368.1.15.2.1.19"; # Max connexions / apSvcMaxConnections 30 | my $css_svc_conn = "1.3.6.1.4.1.9.9.368.1.15.2.1.20"; # apSvcConnections 31 | my $css_svc_avgresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.65"; # apSvcAvgResponseTime : average response time 32 | my $css_svc_maxresp = "1.3.6.1.4.1.9.9.368.1.15.2.1.66"; # apSvcPeakAvgResponseTime : peak response time 33 | my @css_svc_state_txt = ("", "suspended", "down", "", "alive", "dying"); 34 | my @css_svc_state_nag = (3, 2, 2, 3, 0, 2); 35 | 36 | # Globals 37 | 38 | my $VERSION = "2.1.0"; 39 | 40 | my $o_host = undef; # hostname 41 | my $o_community = undef; # community 42 | my $o_port = 161; # port 43 | my $o_domain = 'udp/ipv4'; # protocol 44 | my $o_help = undef; # wan't some help ? 45 | my $o_verb = undef; # verbose mode 46 | my $o_version = undef; # print version 47 | my $o_timeout = undef; # Timeout (Default 5) 48 | my $o_version2 = undef; # use snmp v2c 49 | 50 | #Specific 51 | my $o_dir = "/tmp/"; # Directory to store temp file in it. 52 | 53 | # SNMPv3 specific 54 | my $o_login = undef; # Login for snmpv3 55 | my $o_passwd = undef; # Pass for snmpv3 56 | my $v3protocols = undef; # V3 protocol list. 57 | my $o_authproto = 'md5'; # Auth protocol 58 | my $o_privproto = 'des'; # Priv protocol 59 | my $o_privpass = undef; # priv password 60 | 61 | # functions 62 | 63 | sub p_version { print "check_snmp_css_main version : $VERSION\n"; } 64 | 65 | sub print_usage { 66 | print 67 | "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-d directory] [-p ] [-t ] [-V]\n"; 68 | } 69 | 70 | sub help { 71 | print "\nSNMP Cisco CSS monitor MAIN script for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; 72 | print "GPL License, (c)2004-2006 Patrick Proy\n\n"; 73 | print_usage(); 74 | print < 82 | Directory where temp file with index is written 83 | -C, --community=COMMUNITY NAME 84 | community name for the host's SNMP agent (implies v1 protocol) 85 | -2, --v2c 86 | Use snmp v2c 87 | -l, --login=LOGIN ; -x, --passwd=PASSWD 88 | Login and auth password for snmpv3 authentication 89 | If no priv password exists, implies AuthNoPriv 90 | -X, --privpass=PASSWD 91 | Priv password for snmpv3 (AuthPriv protocol) 92 | -L, --protocols=, 93 | : Authentication protocol (md5|sha : default md5) 94 | : Priv protocole (des|aes : default des) 95 | -P, --port=PORT 96 | SNMP port (Default 161) 97 | --protocol=PROTOCOL 98 | Network protocol to be used 99 | ['udp/ipv4'] : UDP over IPv4 100 | 'udp/ipv6' : UDP over IPv6 101 | 'tcp/ipv4' : TCP over IPv4 102 | 'tcp/ipv6' : TCP over IPv6 103 | 104 | Network protocol (Default udp/ipv4) 105 | -t, --timeout=INTEGER 106 | timeout for SNMP in seconds (Default: 5) 107 | -V, --version 108 | prints version number 109 | EOT 110 | } 111 | 112 | # For verbose output 113 | sub verb { my $t = shift; print $t, "\n" if defined($o_verb); } 114 | 115 | sub check_options { 116 | Getopt::Long::Configure("bundling"); 117 | GetOptions( 118 | 'v' => \$o_verb, 119 | 'verbose' => \$o_verb, 120 | 'h' => \$o_help, 121 | 'help' => \$o_help, 122 | 'H:s' => \$o_host, 123 | 'hostname:s' => \$o_host, 124 | 'p:i' => \$o_port, 125 | 'port:i' => \$o_port, 126 | 'protocol:s' => \$o_domain, 127 | 'C:s' => \$o_community, 128 | 'community:s' => \$o_community, 129 | 'l:s' => \$o_login, 130 | 'login:s' => \$o_login, 131 | 'x:s' => \$o_passwd, 132 | 'passwd:s' => \$o_passwd, 133 | 'X:s' => \$o_privpass, 134 | 'privpass:s' => \$o_privpass, 135 | 'L:s' => \$v3protocols, 136 | 'protocols:s' => \$v3protocols, 137 | 't:i' => \$o_timeout, 138 | 'timeout:i' => \$o_timeout, 139 | 'V' => \$o_version, 140 | 'version' => \$o_version, 141 | '2' => \$o_version2, 142 | 'v2c' => \$o_version2, 143 | 'd:s' => \$o_dir, 144 | 'dir:s' => \$o_dir 145 | ); 146 | 147 | # Basic checks 148 | if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) { 149 | print "Timeout must be >1 and <60 !\n"; 150 | print_usage(); 151 | exit $ERRORS{"UNKNOWN"}; 152 | } 153 | if (!defined($o_timeout)) { $o_timeout = 5; } 154 | if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } 155 | if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } 156 | if (!defined($o_host)) # check host and filter 157 | { 158 | print_usage(); 159 | exit $ERRORS{"UNKNOWN"}; 160 | } 161 | 162 | # check snmp information 163 | if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) { 164 | print "Put snmp login info!\n"; 165 | print_usage(); 166 | exit $ERRORS{"UNKNOWN"}; 167 | } 168 | if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) { 169 | print "Can't mix snmp v1,2c,3 protocols!\n"; 170 | print_usage(); 171 | exit $ERRORS{"UNKNOWN"}; 172 | } 173 | if (defined($v3protocols)) { 174 | if (!defined($o_login)) { 175 | print "Put snmp V3 login info with protocols!\n"; 176 | print_usage(); 177 | exit $ERRORS{"UNKNOWN"}; 178 | } 179 | my @v3proto = split(/,/, $v3protocols); 180 | if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol 181 | if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol 182 | if ((defined($v3proto[1])) && (!defined($o_privpass))) { 183 | print "Put snmp V3 priv login info with priv protocols!\n"; 184 | print_usage(); 185 | exit $ERRORS{"UNKNOWN"}; 186 | } 187 | } 188 | if (defined($o_dir)) { 189 | verb("Tmp directory : $o_dir"); 190 | } 191 | } 192 | 193 | ########## MAIN ####### 194 | 195 | check_options(); 196 | 197 | # Check timeout if snmp screws up 198 | if (defined($o_timeout)) { 199 | verb("Alarm in $o_timeout seconds"); 200 | alarm($o_timeout); 201 | } 202 | 203 | $SIG{'ALRM'} = sub { 204 | print "No answer from host $o_host:$o_port\n"; 205 | exit $ERRORS{"UNKNOWN"}; 206 | }; 207 | 208 | # Connect to host 209 | my ($session, $error); 210 | if (defined($o_login) && defined($o_passwd)) { 211 | 212 | # SNMPv3 login 213 | verb("SNMPv3 login"); 214 | if (!defined($o_privpass)) { 215 | verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto"); 216 | ($session, $error) = Net::SNMP->session( 217 | -hostname => $o_host, 218 | -port => $o_port, 219 | -version => '3', 220 | -username => $o_login, 221 | -authpassword => $o_passwd, 222 | -authprotocol => $o_authproto, 223 | -timeout => $o_timeout, 224 | -domain => $o_domain 225 | ); 226 | } else { 227 | verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto"); 228 | ($session, $error) = Net::SNMP->session( 229 | -hostname => $o_host, 230 | -port => $o_port, 231 | -version => '3', 232 | -username => $o_login, 233 | -authpassword => $o_passwd, 234 | -authprotocol => $o_authproto, 235 | -privpassword => $o_privpass, 236 | -privprotocol => $o_privproto, 237 | -timeout => $o_timeout, 238 | -domain => $o_domain 239 | ); 240 | } 241 | } else { 242 | if (defined($o_version2)) { 243 | 244 | # SNMPv2 Login 245 | verb("SNMP v2c login"); 246 | ($session, $error) = Net::SNMP->session( 247 | -hostname => $o_host, 248 | -version => 2, 249 | -community => $o_community, 250 | -port => $o_port, 251 | -timeout => $o_timeout, 252 | -domain => $o_domain 253 | ); 254 | } else { 255 | 256 | # SNMPV1 login 257 | verb("SNMP v1 login"); 258 | ($session, $error) = Net::SNMP->session( 259 | -hostname => $o_host, 260 | -community => $o_community, 261 | -port => $o_port, 262 | -timeout => $o_timeout, 263 | -domain => $o_domain 264 | ); 265 | } 266 | } 267 | if (!defined($session)) { 268 | printf("ERROR opening session: %s.\n", $error); 269 | exit $ERRORS{"UNKNOWN"}; 270 | } 271 | $session->max_msg_size(10000); 272 | 273 | ########### Cisco CSS checks ############## 274 | 275 | # Get load table 276 | my $resultat 277 | = (version->parse(Net::SNMP->VERSION) < 4) 278 | ? $session->get_table($css_svc_name) 279 | : $session->get_table(Baseoid => $css_svc_name); 280 | 281 | if (!defined($resultat)) { 282 | printf("ERROR: Name table : %s.\n", $session->error); 283 | $session->close; 284 | exit $ERRORS{"UNKNOWN"}; 285 | } 286 | 287 | # Get name data & index 288 | my (@index, @svcname) = (undef, undef); 289 | my $numsvc = 0; 290 | foreach my $key (keys %$resultat) { 291 | verb("OID : $key, Desc : $$resultat{$key}"); 292 | $svcname[$numsvc] = $$resultat{$key}; 293 | $key =~ s/$css_svc_name//; 294 | verb("Found : $svcname[$numsvc]"); 295 | $index[$numsvc++] = $key; 296 | } 297 | 298 | # Write file 299 | 300 | my $file_name = $o_dir . "/Nagios_css_" . $o_host; 301 | my $file_lock = $file_name . ".lock"; 302 | 303 | # First, make a lock file 304 | system("touch $file_lock"); 305 | 306 | # allow scripts to finish reading file 307 | sleep(0.5); 308 | 309 | # create the file 310 | if (!open(FILE, "> " . $file_name)) { 311 | print "Cannot write $file_name\n"; 312 | unlink($file_lock); 313 | exit $ERRORS{"UNKNOWN"}; 314 | } 315 | for (my $i = 0; $i < $numsvc; $i++) { 316 | my $output = $index[$i] . ":" . $svcname[$i] . "\n"; 317 | print FILE $output; 318 | } 319 | close(FILE); 320 | unlink($file_lock); 321 | print "Found $numsvc services : OK\n"; 322 | exit $ERRORS{"OK"}; 323 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_mem.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nagios plugins 6 | 7 | 8 | 9 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 98 | 99 | 475 | 476 | 477 | 478 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Home

82 | 83 |
94 | 95 | 96 | 97 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | 119 | 120 | 121 | 122 | 123 | 451 | 452 | 453 | 454 | 455 | 456 | 469 | 470 | 471 | 472 |
Snmp memory check
112 | 113 |

Script : check_snmp_mem.pl

114 | 115 |

Last update : Sept 4 2006

116 | 117 |
124 | 125 |

Description :

126 | 127 |

Checks by snmp v1, v2c or v3 :

128 | 129 |

- Memory and swap usage on Linux given by Net-snmp. 130 | 131 |
132 | 133 | It checks memory and swap usage independantly : one warning and 134 | 135 | critical level for each of them.
136 | 137 |

138 | 139 |

- Memory usage on cisco routers or Pix : the 140 | 141 | plugin will add all of the memory pool and then checks the warning 142 | 143 | and critical levels.
144 | 145 | On cisco routeurs, it will add 'IO' and 'Processor' memory
146 | 147 | On Pix, it will check the memory used (one memory pool only on Pix).
148 | 149 |

150 | 151 |

- Memory usage on HP Procurve switch.
152 | 153 | Memory segments will be added then the free memory will be checked.
154 | 155 |

156 | 157 |

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

164 | 165 |

Checking memory for other os :

166 | 167 |

AS/400 : use the check_snmp_storage 168 | 169 | command to check the RAM

170 | 171 |

./check_snmp_storage.pl -H <IP> 172 | 173 | -C <community> -m RAM -s -w <warn%> -c 174 | 175 | <crit%>

176 | 177 |

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

180 | 181 |

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

186 | 187 |

SNMP Login
188 | 189 |

190 | 191 |

See snmp info page

192 | 193 |

Requirements :

194 | 195 |

- Perl in /usr/bin/perl - or just run 'perl 196 | 197 | script'
198 | 199 | - Net::SNMP
200 | 201 | - file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)
202 | 203 |

204 | 205 |

Dowload 206 | 207 | lastest version : 1.1

208 | 209 |

Configurations 210 | 211 | examples

212 | 213 |

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

215 | 216 |

Examples :

217 | 218 |


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

223 | 224 | 225 | 226 | 227 | 228 | 233 | 234 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 259 | 260 | 261 | 262 | 263 | 264 | 269 | 270 | 275 | 276 | 277 | 278 | 279 | 280 | 289 | 290 | 297 | 298 | 299 | 300 | 301 | 302 | 307 | 308 | 315 | 316 | 317 | 318 | 319 | 320 | 325 | 326 | 333 | 334 | 335 | 336 |
229 | 230 |

Get help 231 | 232 |

235 | 236 |

./check_snmp_mem.pl -h

237 | 238 |
Verbose output./check_snmp_mem.pl -H <IP> 247 | 248 | -C <com> -w 80 -c 81 -v
snmpv3 login./check_snmp_mem.pl -H 127.0.0.1 257 | 258 | -l login -x passwd
265 | 266 |

  267 | 268 |

271 | 272 |

Unix/Linux

273 | 274 |
281 | 282 |

%used of
283 | 284 | - RAM < 99% and 100%
285 | 286 | - Swap : < 20% and 30% 287 | 288 |

291 | 292 |

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

295 | 296 |
303 | 304 |

Same with no warning levels for memory 305 | 306 |

309 | 310 |

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

313 | 314 |
321 | 322 |

Check memory on Cisco 323 | 324 |

327 | 328 |

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

331 | 332 |
337 | 338 |

Output of check_snmp_mem.pl -h <

339 | 340 | 341 | 342 | 343 | 344 | 445 | 446 | 447 | 448 |
345 | 346 |

347 | 348 |

349 | 
350 | SNMP Memory Monitor for Nagios version 1.1
351 | 
352 | (c)2004-2006 - Patrick Proy
353 | 
354 | 
355 | 
356 | 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]
357 | 
358 | -v, --verbose
359 | 
360 |    print extra debugging information (including interface list on the system)
361 | 
362 | -h, --help
363 | 
364 |    print this help message
365 | 
366 | -H, --hostname=HOST
367 | 
368 |    name or IP address of host to check
369 | 
370 | -C, --community=COMMUNITY NAME
371 | 
372 |    community name for the host's SNMP agent (implies SNMP v1 or v2c with option)
373 | 
374 | -2, --v2c
375 | 
376 |    Use snmp v2c
377 | 
378 | -l, --login=LOGIN ; -x, --passwd=PASSWD
379 | 
380 |    Login and auth password for snmpv3 authentication 
381 | 
382 |    If no priv password exists, implies AuthNoPriv 
383 | 
384 | -X, --privpass=PASSWD
385 | 
386 |    Priv password for snmpv3 (AuthPriv protocol)
387 | 
388 | -L, --protocols=<authproto>,<privproto>
389 | 
390 |    <authproto> : Authentication protocol (md5|sha : default md5)
391 | 
392 |    <privproto> : Priv protocole (des|aes : default des) 
393 | 
394 | -P, --port=PORT
395 | 
396 |    SNMP port (Default 161)
397 | 
398 | -w, --warn=INTEGER | INT,INT
399 | 
400 |    warning level for memory in percent (0 for no checks) 
401 | 
402 |      Default (-N switch) : comma separated level for Real Memory and Swap 
403 | 
404 |      -I switch : warning level
405 | 
406 | -c, --crit=INTEGER | INT,INT
407 | 
408 |    critical level for memory in percent (0 for no checks)
409 | 
410 |      Default (-N switch) : comma separated level for Real Memory and Swap 
411 | 
412 |      -I switch : critical level
413 | 
414 | -N, --netsnmp (default)
415 | 
416 |    check linux memory & swap provided by Net SNMP 
417 | 
418 | -m, --memcache
419 | 
420 |    include cached memory in used memory (only with Net-SNMP)
421 | 
422 | -I, --cisco
423 | 
424 |    check cisco memory (sum of all memory pools)
425 | 
426 | -E, --hp
427 | 
428 |    check HP proccurve memory
429 | 
430 | -f, --perfdata
431 | 
432 |    Performance data output
433 | 
434 | -t, --timeout=INTEGER
435 | 
436 |    timeout for SNMP in seconds (Default: 5)
437 | 
438 | -V, --version
439 | 
440 |    prints version number
441 | 
442 | 
443 | 444 |
449 | 450 |
457 | 458 |

This project is hosted on :
459 | 460 | http://sourceforge.net/projects/nagios-snmp 461 | 462 |

463 | 464 |

Nagios and the Nagios logo are registered 465 | 466 | trademarks of Ethan Galstad.

467 | 468 |
473 | 474 |
479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | -------------------------------------------------------------------------------- /plugins/check_snmp_linkproof_nhr.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | ############################## check_snmp_linkproof_nhr ################# 3 | # Version : 1.0 4 | # Date : Aug 24 2006 5 | # Author : Patrick Proy ( patrick at proy.org) 6 | # Help : http://www.manubulon.com/nagios/ 7 | # License : GPL - http://www.fsf.org/licenses/gpl.txt 8 | # Changelog : 9 | # Contributors : 10 | ################################################################# 11 | # 12 | # Help : ./check_snmp_linkproof_nhr.pl -h 13 | # 14 | 15 | use strict; 16 | use Net::SNMP; 17 | use Getopt::Long; 18 | 19 | # Icinga specific 20 | my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); 21 | 22 | # SNMP Datas 23 | 24 | my $lp_type = "1.3.6.1.4.1.89.35.1.38.1.1.13"; # node type (1=regular, 2=nhr). 25 | my $lp_name = "1.3.6.1.4.1.89.35.1.38.1.1.2"; # nhr name 26 | my $lp_users = "1.3.6.1.4.1.89.35.1.38.1.1.5"; # nhr users 27 | my $lp_state = "1.3.6.1.4.1.89.35.1.38.1.1.3"; # state : 1=active, 2=Notinservice, 3= nonewsessions. 28 | my $lp_port = "1.3.6.1.4.1.89.35.1.38.1.1.15"; # nhr users 29 | 30 | # Globals 31 | 32 | my $VERSION = "2.1.0"; 33 | 34 | my $o_host = undef; # hostname 35 | my $o_community = undef; # community 36 | my $o_port = 161; # port 37 | my $o_domain = 'udp/ipv4'; # protocol 38 | my $o_help = undef; # wan't some help ? 39 | my $o_verb = undef; # verbose mode 40 | my $o_version = undef; # print version 41 | 42 | # specific 43 | my $o_nhr_num = undef; # nhr number TODO 44 | my $o_nhr_max = undef; # Maximum connexions TODO 45 | 46 | my $o_timeout = undef; # Timeout (Default 5) 47 | my $o_perf = undef; # Output performance data 48 | my $o_version2 = undef; # use snmp v2c 49 | 50 | # SNMPv3 specific 51 | my $o_login = undef; # Login for snmpv3 52 | my $o_passwd = undef; # Pass for snmpv3 53 | my $v3protocols = undef; # V3 protocol list. 54 | my $o_authproto = 'md5'; # Auth protocol 55 | my $o_privproto = 'des'; # Priv protocol 56 | my $o_privpass = undef; # priv password 57 | 58 | # functions 59 | 60 | sub p_version { print "check_snmp_linkproof_nhr version : $VERSION\n"; } 61 | 62 | sub print_usage { 63 | print 64 | "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) [-p ] [-f] [-t ] [-V]\n"; 65 | } 66 | 67 | sub isnnum { # Return true if arg is not a number 68 | my $num = shift; 69 | if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; } 70 | return 1; 71 | } 72 | 73 | sub help { 74 | print "\nSNMP Radware Linkproof NHR monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; 75 | print "(c)2004-2006 Patrick Proy\n\n"; 76 | print_usage(); 77 | print <, 98 | : Authentication protocol (md5|sha : default md5) 99 | : Priv protocole (des|aes : default des) 100 | -P, --port=PORT 101 | SNMP port (Default 161) 102 | --protocol=PROTOCOL 103 | Network protocol to be used 104 | ['udp/ipv4'] : UDP over IPv4 105 | 'udp/ipv6' : UDP over IPv6 106 | 'tcp/ipv4' : TCP over IPv4 107 | 'tcp/ipv6' : TCP over IPv6 108 | 109 | Network protocol (Default udp/ipv4) 110 | -f, --perfparse, --perfdata 111 | Performance data output 112 | -t, --timeout=INTEGER 113 | timeout for SNMP in seconds (Default: 5) 114 | -V, --version 115 | prints version number 116 | EOT 117 | } 118 | 119 | # For verbose output 120 | sub verb { my $t = shift; print $t, "\n" if defined($o_verb); } 121 | 122 | sub check_options { 123 | Getopt::Long::Configure("bundling"); 124 | GetOptions( 125 | 'v' => \$o_verb, 126 | 'verbose' => \$o_verb, 127 | 'h' => \$o_help, 128 | 'help' => \$o_help, 129 | 'H:s' => \$o_host, 130 | 'hostname:s' => \$o_host, 131 | 'p:i' => \$o_port, 132 | 'port:i' => \$o_port, 133 | 'protocol:s' => \$o_domain, 134 | 'C:s' => \$o_community, 135 | 'community:s' => \$o_community, 136 | 'l:s' => \$o_login, 137 | 'login:s' => \$o_login, 138 | 'x:s' => \$o_passwd, 139 | 'passwd:s' => \$o_passwd, 140 | 'X:s' => \$o_privpass, 141 | 'privpass:s' => \$o_privpass, 142 | 'L:s' => \$v3protocols, 143 | 'protocols:s' => \$v3protocols, 144 | 't:i' => \$o_timeout, 145 | 'timeout:i' => \$o_timeout, 146 | 'V' => \$o_version, 147 | 'version' => \$o_version, 148 | '2' => \$o_version2, 149 | 'v2c' => \$o_version2, 150 | 'f' => \$o_perf, 151 | 'perfparse' => \$o_perf, 152 | 'perfdata' => \$o_perf 153 | ); 154 | 155 | # Basic checks 156 | if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) { 157 | print "Timeout must be >1 and <60 !\n"; 158 | print_usage(); 159 | exit $ERRORS{"UNKNOWN"}; 160 | } 161 | if (!defined($o_timeout)) { $o_timeout = 5; } 162 | if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } 163 | if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } 164 | if (!defined($o_host)) # check host and filter 165 | { 166 | print_usage(); 167 | exit $ERRORS{"UNKNOWN"}; 168 | } 169 | 170 | # check snmp information 171 | if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) { 172 | print "Put snmp login info!\n"; 173 | print_usage(); 174 | exit $ERRORS{"UNKNOWN"}; 175 | } 176 | if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) { 177 | print "Can't mix snmp v1,2c,3 protocols!\n"; 178 | print_usage(); 179 | exit $ERRORS{"UNKNOWN"}; 180 | } 181 | if (defined($v3protocols)) { 182 | if (!defined($o_login)) { 183 | print "Put snmp V3 login info with protocols!\n"; 184 | print_usage(); 185 | exit $ERRORS{"UNKNOWN"}; 186 | } 187 | my @v3proto = split(/,/, $v3protocols); 188 | if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol 189 | if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol 190 | if ((defined($v3proto[1])) && (!defined($o_privpass))) { 191 | print "Put snmp V3 priv login info with priv protocols!\n"; 192 | print_usage(); 193 | exit $ERRORS{"UNKNOWN"}; 194 | } 195 | } 196 | } 197 | 198 | ########## MAIN ####### 199 | 200 | check_options(); 201 | 202 | # Check timeout if snmp screws up 203 | if (defined($o_timeout)) { 204 | verb("Alarm in $o_timeout seconds"); 205 | alarm($o_timeout); 206 | } 207 | 208 | $SIG{'ALRM'} = sub { 209 | print "No answer from host $o_host:$o_port\n"; 210 | exit $ERRORS{"UNKNOWN"}; 211 | }; 212 | 213 | # Connect to host 214 | my ($session, $error); 215 | if (defined($o_login) && defined($o_passwd)) { 216 | 217 | # SNMPv3 login 218 | verb("SNMPv3 login"); 219 | if (!defined($o_privpass)) { 220 | verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto"); 221 | ($session, $error) = Net::SNMP->session( 222 | -hostname => $o_host, 223 | -port => $o_port, 224 | -version => '3', 225 | -username => $o_login, 226 | -authpassword => $o_passwd, 227 | -authprotocol => $o_authproto, 228 | -timeout => $o_timeout, 229 | -domain => $o_domain 230 | ); 231 | } else { 232 | verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto"); 233 | ($session, $error) = Net::SNMP->session( 234 | -hostname => $o_host, 235 | -port => $o_port, 236 | -version => '3', 237 | -username => $o_login, 238 | -authpassword => $o_passwd, 239 | -authprotocol => $o_authproto, 240 | -privpassword => $o_privpass, 241 | -privprotocol => $o_privproto, 242 | -timeout => $o_timeout, 243 | -domain => $o_domain 244 | ); 245 | } 246 | } else { 247 | if (defined($o_version2)) { 248 | 249 | # SNMPv2 Login 250 | verb("SNMP v2c login"); 251 | ($session, $error) = Net::SNMP->session( 252 | -hostname => $o_host, 253 | -version => 2, 254 | -community => $o_community, 255 | -port => $o_port, 256 | -timeout => $o_timeout, 257 | -domain => $o_domain 258 | ); 259 | } else { 260 | 261 | # SNMPV1 login 262 | verb("SNMP v1 login"); 263 | ($session, $error) = Net::SNMP->session( 264 | -hostname => $o_host, 265 | -community => $o_community, 266 | -port => $o_port, 267 | -timeout => $o_timeout, 268 | -domain => $o_domain 269 | ); 270 | } 271 | } 272 | if (!defined($session)) { 273 | printf("ERROR opening session: %s.\n", $error); 274 | exit $ERRORS{"UNKNOWN"}; 275 | } 276 | 277 | my $exit_val = undef; 278 | ########### NHR checks ############## 279 | 280 | my $nhr_num = 0; # nujmber of NHR 281 | my @nhr_table = undef; # index of NHR 282 | my $output = undef; 283 | my $perf_output = ""; 284 | my @oids = undef; 285 | my $inactive_nhr = 0; 286 | my $global_status = 0; 287 | 288 | # Get load table 289 | my $resultat 290 | = (version->parse(Net::SNMP->VERSION) < 4) 291 | ? $session->get_table($lp_type) 292 | : $session->get_table(Baseoid => $lp_type); 293 | 294 | if (!defined($resultat)) { 295 | printf("ERROR: NHR table : %s.\n", $session->error); 296 | $session->close; 297 | exit $ERRORS{"UNKNOWN"}; 298 | } 299 | my $oidindex = 0; 300 | foreach my $key (keys %$resultat) { 301 | verb("OID : $key, Desc : $$resultat{$key}"); 302 | if ($$resultat{$key} == 2) { # found NHR 303 | $key =~ s/$lp_type\.//; 304 | $nhr_table[$nhr_num++] = $key; 305 | $oids[$oidindex++] = $lp_name . "." . $key; 306 | $oids[$oidindex++] = $lp_users . "." . $key; 307 | $oids[$oidindex++] = $lp_state . "." . $key; 308 | $oids[$oidindex++] = $lp_port . "." . $key; 309 | verb("found nhr : $key"); 310 | } 311 | } 312 | 313 | if ($nhr_num == 0) { 314 | print "No NHR found : CRITICAL\n"; 315 | exit $ERRORS{"CRITICAL"}; 316 | } 317 | 318 | my $result = undef; 319 | if (version->parse(Net::SNMP->VERSION) < 4) { 320 | $result = $session->get_request(@oids); 321 | } else { 322 | if ($session->version == 0) { 323 | 324 | # snmpv1 325 | $result = $session->get_request(-varbindlist => \@oids); 326 | } else { 327 | 328 | # snmp v2c or v3 : get_bulk_request is not really good for this, so do simple get 329 | $result = $session->get_request(-varbindlist => \@oids); 330 | } 331 | } 332 | 333 | if (!defined($result)) { 334 | printf("ERROR: NHR table get : %s.\n", $session->error); 335 | $session->close; 336 | exit $ERRORS{"UNKNOWN"}; 337 | } 338 | 339 | my ($nhr_name, $nhr_state, $nhr_users) = (undef, undef, undef); 340 | my @nhr_text_state = ("", "active", "Not in service", "No new session"); 341 | for (my $i = 0; $i < $nhr_num; $i++) { 342 | if (defined($output)) { $output .= "; "; } 343 | $nhr_name = $$result{ $lp_name . "." . $nhr_table[$i] }; 344 | $nhr_state = $$result{ $lp_state . "." . $nhr_table[$i] }; 345 | $nhr_users = $$result{ $lp_users . "." . $nhr_table[$i] }; 346 | $output .= $nhr_name . "(" . $nhr_users . "):" . $nhr_text_state[$nhr_state]; 347 | if ($nhr_state == 1) { 348 | if (defined($o_perf)) { 349 | if (defined($perf_output)) { $perf_output .= " "; } 350 | $perf_output .= $nhr_name . "=" . $nhr_users; 351 | } 352 | } elsif ($nhr_state == 2) { 353 | $inactive_nhr++; 354 | $global_status = 1; 355 | } else { 356 | $global_status = 1; 357 | } 358 | } 359 | 360 | $session->close; 361 | 362 | if ($inactive_nhr == $nhr_num) { 363 | $output .= " : CRITICAL"; 364 | if (defined($o_perf)) { $output .= " | " . $perf_output; } 365 | print $output, "\n"; 366 | exit $ERRORS{"CRITICAL"}; 367 | } 368 | 369 | if ($global_status == 1) { 370 | $output .= " : WARNING"; 371 | if (defined($o_perf)) { $output .= " | " . $perf_output; } 372 | print $output, "\n"; 373 | exit $ERRORS{"WARNING"}; 374 | } 375 | 376 | $output .= " : OK"; 377 | if (defined($o_perf)) { $output .= " | " . $perf_output; } 378 | print $output, "\n"; 379 | exit $ERRORS{"OK"}; 380 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_env.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nagios plugins 6 | 7 | 8 | 9 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 98 | 99 | 360 | 361 | 362 | 363 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Home

82 | 83 |
94 | 95 | 96 | 97 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | 119 | 120 | 121 | 122 | 123 | 336 | 337 | 338 | 339 | 340 | 341 | 354 | 355 | 356 | 357 |
Snmp env check
112 | 113 |

Script : check_snmp_env.pl

114 | 115 |

Last update : April 19 2007

116 | 117 |
124 | 125 |

Description :

126 | 127 |

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

129 |

SNMP Login
130 | 131 |

132 | 133 |

See snmp info page

134 | 135 |

Requirements :

136 | 137 |

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

142 |

Checks

143 |

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

147 |

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

151 |

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

153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 |
Host typeOptionPower supplyFanVoltageTemperatureDisks
CiscociscoYesYesNo (working on it)No (working on it)No
Nokia IpsonokiaYesYesNo.YesNo
BluecoatbcYesYesYesYesYes
IronPortironYesYes, option '-F' in RPMNoYes, option '-c' in CelciusNo
FoundryFoundryYesNo (bug in snmp agent)NoYesNo
209 |

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

212 |

 

213 | 214 |

Dowload 215 | lastest version : 1.2

216 | 217 |

Configurations 218 | 219 | examples

220 | 221 |

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

223 | 224 |

Examples :

225 | 226 |


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

231 | 232 | 233 | 234 | 237 | 240 | 241 | 242 | 243 | 245 | 246 | 247 | 248 | 250 | 251 | 252 | 255 | 259 | 260 | 261 | 263 | 265 | 266 | 267 | 269 | 271 | 272 |
235 |

Get help 236 |

238 |

./check_snmp_env.pl -h

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

Check Cisco for all sensors 254 |

256 |

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

258 |
Check Nokia 262 | for all sensors./check_snmp_env.pl -H 127.0.0.1 264 | -C public -T nokia
checks ironport 268 | fans RPM > 1500 and temp < 70 deg celcius./check_snmp_env.pl -H 127.0.0.1 270 | -C public -T iron -F 1500 -c 70
273 | 274 |

Output of check_snmp_env.pl -h

275 | 276 | 277 | 278 | 279 | 280 | 330 | 331 | 332 | 333 |
281 |


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

Usage: ./check_snmp_env.pl [-v] -H <host> -C <snmp_community> 285 | [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 286 | [-p <port>] -T (cisco|nokia|bc|iron|foundry) [-F <rpm>] 287 | [-c <celcius>] [-f] [-t <timeout>] [-V]
288 | -v, --verbose
289 | print extra debugging information
290 | -h, --help
291 | print this help message
292 | -H, --hostname=HOST
293 | name or IP address of host to check
294 | -C, --community=COMMUNITY NAME
295 | community name for the host's SNMP agent (implies v1 protocol)
296 | -2, --v2c
297 | Use snmp v2c
298 | -l, --login=LOGIN ; -x, --passwd=PASSWD
299 | Login and auth password for snmpv3 authentication
300 | If no priv password exists, implies AuthNoPriv
301 | -X, --privpass=PASSWD
302 | Priv password for snmpv3 (AuthPriv protocol)
303 | -L, --protocols=<authproto>,<privproto>
304 | <authproto> : Authentication protocol (md5|sha : default 305 | md5)
306 | <privproto> : Priv protocole (des|aes : default des) 307 |
308 | -P, --port=PORT
309 | SNMP port (Default 161)
310 | -T, --type=cisco|nokia|bc|iron|foundry
311 | Environemental check :
312 | cisco : voltage,temp,fan,power supply status
313 | will try to check everything present
314 | nokia : fan and power supply
315 | bc : fans, power supply, voltage, disks
316 | iron : fans, power supply, temp
317 | foundry : power supply, temp
318 | -F, --fan=<rpm>
319 | Minimum fan rpm value
320 | -c, --celcius=<celcius>
321 | Maximum temp in degree celcius
322 | -f, --perfparse
323 | Perfparse compatible output
324 | -t, --timeout=INTEGER
325 | timeout for SNMP in seconds (Default: 5)
326 | -V, --version
327 | prints version number
328 |

329 |
334 | 335 |
342 | 343 |

This project is hosted on :
344 | 345 | http://sourceforge.net/projects/nagios-snmp 346 | 347 |

348 | 349 |

Nagios and the Nagios logo are registered 350 | 351 | trademarks of Ethan Galstad.

352 | 353 |
358 | 359 |
364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | -------------------------------------------------------------------------------- /plugins/check_snmp_boostedge.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | ############################## check_snmp_boostedge.pl ################# 3 | # Version : 1.0 4 | # Date : Jan 16 2007 5 | # Author : Patrick Proy ( patrick at proy.org) 6 | # Help : http://www.manubulon.com/nagios/ 7 | # License : GPL - http://www.fsf.org/licenses/gpl.txt 8 | # Changelog : 9 | # Contributors : 10 | ################################################################# 11 | # 12 | # Help : ./check_snmp_boostedge.pl -h 13 | # 14 | 15 | use strict; 16 | use Net::SNMP; 17 | use Getopt::Long; 18 | 19 | # Icinga specific 20 | 21 | my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); 22 | 23 | # SNMP Datas 24 | 25 | my $be_global_status = "1.3.6.1.4.1.4185.12.1.1.3.0"; # boostedge global status (stop(0), start(1)) 26 | 27 | my $be_service_number = "1.3.6.1.4.1.4185.12.1.5.1.0"; # beServiceNumber 28 | 29 | my $be_service_table = "1.3.6.1.4.1.4185.12.1.5"; # beServices 30 | my $be_service_name = "1.3.6.1.4.1.4185.12.1.5.2.1.2"; # beServiceName 31 | my $be_service_status = "1.3.6.1.4.1.4185.12.1.5.2.1.4"; # status ("RUNNING") 32 | my $be_service_mode = "1.3.6.1.4.1.4185.12.1.5.2.1.5"; # beServiceMode (disabled(0), enabled(1)) 33 | 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) 34 | my $be_service_dataout 35 | = "1.3.6.1.4.1.4185.12.1.5.2.1.7"; # beServiceDataOut (Not populated for now : HTTP/S - V5.2.16.0) 36 | my $be_service_connect 37 | = "1.3.6.1.4.1.4185.12.1.5.2.1.8"; # beServiceConnect (Not populated for now : HTTP/S - V5.2.16.0) 38 | 39 | # Globals 40 | 41 | my $VERSION = "2.1.0"; 42 | 43 | my $o_host = undef; # hostname 44 | my $o_community = undef; # community 45 | my $o_port = 161; # port 46 | my $o_domain = 'udp/ipv4'; # protocol 47 | my $o_help = undef; # wan't some help ? 48 | my $o_verb = undef; # verbose mode 49 | my $o_version = undef; # print version 50 | my $o_timeout = undef; # Timeout (Default 5) 51 | my $o_perf = undef; # Output performance data 52 | my $o_version2 = undef; # use snmp v2c 53 | 54 | # Specific 55 | my $o_service = undef; # service regexp selection 56 | my $o_nservice = undef; # service number expected 57 | 58 | # SNMPv3 specific 59 | my $o_login = undef; # Login for snmpv3 60 | my $o_passwd = undef; # Pass for snmpv3 61 | my $v3protocols = undef; # V3 protocol list. 62 | my $o_authproto = 'md5'; # Auth protocol 63 | my $o_privproto = 'des'; # Priv protocol 64 | my $o_privpass = undef; # priv password 65 | 66 | # functions 67 | 68 | sub p_version { print "check_snmp_boostedge version : $VERSION\n"; } 69 | 70 | sub print_usage { 71 | print 72 | "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) -s -n [-p ] [-f] [-t ] [-V]\n"; 73 | } 74 | 75 | sub isnnum { # Return true if arg is not a number 76 | my $num = shift; 77 | if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; } 78 | return 1; 79 | } 80 | 81 | sub set_status { # return worst status with this order : OK, unknwonw, warning, critical 82 | my $new_status = shift; 83 | my $cur_status = shift; 84 | if (($cur_status == 0) || ($new_status == $cur_status)) { return $new_status; } 85 | if ($new_status == 3) { return $cur_status; } 86 | if ($new_status > $cur_status) { return $new_status; } 87 | return $cur_status; 88 | } 89 | 90 | sub is_pattern_valid { # Test for things like "" or "+5-i" 91 | my $pat = shift; 92 | if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings 93 | return eval { "" =~ /$pat/; 1 } || 0; 94 | } 95 | 96 | sub help { 97 | print "\nSNMP Boostedge service monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; 98 | print "GPL License, (c)2006-2007 Patrick Proy\n\n"; 99 | print_usage(); 100 | print < 110 | Regexp of service to select 111 | -n, --number= 112 | Number of services selected that must be in running & enabled state 113 | -2, --v2c 114 | Use snmp v2c 115 | -l, --login=LOGIN ; -x, --passwd=PASSWD 116 | Login and auth password for snmpv3 authentication 117 | If no priv password exists, implies AuthNoPriv 118 | -X, --privpass=PASSWD 119 | Priv password for snmpv3 (AuthPriv protocol) 120 | -L, --protocols=, 121 | : Authentication protocol (md5|sha : default md5) 122 | : Priv protocole (des|aes : default des) 123 | -P, --port=PORT 124 | SNMP port (Default 161) 125 | --protocol=PROTOCOL 126 | Network protocol to be used 127 | ['udp/ipv4'] : UDP over IPv4 128 | 'udp/ipv6' : UDP over IPv6 129 | 'tcp/ipv4' : TCP over IPv4 130 | 'tcp/ipv6' : TCP over IPv6 131 | 132 | Network protocol (Default udp/ipv4) 133 | -f, --perfparse, --perfdata 134 | Performance data output 135 | -t, --timeout=INTEGER 136 | timeout for SNMP in seconds (Default: 5) 137 | -V, --version 138 | prints version number 139 | EOT 140 | } 141 | 142 | # For verbose output 143 | sub verb { my $t = shift; print $t, "\n" if defined($o_verb); } 144 | 145 | sub check_options { 146 | Getopt::Long::Configure("bundling"); 147 | GetOptions( 148 | 'v' => \$o_verb, 149 | 'verbose' => \$o_verb, 150 | 'h' => \$o_help, 151 | 'help' => \$o_help, 152 | 'H:s' => \$o_host, 153 | 'hostname:s' => \$o_host, 154 | 'p:i' => \$o_port, 155 | 'port:i' => \$o_port, 156 | 'protocol:s' => \$o_domain, 157 | 'C:s' => \$o_community, 158 | 'community:s' => \$o_community, 159 | 'l:s' => \$o_login, 160 | 'login:s' => \$o_login, 161 | 'x:s' => \$o_passwd, 162 | 'passwd:s' => \$o_passwd, 163 | 'X:s' => \$o_privpass, 164 | 'privpass:s' => \$o_privpass, 165 | 'L:s' => \$v3protocols, 166 | 'protocols:s' => \$v3protocols, 167 | 't:i' => \$o_timeout, 168 | 'timeout:i' => \$o_timeout, 169 | 'V' => \$o_version, 170 | 'version' => \$o_version, 171 | '2' => \$o_version2, 172 | 'v2c' => \$o_version2, 173 | 'f' => \$o_perf, 174 | 'perfparse' => \$o_perf, 175 | 'perfdata' => \$o_perf, 176 | 's:s' => \$o_service, 177 | 'service:s' => \$o_service, 178 | 'n:i' => \$o_nservice, 179 | 'number:i' => \$o_nservice 180 | ); 181 | 182 | # Basic checks 183 | if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) { 184 | print "Timeout must be >1 and <60 !\n"; 185 | print_usage(); 186 | exit $ERRORS{"UNKNOWN"}; 187 | } 188 | if (!defined($o_timeout)) { $o_timeout = 5; } 189 | if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } 190 | if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } 191 | if (!defined($o_host)) # check host and filter 192 | { 193 | print_usage(); 194 | exit $ERRORS{"UNKNOWN"}; 195 | } 196 | 197 | # check snmp information 198 | if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) { 199 | print "Put snmp login info!\n"; 200 | print_usage(); 201 | exit $ERRORS{"UNKNOWN"}; 202 | } 203 | if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) { 204 | print "Can't mix snmp v1,2c,3 protocols!\n"; 205 | print_usage(); 206 | exit $ERRORS{"UNKNOWN"}; 207 | } 208 | if (defined($v3protocols)) { 209 | if (!defined($o_login)) { 210 | print "Put snmp V3 login info with protocols!\n"; 211 | print_usage(); 212 | exit $ERRORS{"UNKNOWN"}; 213 | } 214 | my @v3proto = split(/,/, $v3protocols); 215 | if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol 216 | if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol 217 | if ((defined($v3proto[1])) && (!defined($o_privpass))) { 218 | print "Put snmp V3 priv login info with priv protocols!\n"; 219 | print_usage(); 220 | exit $ERRORS{"UNKNOWN"}; 221 | } 222 | } 223 | if (!defined($o_service) || !(is_pattern_valid($o_service))) { 224 | print "Service selection must be set and be a valid regexp\n"; 225 | print_usage(); 226 | exit $ERRORS{"UNKNOWN"}; 227 | } 228 | if (!defined($o_nservice) || isnnum($o_nservice)) { 229 | print "Service number must be set and be an integer\n"; 230 | print_usage(); 231 | exit $ERRORS{"UNKNOWN"}; 232 | } 233 | } 234 | 235 | ########## MAIN ####### 236 | 237 | check_options(); 238 | 239 | # Check timeout if snmp screws up 240 | if (defined($o_timeout)) { 241 | verb("Alarm in $o_timeout seconds"); 242 | alarm($o_timeout); 243 | } 244 | 245 | $SIG{'ALRM'} = sub { 246 | print "No answer from host $o_host:$o_port\n"; 247 | exit $ERRORS{"UNKNOWN"}; 248 | }; 249 | 250 | # Connect to host 251 | my ($session, $error); 252 | if (defined($o_login) && defined($o_passwd)) { 253 | 254 | # SNMPv3 login 255 | verb("SNMPv3 login"); 256 | if (!defined($o_privpass)) { 257 | verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto"); 258 | ($session, $error) = Net::SNMP->session( 259 | -hostname => $o_host, 260 | -port => $o_port, 261 | -version => '3', 262 | -username => $o_login, 263 | -authpassword => $o_passwd, 264 | -authprotocol => $o_authproto, 265 | -timeout => $o_timeout, 266 | -domain => $o_domain 267 | ); 268 | } else { 269 | verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto"); 270 | ($session, $error) = Net::SNMP->session( 271 | -hostname => $o_host, 272 | -port => $o_port, 273 | -version => '3', 274 | -username => $o_login, 275 | -authpassword => $o_passwd, 276 | -authprotocol => $o_authproto, 277 | -privpassword => $o_privpass, 278 | -privprotocol => $o_privproto, 279 | -timeout => $o_timeout, 280 | -domain => $o_domain 281 | ); 282 | } 283 | } else { 284 | if (defined($o_version2)) { 285 | 286 | # SNMPv2 Login 287 | verb("SNMP v2c login"); 288 | ($session, $error) = Net::SNMP->session( 289 | -hostname => $o_host, 290 | -version => 2, 291 | -community => $o_community, 292 | -port => $o_port, 293 | -timeout => $o_timeout, 294 | -domain => $o_domain 295 | ); 296 | } else { 297 | 298 | # SNMPV1 login 299 | verb("SNMP v1 login"); 300 | ($session, $error) = Net::SNMP->session( 301 | -hostname => $o_host, 302 | -community => $o_community, 303 | -port => $o_port, 304 | -timeout => $o_timeout, 305 | -domain => $o_domain 306 | ); 307 | } 308 | } 309 | if (!defined($session)) { 310 | printf("ERROR opening session: %s.\n", $error); 311 | exit $ERRORS{"UNKNOWN"}; 312 | } 313 | 314 | # Get global status 315 | my @oidlist = ($be_global_status); 316 | my $resultat 317 | = (version->parse(Net::SNMP->VERSION) < 4) 318 | ? $session->get_request(@oidlist) 319 | : $session->get_request(-varbindlist => \@oidlist); 320 | 321 | if (!defined($resultat)) { 322 | printf("ERROR: Gloabal status table : %s.\n", $session->error); 323 | $session->close; 324 | exit $ERRORS{"UNKNOWN"}; 325 | } 326 | 327 | if ($$resultat{$be_global_status} != 1) { 328 | print "Global service is stopped (", $$resultat{$be_global_status}, ") : CRITICAL\n"; 329 | exit $ERRORS{"CRITICAL"}; 330 | } 331 | 332 | $resultat = undef; 333 | 334 | # Get service table 335 | $resultat 336 | = (version->parse(Net::SNMP->VERSION) < 4) 337 | ? $session->get_table($be_service_table) 338 | : $session->get_table(Baseoid => $be_service_table); 339 | 340 | if (!defined($resultat)) { 341 | printf("ERROR: Description table : %s.\n", $session->error); 342 | $session->close; 343 | exit $ERRORS{"UNKNOWN"}; 344 | } 345 | $session->close; 346 | 347 | my $output = ""; 348 | my $output_perf = ""; 349 | my $global_status = 0; 350 | my ($nservice, $nservice_ok) = (0, 0); 351 | my (@found_service, @service_state) = undef; 352 | 353 | foreach my $key (keys %$resultat) { 354 | verb("OID : $key, Desc : $$resultat{$key}"); 355 | if (($key =~ /$be_service_name\./) && ($$resultat{$key} =~ /$o_service/)) { # Get index of service with name 356 | $found_service[$nservice] = $$resultat{$key}; 357 | $key =~ s/$be_service_name//; 358 | $service_state[$nservice] = $$resultat{ $be_service_status . $key }; 359 | if (($service_state[$nservice] ne "RUNNING") || ($$resultat{ $be_service_mode . $key } != 1)) { 360 | $service_state[$nservice] .= "(" . $$resultat{ $be_service_mode . $key } . ")"; 361 | $global_status = 2; 362 | } else { 363 | $nservice_ok++; 364 | } 365 | $nservice++; 366 | verb("Found service $found_service[$nservice-1]"); 367 | } 368 | } 369 | 370 | if ($o_nservice > $nservice_ok) { 371 | for (my $i = 0; $i < $nservice; $i++) { 372 | if ($output ne "") { $output .= ", "; } 373 | $output .= $found_service[$i] . ":" . $service_state[$i]; 374 | } 375 | if ($output ne "") { $output .= ", "; } 376 | $output .= ":" . $nservice_ok . " services OK < " . $o_nservice; 377 | print $output, " : CRITICAL\n"; 378 | exit $ERRORS{"CRITICAL"}; 379 | } 380 | 381 | $output = $nservice_ok . " services OK"; 382 | if ($o_nservice < $nservice_ok) { 383 | print $output, " > $o_nservice : WARNING\n"; 384 | exit $ERRORS{"WARNING"}; 385 | } 386 | print $output, " : OK\n"; 387 | exit $ERRORS{"OK"}; 388 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nagios plugins 6 | 7 | 8 | 9 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 98 | 99 | 371 | 372 | 373 | 374 |
62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 |
Home

82 | 83 |
94 | 95 | 96 | 97 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 118 | 119 | 120 | 121 | 122 | 123 | 347 | 348 | 349 | 350 | 351 | 352 | 365 | 366 | 367 | 368 |
Snmp CSS check
112 | 113 |

Script : check_snmp_css.pl / check_snmp_css_main.pl

114 | 115 |

Last update : Jan 22 2007

116 | 117 |
124 | 125 |

Description :

126 | 127 |

Checks by snmp v1, v2c or v3 CSS services state

128 |

SNMP Login
129 | 130 |

131 | 132 |

See snmp info page

133 | 134 |

Requirements :

135 | 136 |

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

141 |

Checks

142 |

This scripts checks status of the CSS services.

143 |

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

145 |

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

151 |

You can choose not to put 1, 2 or 3 numbers. 152 |
153 | If you set "-w 3" only the number of active services will 154 | be checked.
155 | If you set "-w 3,200" only the number of active services 156 | and response time will be checked.
157 |
158 | For no warnings, put -1 (ex : -w5,-1,3).
159 | When using negative numbers, dont put space after "-w" 160 | : "-w -1,100,6" will not work, "-w-1,100,6" 161 | will work.

162 |

-d option and check_snmp_css_main.pl

163 |

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

165 |

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

169 |

If you use check_snmp_css, then it will read 170 | the index (50 oids) + checks 5 oids = 55 OID every 12 seconds in 171 | average. This will heavily load the CSS.
172 | This is why I wrote check_snmp_css_main.pl. This script will get 173 | the index of the CSS every 10 minutes for example (could be more) 174 | as the index won't change often.
175 | Then the check_snmp_css will only have to check for the 5 oids every 176 | 12 seconds, which will reduce by about 10 the amount of snmp queries 177 | !

178 |

How to use it :

179 |

Create a service with long inter-delay check 180 | executing :

181 |

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

186 |

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

188 |

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

191 |

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

196 |

A lockfile is created bye check_snmp_css_main.pl 197 | when it writes it's file. The check_snmp_css script will wait until 198 | the lock file is removed to read the index file.
199 | The lock file is named : Nagios_CSS_<IP Address>.lock
200 |
The lock file format is simple: every line is in format 201 |
202 | <OID>:<Service name>

203 |

 

204 |

Dowload 205 | lastest version of check_snmp_css.pl : 1.0

206 |

Dowload 207 | lastest version of check_snmp_css_main.pl : 1.0

208 | 209 |

Configurations 210 | 211 | examples

212 | 213 |

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

215 | 216 |

Examples :

217 | 218 |


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

223 | 224 | 225 | 226 | 229 | 232 | 233 | 234 | 235 | 237 | 238 | 239 | 240 | 242 | 243 |
227 |

Get help 228 |

230 |

./check_snmp_css.pl -h

231 |
Verbose output./check_snmp_css.pl -H <IP> 236 | -C <com> -v
snmpv3 login./check_snmp_css.pl -H 127.0.0.1 241 | -l login -x passwd
244 | 245 |

Output of check_snmp_css.pl -h

246 | 247 | 248 | 249 | 250 | 300 | 301 | 302 | 303 |
251 |
252 |  SNMP Cisco CSS monitor for Nagios version 1.0
253 | (c)2004-2006 Patrick Proy
254 | 
255 | Usage: ./check_snmp_css.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 
256 |        -n <name> [-d directory] [-w <num>,<resp>,<conn> -c <num>,<resp>,<conn>]  [-p <port>] [-f] [-t <timeout>] [-V]
257 | -v, --verbose
258 |    print extra debugging information 
259 | -h, --help
260 |    print this help message
261 | -H, --hostname=HOST
262 |    name or IP address of host to check
263 | -n, --name=<name> 
264 |    regexp to select service
265 | -w, --warning=<num>,<resp>,<conn> 
266 |    Optional. Warning level for
267 |    - minimum number of active & alive service 
268 |    - average response time
269 |    - number of connexions
270 |    For no warnings, put -1 (ex : -w5,-1,3).
271 |    When using negative numbers, dont put space after "-w"
272 | -d, --dir=<directory to put file> 
273 |    Directory where the temp file with index, created by check_snmp_css_main.pl, can be found
274 |    If no directory is set, /tmp will be used
275 | -c, --critical=<num>,resp>,<conn>
276 |    Optional. Critical levels (-1 for no critical levels)
277 |    See warning levels.
278 | -C, --community=COMMUNITY NAME
279 |    community name for the host's SNMP agent (implies v1 protocol)
280 | -2, --v2c
281 |    Use snmp v2c
282 | -l, --login=LOGIN ; -x, --passwd=PASSWD
283 |    Login and auth password for snmpv3 authentication 
284 |    If no priv password exists, implies AuthNoPriv 
285 | -X, --privpass=PASSWD
286 |    Priv password for snmpv3 (AuthPriv protocol)
287 | -L, --protocols=<authproto>,<privproto>
288 |    <authproto> : Authentication protocol (md5|sha : default md5)
289 |    <privproto> : Priv protocole (des|aes : default des) 
290 | -P, --port=PORT
291 |    SNMP port (Default 161)
292 | -f, --perfparse
293 |    Perfparse compatible output
294 | -t, --timeout=INTEGER
295 |    timeout for SNMP in seconds (Default: 5)
296 | -V, --version
297 |    prints version number
298 | 
299 |
304 | 305 |
306 |

Output of check_snmp_css_main.pl -h

307 | 308 | 309 | 344 | 345 |
310 |
311 |  SNMP Cisco CSS monitor MAIN script for Nagios version 1.0
312 | GPL Licence, (c)2004-2006 Patrick Proy
313 | 
314 | Usage: ./check_snmp_css_main.pl [-v] -H <host> -C <snmp_community> [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 
315 |        [-d directory] [-p <port>] [-t <timeout>] [-V]
316 | -v, --verbose
317 |    print extra debugging information 
318 | -h, --help
319 |    print this help message
320 | -H, --hostname=HOST
321 |    name or IP address of host to check
322 | -d, --dir=<directory to put file> 
323 |    Directory where temp file with index is written
324 | -C, --community=COMMUNITY NAME
325 |    community name for the host's SNMP agent (implies v1 protocol)
326 | -2, --v2c
327 |    Use snmp v2c
328 | -l, --login=LOGIN ; -x, --passwd=PASSWD
329 |    Login and auth password for snmpv3 authentication 
330 |    If no priv password exists, implies AuthNoPriv 
331 | -X, --privpass=PASSWD
332 |    Priv password for snmpv3 (AuthPriv protocol)
333 | -L, --protocols=<authproto>,<privproto>
334 |    <authproto> : Authentication protocol (md5|sha : default md5)
335 |    <privproto> : Priv protocole (des|aes : default des) 
336 | -P, --port=PORT
337 |    SNMP port (Default 161)
338 | -t, --timeout=INTEGER
339 |    timeout for SNMP in seconds (Default: 5)
340 | -V, --version
341 |    prints version number
342 | 
343 |
346 |
353 | 354 |

This project is hosted on :
355 | 356 | http://sourceforge.net/projects/nagios-snmp 357 | 358 |

359 | 360 |

Nagios and the Nagios logo are registered 361 | 362 | trademarks of Ethan Galstad.

363 | 364 |
369 | 370 |
375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_cpfw.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Nagios plugins 8 | 9 | 10 | 11 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 100 | 101 | 457 | 458 | 459 | 460 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 |
Home

84 | 85 |
96 | 97 | 98 | 99 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 120 | 121 | 122 | 123 | 124 | 125 | 433 | 434 | 435 | 436 | 437 | 438 | 451 | 452 | 453 | 454 |
Snmp Checkpoint FW-1 check
114 | 115 |

Script : check_snmp_cpfw.pl

116 | 117 |

Last update : April 19 2007

118 | 119 |
126 | 127 |

Description :

128 | 129 |

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

131 | 132 |

You can choose to check 1, 2, 3 or all 4 modules. 133 | 134 | Each module will be checked independently and critical state will 135 | 136 | be returned if one of them is not OK.

137 | 138 |

- Firewall (on filtering firewall) :

139 | 140 |

Checks policy state : must be installed
141 | 142 | Can check installed policy name : you mut provide the exact name 143 | 144 | of the policy (-p = <policy name>)
145 | 146 | Can check connections : warning and maximum levels must be provided 147 | 148 | ( -c=<warn>,<crit>)

149 | 150 |

- SVN

151 | 152 |

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

155 | 156 |

- Management

157 | 158 |

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

161 | 162 |

- High availability

163 | 164 |

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

172 |

SNMP Login
173 |

174 |

See snmp info page

175 | 176 |

Requirements :

177 | 178 |

- On the Checkpoint Firewall : SNMP extentions 179 | 180 | must be active

181 | 182 |

- Perl in /usr/bin/perl - or just run 'perl 183 | 184 | script'
185 | 186 | - Net::SNMP
187 | 188 | - file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec)

189 | 190 |

Configurations 191 | 192 | examples
193 | 194 |

195 | 196 |

Dowload 197 | lastest version : 1.2.1

198 | 199 |

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

201 | 202 |

Examples :

203 | 204 |


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

209 | 210 | 211 | 212 | 213 | 214 | 219 | 220 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 235 | 236 | 237 | 238 | 239 | 240 | 245 | 246 | 251 | 252 | 253 | 254 | 255 | 256 | 261 | 262 | 267 | 268 | 269 | 270 | 271 | 272 | 277 | 278 | 283 | 284 | 285 | 286 | 287 | 288 | 293 | 294 | 297 | 298 | 299 | 300 | 301 | 302 | 305 | 306 | 309 | 310 | 311 | 312 | 313 | 314 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 331 | 332 | 335 | 336 | 337 | 338 | 339 | 340 | 343 | 344 | 347 | 348 | 349 | 350 | 351 | 352 | 357 | 358 | 361 | 362 | 363 | 364 |
215 | 216 |

Get help 217 | 218 |

221 | 222 |

./check_snmp_cpfw.pl -h

223 | 224 |
snmpv3 login./check_snmp_cpfw.pl -H 127.0.0.1 233 | 234 | -l login -x passwd .....
241 | 242 |

Check firewall / HA / SVN - for a HA filtering module - 243 | 244 |

247 | 248 |

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

249 | 250 |
257 | 258 |

Result example : 259 | 260 |

263 | 264 |

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

265 | 266 |
273 | 274 |

Check SVN/Mgmt - for a management - 275 | 276 |

279 | 280 |

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

281 | 282 |
289 | 290 |
Result example :
291 | 292 |
SVN : OK / MGMT : OK / CPFW 295 | 296 | Status : OK
Check policy 303 | 304 | name ./check_snmp_cpfw.pl -H 127.0.0.1 307 | 308 | -C public -w -p prod
315 | 316 |

Result example :

317 | 318 |
FW : OK / CPFW Status : OK
327 | 328 |
Same with another policy installed :
329 | 330 |
FW : Policy installed : Standard 333 | 334 | / CPFW Status : CRITICAL
Check number 341 | 342 | of active connection with performance data output./check_snmp_cpfw.pl -H 127.0.0.1 345 | 346 | -C public -w -c 1000,5000 -f
353 | 354 |
Result example :
355 | 356 |
FW : OK / CPFW Status : OK 359 | 360 | | fw_connexions=340
365 | 366 |

 

367 | 368 |

Output of check_snmp_cpfw.pl -h

369 | 370 | 371 | 372 | 373 | 374 | 427 | 428 | 429 | 430 |
375 |

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

Usage: ./check_snmp_cpfw.pl [-v] -H <host> -C <snmp_community> 379 | [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 380 | [-s] [-w [-p=pol_name] [-c=warn,crit]] [-m] [-a [standby] 381 | ] [-f] [-p <port>] [-t <timeout>] [-V]
382 | -v, --verbose
383 | print extra debugging information (including interface list 384 | on the system)
385 | -h, --help
386 | print this help message
387 | -H, --hostname=HOST
388 | name or IP address of host to check
389 | -C, --community=COMMUNITY NAME
390 | community name for the host's SNMP agent (implies v1 protocol)
391 | 2, --v2c
392 | Use snmp v2c
393 | -l, --login=LOGIN ; -x, --passwd=PASSWD
394 | Login and auth password for snmpv3 authentication
395 | If no priv password exists, implies AuthNoPriv
396 | -X, --privpass=PASSWD
397 | Priv password for snmpv3 (AuthPriv protocol)
398 | -L, --protocols=<authproto>,<privproto>
399 | <authproto> : Authentication protocol (md5|sha : default 400 | md5)
401 | <privproto> : Priv protocole (des|aes : default des) 402 |
403 | -s, --svn
404 | check for svn status
405 | -w, --fw
406 | check for fw status
407 | -a, --ha[=standby]
408 | check for ha status and node in "active" state
409 | If using SecurePlatform and monitoring a standby unit, put 410 | "standby" too
411 | -m, --mgmt
412 | check for management status
413 | -p, --policy=POLICY_NAME
414 | check if installed policy is POLICY_NAME (must have -w)
415 | -c, --connexions=WARN,CRIT
416 | check warn and critical number of connexions (must have -w)
417 | -f, --perfparse
418 | perfparse output (only works with -c)
419 | -P, --port=PORT
420 | SNMP port (Default 161)
421 | -t, --timeout=INTEGER
422 | timeout for SNMP (Default: Nagios default)
423 | -V, --version
424 | prints version number
425 |

426 |
431 | 432 |
439 | 440 |

This project is hosted on :
441 | 442 | http://sourceforge.net/projects/nagios-snmp 443 | 444 |

445 | 446 |

Nagios and the Nagios logo are registered 447 | 448 | trademarks of Ethan Galstad.

449 | 450 |
455 | 456 |
461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/snmp_load.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Nagios plugins 6 | 7 | 8 | 9 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 96 | 97 | 397 | 398 | 399 | 400 |
60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |
Home

80 | 81 |
92 | 93 | 94 | 95 |
98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 116 | 117 | 118 | 119 | 120 | 121 | 373 | 374 | 375 | 376 | 377 | 378 | 391 | 392 | 393 | 394 |
Snmp load check
110 | 111 |

Script : check_snmp_load.pl

112 | 113 |

Last update : Sept 5 2006

114 | 115 |
122 | 123 |

Description :

124 | 125 |

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

132 | 133 |

Check types are selected by the -T option : 134 | 135 |

136 | 137 | 138 | 139 | 142 | 145 | 148 | 149 | 150 | 151 | 152 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 170 | 171 | 172 | 173 | 174 | 176 | 177 | 178 | 179 | 180 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 213 | 214 |
140 |
-T value
141 |
143 |
System
144 |
146 |
-w & -c values
147 |
netslLinux : load provided by Net SNMP3 values : load average on 1 min, 5 min, 153 | 15 min (absolute)
netscLinux : CPU usage given by net-snmp1 value in %
as400as400 CPU usage1 value in %
ciscocisco CPU usage3 values : CPU average on 5sec, 1 min 169 | & 5 min (%)
catacisco catalyst CPU usage3 values : CPU average on 5sec, 1 min 175 | & 5 min (%)
nscNetscreen CPU usage3 values : CPU average on 5sec, 1 min 181 | & 5 min (%)
fgFortigate CPU usage1 value in %
bcbluecoat CPU usage1 value in %
nokianokia CPU usage1 value in %
hpHP procurve switch CPU usage1 value in %
lpLinkproof CPU usage1 value in %
hpuxHP-UX load3 values : load average on 1 min, 5 min, 212 | 15 min
215 | 216 |

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

219 | 220 |

SNMP Login
221 | 222 |

223 | 224 |

See snmp info page

225 | 226 |

Requirements :

227 | 228 |

- Perl in /usr/bin/perl - or just run 'perl 229 | 230 | script'
231 | 232 | - Net::SNMP
233 | 234 | - file 'utils.pm' in plugin diretory
235 | 236 |

237 | 238 |

Dowload 239 | lastest version : 1.3.2

240 | 241 |

Configurations 242 | 243 | examples

244 | 245 |

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

247 |

Examples :

248 | 249 |


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

254 | 255 |

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

258 | 259 | 260 | 261 | 264 | 267 | 268 | 269 | 273 | 277 | 278 | 279 | 283 | 287 | 288 | 289 | 292 | 296 | 297 |
262 |

Get help 263 |

265 |

./check_snmp_load.pl -h

266 |
270 |

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

274 |

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

276 |
280 |

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

284 |

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

286 |
290 |

Check cpu load on AS/400 291 |

293 |

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

295 |
298 | 299 |

Output of check_snmp_load.pl -h

300 | 301 | 302 | 303 | 304 | 305 | 367 | 368 | 369 | 370 |
306 | SNMP Load & CPU Monitor for Nagios version 1.3
307 | (c)2004-2006 Patrick Proy 308 |

Usage: ./check_snmp_load.pl [-v] -H <host> -C <snmp_community> 309 | [-2] | (-l login -x passwd [-X pass -L <authp>,<privp>]) 310 | [-p <port>] -w <warn level> -c <crit level> 311 | -T=[stand|netsl|netsc|as400|cisco|cata|nsc|fg|bc|nokia|hp|lp] 312 | [-f] [-t <timeout>] [-V]
313 | -v, --verbose
314 | print extra debugging information
315 | -h, --help
316 | print this help message
317 | -H, --hostname=HOST
318 | name or IP address of host to check
319 | -C, --community=COMMUNITY NAME
320 | community name for the host's SNMP agent (implies v1 protocol)
321 | -2, --v2c
322 | Use snmp v2c
323 | -l, --login=LOGIN ; -x, --passwd=PASSWD
324 | Login and auth password for snmpv3 authentication
325 | If no priv password exists, implies AuthNoPriv
326 | -X, --privpass=PASSWD
327 | Priv password for snmpv3 (AuthPriv protocol)
328 | -L, --protocols=<authproto>,<privproto>
329 | <authproto> : Authentication protocol (md5|sha : default 330 | md5)
331 | <privproto> : Priv protocole (des|aes : default des) 332 |
333 | -P, --port=PORT
334 | SNMP port (Default 161)
335 | -w, --warn=INTEGER | INT,INT,INT
336 | 1 value check : warning level for cpu in percent (on one minute)
337 | 3 value check : comma separated level for load or cpu for 338 | 1min, 5min, 15min
339 | -c, --crit=INTEGER | INT,INT,INT
340 | critical level for cpu in percent (on one minute)
341 | 1 value check : critical level for cpu in percent (on one 342 | minute)
343 | 3 value check : comma separated level for load or cpu for 344 | 1min, 5min, 15min
345 | -T, --type=stand|netsl|netsc|as400|cisco|bc|nokia|hp|lp
346 | CPU check :
347 | stand : standard MIBII (works with Windows),
348 | can handle multiple CPU.
349 | netsl : linux load provided by Net SNMP
350 | netsc : cpu usage given by net-snmp (100-idle)
351 | as400 : as400 CPU usage
352 | cisco : Cisco CPU usage
353 | cata : Cisco catalyst CPU usage
354 | nsc : NetScreen CPU usage
355 | fg : Fortigate CPU usage
356 | bc : Bluecoat CPU usage
357 | nokia : Nokia CPU usage
358 | hp : HP procurve switch CPU usage
359 | lp : Linkproof CPU usage
360 | -f, --perfparse
361 | Perfparse compatible output
362 | -t, --timeout=INTEGER
363 | timeout for SNMP in seconds (Default: 5)
364 | -V, --version
365 | prints version number

366 |
371 | 372 |
379 | 380 |

This project is hosted on :
381 | 382 | http://sourceforge.net/projects/nagios-snmp 383 | 384 |

385 | 386 |

Nagios and the Nagios logo are registered 387 | 388 | trademarks of Ethan Galstad.

389 | 390 |
395 | 396 |
401 | 402 |

 

403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | -------------------------------------------------------------------------------- /doc/html/nagios.manubulon.com/faq.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Nagios plugins 4 | 5 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 106 | 107 | 108 | 294 | 295 | 296 | 297 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 69 | 70 | 71 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 |
This site :
Home
Nagios plugins
Info on snmp
Nagios config
FAQ
Project page on SourceForge
-----------
Links :
Nagios 67 | 68 | Home
Nagios 72 | Plugins
Oreon project
NagiosExchange
Opsyx 82 | forum
Forum 2037
-----------
Others :
95 |
-----------
http://sourceforge.net/projects/nagios-snmp
104 | 105 |
109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 127 | 128 | 129 | 130 | 131 | 132 | 281 | 282 | 283 | 284 | 289 | 290 | 291 |
FAQ
121 | 122 |

 

123 | 124 |

Last update : May 25 2007

125 | 126 |
133 | 134 |

 

135 |

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

137 |

Running the scripts :

138 |

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

140 |

- How do I install Net::SNMP 141 | perl module

142 |

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

144 |

- How do I get help on the 145 | options ?

146 |

- Return code of X is out of 147 | bounds

148 |

- Are these plugins compatible 149 | with Nagios 2.0 ?

150 |

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

152 |

- "No Output" using 153 | Nagios 2

154 |

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

156 |

- No usable data on file (X rows)

157 |

Misc
158 |

159 |

- Are these scripts secure 160 | ?

161 |

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

163 |

- Can I donate to help this 164 | project ?

165 |
166 |

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

168 |

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

169 |

How do I install Net::SNMP 170 | perl module ?

171 |

There are 2 ways of doing this

172 |

1) By CPAN (best)

173 |

on command line, as root :
174 |
175 | [your_host]# perl -MCPAN -e shell
176 | cpan shell -- CPAN exploration and modules installation (v1.76)
177 | ReadLine support enabled
178 | cpan> install Net::SNMP
179 |

180 |

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

182 |

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

184 |

2) "By hand"
185 |

186 |

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

188 |

- Crypt::DES
189 | - Digest::MD5
190 | - Digest::SHA1
191 | - Digest::HMAC
192 | - Net::SNMP
193 |
194 | for each one (you must install Net::SNMP at the end) :
195 | tar zxf <module>.tar.gz
196 | cd <module>
197 | perl Makefile.pl
198 | make test
199 | make install

200 |

What are the supported 201 | platforms to run the scripts on ?

202 |

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

206 |

How do I get help on the 207 | options ?

208 |

Just run <script> -h on the command 209 | line.
210 |
211 |

212 |

Return code of X is out 213 | of bounds

214 |

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

215 |

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

217 |

define command{
218 | command_name check_disk
219 | command_line /usr/bin/perl $USER1$/check_snmp_storage.pl 220 | -C $ARG1$ [........]
221 | }
222 |

223 |

Are these plugins compatible 224 | with Nagios 2.0 ?

225 |

Yes.

226 |

ERROR: XXXXXX : Expected OBJECT IDENTIFIER in dotted notation. 227 |

228 |

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

231 |

"No Output" using 232 | Nagios 2

233 |

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

235 |

You can :
236 |

237 |

- Add a patch if your nagios release is old. 238 | Here is a patch made by Gavin Carr for the p1.pl file to correct 239 | this (it should be in nagios CVS shortly). http://nagios.manubulon.com/p1-print.pl.patch 240 |

241 |

- Upgrade Nagios.
242 |
243 | - add "/usr/bin/perl" before the script command so Nagios 244 | won't use embeded perl.

245 |

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

247 |

Your snmp table is too big.

248 |

Some of my scripts (check_snmp_storage and 249 | check_snmp_process) now have an option (-o) to set this directly 250 | on command line (thx to Makina Corpus for the patch).

251 |

In other scripts, try adding :

252 |

$session->max_msg_size(5000);
253 |

254 |

After the session has been initialized.

255 |

No usable data on file (X rows)

256 |

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

257 |

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.

258 |

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

262 |

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

263 |

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

265 |


266 | Are these scripts secure ?

267 |

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

271 |

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

273 |

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

Can 275 | I donate to help this project ?

276 |

Of course you can, I just haven't got any idea 277 | 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...).
278 | You can get my postal address on my resume (www.manubulon.com/cvpproy.htm).
279 | He will answer you when he knows how to write (in several years).

280 |
285 |

This project is also hosted by :
286 | 287 | http://sourceforge.net/projects/nagios-snmp 288 |

292 | 293 |
298 | 299 |

 

300 | 301 | 302 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /plugins/check_snmp_win.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | ############################## check_snmp_win ############## 3 | my $VERSION = "2.1.0"; 4 | 5 | # Date : Oct 12 2007 6 | # Author : Patrick Proy (patrick at proy.org) 7 | # Help : http://nagios.manubulon.com/ 8 | # License : GPL - http://www.fsf.org/licenses/gpl.txt 9 | # Contrib : Tenaku 10 | # TODO : 11 | ############################################################### 12 | # 13 | # help : ./check_snmp_win.pl -h 14 | 15 | use strict; 16 | use Net::SNMP; 17 | use Getopt::Long; 18 | 19 | # Icinga specific 20 | my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); 21 | 22 | # SNMP Datas for processes (MIB II) 23 | my $process_table = '1.3.6.1.2.1.25.4.2.1'; 24 | my $index_table = '1.3.6.1.2.1.25.4.2.1.1'; 25 | my $run_name_table = '1.3.6.1.2.1.25.4.2.1.2'; 26 | my $run_path_table = '1.3.6.1.2.1.25.4.2.1.4'; 27 | my $proc_mem_table = '1.3.6.1.2.1.25.5.1.1.2'; # Kbytes 28 | my $proc_cpu_table = '1.3.6.1.2.1.25.5.1.1.1'; # Centi sec of CPU 29 | my $proc_run_state = '1.3.6.1.2.1.25.4.2.1.7'; 30 | 31 | # Windows SNMP DATA 32 | 33 | my $win_serv_table = '1.3.6.1.4.1.77.1.2.3.1'; # Windows services table 34 | my $win_serv_name = '1.3.6.1.4.1.77.1.2.3.1.1'; # Name of the service 35 | 36 | # Install state : uninstalled(1), install-pending(2), uninstall-pending(3), installed(4) 37 | my $win_serv_inst = '1.3.6.1.4.1.77.1.2.3.1.2'; 38 | 39 | # Operating state : active(1), continue-pending(2), pause-pending(3), paused(4) 40 | my $win_serv_state = '1.3.6.1.4.1.77.1.2.3.1.3'; 41 | my %win_serv_state_label = (1 => 'active', 2 => 'continue-pending', 3 => 'pause-pending', 4 => 'paused'); 42 | 43 | # Can be uninstalled : cannot-be-uninstalled(1), can-be-uninstalled(2) 44 | my $win_serv_uninst = '1.3.6.1.4.1.77.1.2.3.1.4'; 45 | 46 | # Globals 47 | 48 | my $Name = 'check_snmp_win'; 49 | 50 | my $o_host = undef; # hostname 51 | my $o_community = undef; # community 52 | my $o_port = 161; # port 53 | my $o_domain = 'udp/ipv4'; # protocol 54 | my $o_version2 = undef; # use snmp v2c 55 | my $o_descr = undef; # description filter 56 | my @o_descrL = undef; # Service descriprion list. 57 | my $o_showall = undef; # Show all services even if OK 58 | my $o_type = "service"; # Check type (service, ...) 59 | my $o_number = undef; # Number of service for warn and crit levels 60 | my $o_help = undef; # wan't some help ? 61 | my $o_verb = undef; # verbose mode 62 | my $o_version = undef; # print version 63 | my $o_noreg = undef; # Do not use Regexp for name 64 | my $o_timeout = 5; # Default 5s Timeout 65 | my $o_octetlength = undef; # SNMP max message size 66 | 67 | # SNMP V3 specific 68 | my $o_login = undef; # snmp v3 login 69 | my $o_passwd = undef; # snmp v3 passwd 70 | 71 | # functions 72 | 73 | sub p_version { print "$Name version : $VERSION\n"; } 74 | 75 | sub print_usage { 76 | print 77 | "Usage: $Name [-v] -H -C [-2] | (-l login -x passwd) [-p ] -n [,] [-t ] [-o ] [-V]\n"; 78 | } 79 | 80 | sub isnotnum { # Return true if arg is not a number 81 | my $num = shift; 82 | if ($num =~ /^-?(\d+\.?\d*)|(^\.\d+)$/) { return 0; } 83 | return 1; 84 | } 85 | 86 | sub is_pattern_valid { # Test for things like "" or "+5-i" 87 | my $pat = shift; 88 | if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings 89 | return eval { "" =~ /$pat/; 1 } || 0; 90 | } 91 | 92 | # Get the alarm signal (just in case snmp timout screws up) 93 | $SIG{'ALRM'} = sub { 94 | print("ERROR: Alarm signal (Nagios time-out)\n"); 95 | exit $ERRORS{"UNKNOWN"}; 96 | }; 97 | 98 | sub help { 99 | print "\nSNMP Windows Monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; 100 | print "GPL license, (c)2004-2007 Patrick Proy\n\n"; 101 | print_usage(); 102 | print < 134 | Compare matching services with instead of the number of names provided. 135 | -s, --showall 136 | Show all services in the output, instead of only the non-active ones. 137 | -r, --noregexp 138 | Do not use regexp to match NAME in service description. 139 | -t, --timeout=INTEGER 140 | timeout for SNMP in seconds (Default: 5) 141 | -o, --octetlength=INTEGER 142 | SNMP max message size (484-65535) 143 | -V, --version 144 | prints version number 145 | Note : 146 | The script will return 147 | OK if ALL services are in active state, 148 | WARNING if there is more than specified (ex 2 service specified, 3 active services matching), 149 | CRITICAL if at least one of them is non active. 150 | The -n option will allows regexp in perl format 151 | -n "service" will match 'service WINS' 'sevice DNS' etc... 152 | It is not case sensitive by default : WINS = wins 153 | EOT 154 | } 155 | 156 | sub verb { my $t = shift; print $t, "\n" if defined($o_verb); } 157 | 158 | sub decode_utf8 { # just replaces UFT8 caracters by "." 159 | my $utfstr = shift; 160 | if (substr($utfstr, 0, 2) ne "0x") { return $utfstr; } 161 | my @stringL = split(//, $utfstr); 162 | my $newstring = ""; 163 | for (my $i = 2; $i < $#stringL; $i += 2) { 164 | if (($stringL[$i] . $stringL[$i + 1]) eq "c3") { 165 | $i += 2; 166 | $newstring .= "."; 167 | } else { 168 | $newstring .= chr(hex($stringL[$i] . $stringL[$i + 1])); 169 | } 170 | } 171 | return $newstring; 172 | } 173 | 174 | sub check_options { 175 | Getopt::Long::Configure("bundling"); 176 | GetOptions( 177 | 'v' => \$o_verb, 178 | 'verbose' => \$o_verb, 179 | 'h' => \$o_help, 180 | 'help' => \$o_help, 181 | 'H:s' => \$o_host, 182 | 'hostname:s' => \$o_host, 183 | 'p:i' => \$o_port, 184 | 'port:i' => \$o_port, 185 | 'protocol:s' => \$o_domain, 186 | 'C:s' => \$o_community, 187 | 'community:s' => \$o_community, 188 | 'l:s' => \$o_login, 189 | 'login:s' => \$o_login, 190 | 'x:s' => \$o_passwd, 191 | 'passwd:s' => \$o_passwd, 192 | 't:i' => \$o_timeout, 193 | 'timeout:i' => \$o_timeout, 194 | 'n:s' => \$o_descr, 195 | 'name:s' => \$o_descr, 196 | 'r' => \$o_noreg, 197 | 'noregexp' => \$o_noreg, 198 | 'T:s' => \$o_type, 199 | 'type:s' => \$o_type, 200 | 'N:i' => \$o_number, 201 | 'number:i' => \$o_number, 202 | '2' => \$o_version2, 203 | 'v2c' => \$o_version2, 204 | 'o:i' => \$o_octetlength, 205 | 'octetlength:i' => \$o_octetlength, 206 | 's' => \$o_showall, 207 | 'showall' => \$o_showall, 208 | 'V' => \$o_version, 209 | 'version' => \$o_version 210 | ); 211 | if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } 212 | if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } 213 | 214 | # check snmp information 215 | if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) { 216 | print "Put snmp login info!\n"; 217 | print_usage(); 218 | exit $ERRORS{"UNKNOWN"}; 219 | } 220 | 221 | # Check compulsory attributes 222 | if ($o_type ne "service") { 223 | print "Invalid check type !\n"; 224 | print_usage(); 225 | exit $ERRORS{"UNKNOWN"}; 226 | } 227 | if (!defined($o_descr) || !defined($o_host)) { print_usage(); exit $ERRORS{"UNKNOWN"} } 228 | @o_descrL = split(/,/, $o_descr); 229 | foreach my $List (@o_descrL) { 230 | if (!is_pattern_valid($List)) { print "Invalid pattern ! "; print_usage(); exit $ERRORS{"UNKNOWN"} } 231 | } 232 | if (defined($o_number)) { 233 | if (isnotnum($o_number) || ($o_number < 0)) { 234 | print "Invalid number of services!\n"; 235 | print_usage(); 236 | exit $ERRORS{"UNKNOWN"}; 237 | } 238 | } 239 | 240 | # Octet length check 241 | if (defined($o_octetlength) && (isnotnum($o_octetlength) || $o_octetlength > 65535 || $o_octetlength < 484)) { 242 | print "octet length must be in range 484 .. 65535\n"; 243 | print_usage(); 244 | exit $ERRORS{'UNKNOWN'}; 245 | } 246 | 247 | } 248 | 249 | ########## MAIN ####### 250 | 251 | check_options(); 252 | 253 | # Check timeout if snmp screws up 254 | if (defined($o_timeout)) { 255 | verb("Alarm in $o_timeout seconds"); 256 | alarm($o_timeout); 257 | } 258 | 259 | $SIG{'ALRM'} = sub { 260 | print "No answer from host $o_host:$o_port\n"; 261 | exit $ERRORS{"UNKNOWN"}; 262 | }; 263 | 264 | # Connect to host 265 | my ($session, $error); 266 | if (defined($o_login) && defined($o_passwd)) { 267 | 268 | # SNMPv3 login 269 | verb("SNMPv3 login"); 270 | ($session, $error) = Net::SNMP->session( 271 | -hostname => $o_host, 272 | -port => $o_port, 273 | -version => '3', 274 | -username => $o_login, 275 | -authpassword => $o_passwd, 276 | -authprotocol => 'md5', 277 | -privpassword => $o_passwd, 278 | -timeout => $o_timeout, 279 | -domain => $o_domain 280 | ); 281 | } else { 282 | if (defined($o_version2)) { 283 | 284 | # SNMPv2 Login 285 | ($session, $error) = Net::SNMP->session( 286 | -hostname => $o_host, 287 | -version => 2, 288 | -community => $o_community, 289 | -port => $o_port, 290 | -timeout => $o_timeout, 291 | -domain => $o_domain 292 | ); 293 | } else { 294 | 295 | # SNMPV1 login 296 | ($session, $error) = Net::SNMP->session( 297 | -hostname => $o_host, 298 | -community => $o_community, 299 | -port => $o_port, 300 | -timeout => $o_timeout, 301 | -domain => $o_domain 302 | ); 303 | } 304 | } 305 | 306 | if (!defined($session)) { 307 | printf("ERROR: %s.\n", $error); 308 | exit $ERRORS{"UNKNOWN"}; 309 | } 310 | 311 | if (defined($o_octetlength)) { 312 | my $oct_resultat = undef; 313 | my $oct_test = $session->max_msg_size(); 314 | verb(" actual max octets:: $oct_test"); 315 | $oct_resultat = $session->max_msg_size($o_octetlength); 316 | if (!defined($oct_resultat)) { 317 | printf("ERROR: Session settings : %s.\n", $session->error); 318 | $session->close; 319 | exit $ERRORS{"UNKNOWN"}; 320 | } 321 | $oct_test = $session->max_msg_size(); 322 | verb(" new max octets:: $oct_test"); 323 | } 324 | 325 | # Look for process in name or path name table 326 | my $resultat = undef; 327 | 328 | $resultat 329 | = (version->parse(Net::SNMP->VERSION) < 4) 330 | ? $session->get_table($win_serv_name) 331 | : $session->get_table(Baseoid => $win_serv_name); 332 | 333 | if (!defined($resultat)) { 334 | printf("ERROR: Process name table : %s.\n", $session->error); 335 | $session->close; 336 | exit $ERRORS{"UNKNOWN"}; 337 | } 338 | 339 | my @tindex = undef; 340 | my @oids = undef; 341 | my @descr = undef; 342 | my $num_int = 0; 343 | my $count_oid = 0; 344 | 345 | # Select storage by regexp of exact match 346 | # and put the oid to query in an array 347 | 348 | verb("Filter : $o_descr"); 349 | 350 | foreach my $key (keys %$resultat) { 351 | my $descr_d = decode_utf8($$resultat{$key}); 352 | verb("Desc : $descr_d"); 353 | 354 | # test by regexp or exact match 355 | my $test = undef; 356 | foreach my $List (@o_descrL) { 357 | if (!($test)) { 358 | $test 359 | = defined($o_noreg) 360 | ? $descr_d eq $List 361 | : $descr_d =~ /$List/i; 362 | } 363 | } 364 | if ($test) { 365 | 366 | # get the full description 367 | $descr[$num_int] = $descr_d; 368 | 369 | # get the index number of the process 370 | $key =~ s/$win_serv_name\.//; 371 | $tindex[$num_int] = $key; 372 | 373 | # put the oid of running state in an array. 374 | $oids[$count_oid++] = $win_serv_state . "." . $tindex[$num_int]; 375 | verb("Name : $descr[$num_int], Index : $tindex[$num_int]"); 376 | $num_int++; 377 | } 378 | } 379 | 380 | if ($num_int == 0) { 381 | if (defined($o_number) && ($o_number == 0)) { 382 | print "No services ", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : OK\n"; 383 | exit $ERRORS{"OK"}; 384 | } else { 385 | print "No services ", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\" found : CRITICAL\n"; 386 | exit $ERRORS{"CRITICAL"}; 387 | } 388 | } 389 | 390 | my $result = undef; 391 | my $num_int_ok = 0; 392 | 393 | $result 394 | = (version->parse(Net::SNMP->VERSION) < 4) 395 | ? $session->get_request(@oids) 396 | : $session->get_request(Varbindlist => \@oids); 397 | 398 | if (!defined($result)) { 399 | printf("ERROR: running table : %s.\n", $session->error); 400 | $session->close; 401 | exit $ERRORS{"UNKNOWN"}; 402 | } 403 | 404 | $session->close; 405 | 406 | my $output = undef; 407 | 408 | #Check if service are in active state 409 | for (my $i = 0; $i < $num_int; $i++) { 410 | my $state = $$result{ $win_serv_state . "." . $tindex[$i] }; 411 | verb("Process $tindex[$i] in state $state"); 412 | if ($state == 1) { 413 | $num_int_ok++; 414 | } else { 415 | $output .= ", " if defined($output); 416 | $output .= $descr[$i] . " : " . $win_serv_state_label{$state}; 417 | } 418 | } 419 | 420 | my $force_critical = 0; 421 | 422 | # Show the services that are not present 423 | # Or all of them with -s option 424 | foreach my $List (@o_descrL) { 425 | my $test = 0; 426 | for (my $i = 0; $i < $num_int; $i++) { 427 | if (defined($o_noreg)) { 428 | if ($descr[$i] eq $List) { $test++; } 429 | } else { 430 | if ($descr[$i] =~ /$List/i) { $test++; } 431 | } 432 | } 433 | if ($test == 0) { 434 | $output .= ", " if defined($output); 435 | $output .= "\"" . $List . "\" not active"; 436 | 437 | # Force a critical state (could otherwise lead to false OK) 438 | $force_critical = 1; 439 | } elsif (defined($o_showall)) { 440 | $output .= ", " if defined($output); 441 | $output .= "\"" . $List . "\" active"; 442 | if ($test != 1) { 443 | $output .= "(" . $test . " services)"; 444 | } 445 | } 446 | } 447 | 448 | if (defined($output)) { 449 | print $output, " : "; 450 | } else { 451 | print $num_int_ok, " services active (", (defined($o_noreg)) ? "named \"" : "matching \"", $o_descr, "\") : "; 452 | } 453 | 454 | $o_number = $#o_descrL + 1 if (!defined($o_number)); 455 | 456 | if (($num_int_ok < $o_number) || ($force_critical == 1)) { 457 | print "CRITICAL\n"; 458 | exit $ERRORS{"CRITICAL"}; 459 | } elsif ($num_int_ok > $o_number) { 460 | print "WARNING\n"; 461 | exit $ERRORS{"WARNING"}; 462 | } 463 | print "OK\n"; 464 | exit $ERRORS{"OK"}; 465 | 466 | -------------------------------------------------------------------------------- /plugins/check_snmp_nsbox.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | ############################## check_snmp_nsbox ################# 3 | # Version : 1.0 4 | # Date : Jan 16 2007 5 | # Author : Patrick Proy ( patrick at proy.org) 6 | # Help : http://www.manubulon.com/nagios/ 7 | # License : GPL - http://www.fsf.org/licenses/gpl.txt 8 | # Changelog : 9 | # Contributors : 10 | ################################################################# 11 | # 12 | # Help : ./check_snmp_nsbox.pl -h 13 | # 14 | 15 | use strict; 16 | use Net::SNMP; 17 | use Getopt::Long; 18 | 19 | # Icinga specific 20 | my $TIMEOUT = 15; 21 | my %ERRORS = ('OK' => 0, 'WARNING' => 1, 'CRITICAL' => 2, 'UNKNOWN' => 3, 'DEPENDENT' => 4); 22 | 23 | # SNMP Datas 24 | my $ns_service_status = "1.3.6.1.4.1.14020.2.2.1.3.0"; # service status 1= ok ?? 25 | 26 | my $ns_service_table = "1.3.6.1.4.1.14020.2.3"; # vhost & diode table 27 | my $ns_vhost_table = "1.3.6.1.4.1.14020.2.3.1"; # vhost table 28 | my $ns_vhost_name = "1.0"; # GUI Vhost Name 29 | my $ns_vhost_requests = "2.0"; # Instant Vhost Requests per Second : NOT POPULATED IN V 2.0.8 30 | my $ns_vhost_Trequests = "2.0"; # Total Vhost Requests : NOT POPULATED IN V 2.0.8 31 | my $ns_diode_table = "1.3.6.1.4.1.14020.2.3.2"; # diode table 32 | my $ns_diode_name = "1.0"; # GUI Diode Name 33 | my $ns_diode_status = "2.0"; # Last diode Status (" " = OK?) (undocumented) 34 | 35 | my $ns_rsa_prct_usage = ".1.3.6.1.4.1.14020.1.1.1.3.0"; # % usage of RSA operations. (undocumented) 36 | my $ns_rsa_oper_second = ".1.3.6.1.4.1.14020.1.1.3.4.0;"; # number of RSA operations/s (undocumented) 37 | 38 | # Globals 39 | 40 | my $VERSION = "2.1.0"; 41 | 42 | my $o_host = undef; # hostname 43 | my $o_community = undef; # community 44 | my $o_port = 161; # port 45 | my $o_domain = 'udp/ipv4'; # protocol 46 | my $o_help = undef; # wan't some help ? 47 | my $o_verb = undef; # verbose mode 48 | my $o_version = undef; # print version 49 | my $o_timeout = undef; # Timeout (Default 5) 50 | my $o_perf = undef; # Output performance data 51 | my $o_version2 = undef; # use snmp v2c 52 | 53 | # specific 54 | my $o_vhost = undef; # vhost regexp 55 | my $o_diode = undef; # diode regexp 56 | my $o_nvhost = undef; # vhost number 57 | my $o_ndiode = undef; # diode number 58 | 59 | # SNMPv3 specific 60 | my $o_login = undef; # Login for snmpv3 61 | my $o_passwd = undef; # Pass for snmpv3 62 | my $v3protocols = undef; # V3 protocol list. 63 | my $o_authproto = 'md5'; # Auth protocol 64 | my $o_privproto = 'des'; # Priv protocol 65 | my $o_privpass = undef; # priv password 66 | 67 | # functions 68 | 69 | sub p_version { print "check_snmp_nsbox version : $VERSION\n"; } 70 | 71 | sub print_usage { 72 | print 73 | "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd [-X pass -L ,]) -d -s -n , [-p ] [-f] [-t ] [-V]\n"; 74 | } 75 | 76 | sub isnnum { # Return true if arg is not a number 77 | my $num = shift; 78 | if ($num =~ /^(\d+\.?\d*)|(^\.\d+)$/) { return 0; } 79 | return 1; 80 | } 81 | 82 | sub set_status { # return worst status with this order : OK, unknwonw, warning, critical 83 | my $new_status = shift; 84 | my $cur_status = shift; 85 | if (($cur_status == 0) || ($new_status == $cur_status)) { return $new_status; } 86 | if ($new_status == 3) { return $cur_status; } 87 | if ($new_status > $cur_status) { return $new_status; } 88 | return $cur_status; 89 | } 90 | 91 | sub is_pattern_valid { # Test for things like "" or "+5-i" 92 | my $pat = shift; 93 | if (!defined($pat)) { $pat = " "; } # Just to get rid of compilation time warnings 94 | return eval { "" =~ /$pat/; 1 } || 0; 95 | } 96 | 97 | sub help { 98 | print "\nSNMP NetSecureOne Netbox monitor for Icinga/Nagios/Naemon/Shinken, Version ", $VERSION, "\n"; 99 | print "(c)2004-2006 Patrick Proy\n\n"; 100 | print_usage(); 101 | print <, 119 | : Authentication protocol (md5|sha : default md5) 120 | : Priv protocole (des|aes : default des) 121 | -d, --diode= 122 | Diode selection by regexp 123 | -s, --vhost= 124 | Vhost selection by regexp 125 | -n, --number=, 126 | number of diode and vhost that must be up. 127 | -P, --port=PORT 128 | SNMP port (Default 161) 129 | --protocol=PROTOCOL 130 | Network protocol to be used 131 | ['udp/ipv4'] : UDP over IPv4 132 | 'udp/ipv6' : UDP over IPv6 133 | 'tcp/ipv4' : TCP over IPv4 134 | 'tcp/ipv6' : TCP over IPv6 135 | 136 | Network protocol (Default udp/ipv4) 137 | -f, --perfparse, --perfdata 138 | Performance data output 139 | -t, --timeout=INTEGER 140 | timeout for SNMP in seconds (Default: 5) 141 | -V, --version 142 | prints version number 143 | EOT 144 | } 145 | 146 | # For verbose output 147 | sub verb { my $t = shift; print $t, "\n" if defined($o_verb); } 148 | 149 | sub check_options { 150 | Getopt::Long::Configure("bundling"); 151 | GetOptions( 152 | 'v' => \$o_verb, 153 | 'verbose' => \$o_verb, 154 | 'h' => \$o_help, 155 | 'help' => \$o_help, 156 | 'H:s' => \$o_host, 157 | 'hostname:s' => \$o_host, 158 | 'p:i' => \$o_port, 159 | 'port:i' => \$o_port, 160 | 'protocol:s' => \$o_domain, 161 | 'C:s' => \$o_community, 162 | 'community:s' => \$o_community, 163 | 'l:s' => \$o_login, 164 | 'login:s' => \$o_login, 165 | 'x:s' => \$o_passwd, 166 | 'passwd:s' => \$o_passwd, 167 | 'X:s' => \$o_privpass, 168 | 'privpass:s' => \$o_privpass, 169 | 'L:s' => \$v3protocols, 170 | 'protocols:s' => \$v3protocols, 171 | 't:i' => \$o_timeout, 172 | 'timeout:i' => \$o_timeout, 173 | 'V' => \$o_version, 174 | 'version' => \$o_version, 175 | '2' => \$o_version2, 176 | 'v2c' => \$o_version2, 177 | 'f' => \$o_perf, 178 | 'perfparse' => \$o_perf, 179 | 'perfdata' => \$o_perf, 180 | 'd:s' => \$o_diode, 181 | 'diode:s' => \$o_diode, 182 | 's:s' => \$o_vhost, 183 | 'vhost:s' => \$o_vhost, 184 | 'n:s' => \$o_nvhost, 185 | 'number:s' => \$o_nvhost 186 | ); 187 | 188 | # Basic checks 189 | if (defined($o_timeout) && (isnnum($o_timeout) || ($o_timeout < 2) || ($o_timeout > 60))) { 190 | print "Timeout must be >1 and <60 !\n"; 191 | print_usage(); 192 | exit $ERRORS{"UNKNOWN"}; 193 | } 194 | if (!defined($o_timeout)) { $o_timeout = 5; } 195 | if (defined($o_help)) { help(); exit $ERRORS{"UNKNOWN"} } 196 | if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"} } 197 | if (!defined($o_host)) # check host and filter 198 | { 199 | print_usage(); 200 | exit $ERRORS{"UNKNOWN"}; 201 | } 202 | 203 | # check snmp information 204 | if (!defined($o_community) && (!defined($o_login) || !defined($o_passwd))) { 205 | print "Put snmp login info!\n"; 206 | print_usage(); 207 | exit $ERRORS{"UNKNOWN"}; 208 | } 209 | if ((defined($o_login) || defined($o_passwd)) && (defined($o_community) || defined($o_version2))) { 210 | print "Can't mix snmp v1,2c,3 protocols!\n"; 211 | print_usage(); 212 | exit $ERRORS{"UNKNOWN"}; 213 | } 214 | if (defined($v3protocols)) { 215 | if (!defined($o_login)) { 216 | print "Put snmp V3 login info with protocols!\n"; 217 | print_usage(); 218 | exit $ERRORS{"UNKNOWN"}; 219 | } 220 | my @v3proto = split(/,/, $v3protocols); 221 | if ((defined($v3proto[0])) && ($v3proto[0] ne "")) { $o_authproto = $v3proto[0]; } # Auth protocol 222 | if (defined($v3proto[1])) { $o_privproto = $v3proto[1]; } # Priv protocol 223 | if ((defined($v3proto[1])) && (!defined($o_privpass))) { 224 | print "Put snmp V3 priv login info with priv protocols!\n"; 225 | print_usage(); 226 | exit $ERRORS{"UNKNOWN"}; 227 | } 228 | } 229 | if (!defined($o_vhost) || !(is_pattern_valid($o_vhost))) { 230 | print "Vhost selection must be set and be a valid regexp (-s)\n"; 231 | print_usage(); 232 | exit $ERRORS{"UNKNOWN"}; 233 | } 234 | if (!defined($o_diode) || !(is_pattern_valid($o_diode))) { 235 | print "Diode selection must be set and be a valid regexp (-d)\n"; 236 | print_usage(); 237 | exit $ERRORS{"UNKNOWN"}; 238 | } 239 | if (!defined($o_nvhost)) { 240 | print "Diode and vhost number must be set (-n)\n"; 241 | print_usage(); 242 | exit $ERRORS{"UNKNOWN"}; 243 | } 244 | my @nsbox_number = split(/,/, $o_nvhost); 245 | if ($#nsbox_number != 1) { print "2 numbers must be set with -n option\n"; print_usage(); exit $ERRORS{"UNKNOWN"} } 246 | if (isnnum($nsbox_number[0]) || isnnum($nsbox_number[1])) { 247 | print "2 numbers must be set with -n option\n"; 248 | print_usage(); 249 | exit $ERRORS{"UNKNOWN"}; 250 | } 251 | $o_ndiode = $nsbox_number[0]; 252 | $o_nvhost = $nsbox_number[1]; 253 | } 254 | 255 | ########## MAIN ####### 256 | 257 | check_options(); 258 | 259 | # Check gobal timeout if snmp screws up 260 | if (defined($TIMEOUT)) { 261 | verb("Alarm at $TIMEOUT + 5"); 262 | alarm($TIMEOUT + 5); 263 | } else { 264 | verb("no global timeout defined : $o_timeout + 10"); 265 | alarm($o_timeout + 10); 266 | } 267 | 268 | # Connect to host 269 | my ($session, $error); 270 | if (defined($o_login) && defined($o_passwd)) { 271 | 272 | # SNMPv3 login 273 | verb("SNMPv3 login"); 274 | if (!defined($o_privpass)) { 275 | verb("SNMPv3 AuthNoPriv login : $o_login, $o_authproto"); 276 | ($session, $error) = Net::SNMP->session( 277 | -hostname => $o_host, 278 | -port => $o_port, 279 | -version => '3', 280 | -username => $o_login, 281 | -authpassword => $o_passwd, 282 | -authprotocol => $o_authproto, 283 | -timeout => $o_timeout, 284 | -domain => $o_domain 285 | ); 286 | } else { 287 | verb("SNMPv3 AuthPriv login : $o_login, $o_authproto, $o_privproto"); 288 | ($session, $error) = Net::SNMP->session( 289 | -hostname => $o_host, 290 | -port => $o_port, 291 | -version => '3', 292 | -username => $o_login, 293 | -authpassword => $o_passwd, 294 | -authprotocol => $o_authproto, 295 | -privpassword => $o_privpass, 296 | -privprotocol => $o_privproto, 297 | -timeout => $o_timeout, 298 | -domain => $o_domain 299 | ); 300 | } 301 | } else { 302 | if (defined($o_version2)) { 303 | 304 | # SNMPv2 Login 305 | verb("SNMP v2c login"); 306 | ($session, $error) = Net::SNMP->session( 307 | -hostname => $o_host, 308 | -version => 2, 309 | -community => $o_community, 310 | -port => $o_port, 311 | -timeout => $o_timeout, 312 | -domain => $o_domain 313 | ); 314 | } else { 315 | 316 | # SNMPV1 login 317 | verb("SNMP v1 login"); 318 | ($session, $error) = Net::SNMP->session( 319 | -hostname => $o_host, 320 | -community => $o_community, 321 | -port => $o_port, 322 | -timeout => $o_timeout, 323 | -domain => $o_domain 324 | ); 325 | } 326 | } 327 | if (!defined($session)) { 328 | printf("ERROR opening session: %s.\n", $error); 329 | exit $ERRORS{"UNKNOWN"}; 330 | } 331 | 332 | ########### check global status ############## 333 | my @oidlist = ($ns_service_status); 334 | my $resultat 335 | = (version->parse(Net::SNMP->VERSION) < 4) 336 | ? $session->get_request(@oidlist) 337 | : $session->get_request(-varbindlist => \@oidlist); 338 | 339 | if (!defined($resultat) || ($$resultat{$ns_service_status} eq "noSuchObject")) { 340 | printf("ERROR: Global status oid not found : %s.\n", $session->error); 341 | $session->close; 342 | exit $ERRORS{"UNKNOWN"}; 343 | } 344 | 345 | if ($$resultat{$ns_service_status} != 1) { 346 | print "Global service is in state ", $$resultat{$ns_service_status}, " : CRITICAL\n"; 347 | exit $ERRORS{"CRITICAL"}; 348 | } 349 | 350 | ########### check vhost & diode status ############## 351 | $resultat = undef; 352 | $resultat 353 | = (version->parse(Net::SNMP->VERSION) < 4) 354 | ? $session->get_table($ns_service_table) 355 | : $session->get_table(Baseoid => $ns_service_table); 356 | 357 | if (!defined($resultat)) { 358 | printf("ERROR: vhost and diode status table : %s.\n", $session->error); 359 | $session->close; 360 | exit $ERRORS{"UNKNOWN"}; 361 | } 362 | $session->close; 363 | 364 | my $output = ""; 365 | my $output_perf = ""; 366 | my ($index, $name) = undef; 367 | my ($nvhost, $ndiode) = (0, 0); 368 | my (@found_vhost, @found_diode) = (undef, undef); 369 | 370 | foreach my $key (keys %$resultat) { 371 | verb("OID : $key, Desc : $$resultat{$key}"); 372 | if ($key =~ /($ns_vhost_table)\.(\d+)\.($ns_vhost_name)/) { # Get index of vhost with name 373 | $index = $2; 374 | $name = $$resultat{$key}; 375 | if ($name =~ /$o_vhost/) { 376 | $found_vhost[$nvhost++] = $name; 377 | verb("found vhost $name"); 378 | } 379 | } 380 | if ($key =~ /($ns_diode_table)\.(\d+)\.($ns_diode_name)/) { # Get index of diode with name 381 | $index = $2; 382 | $name = $$resultat{$key}; 383 | if ($name =~ /$o_diode/) { 384 | 385 | # TODO Check diode status : undocumented for now. 386 | $found_diode[$ndiode++] = $name; 387 | verb("found diode $name"); 388 | } 389 | } 390 | } 391 | 392 | if (($ndiode < $o_ndiode) || ($nvhost < $o_nvhost)) { 393 | $output = "Diode"; 394 | if ($ndiode == 0) { $output .= ": none "; } 395 | else { 396 | $output .= "(" . $ndiode . "): :"; 397 | for (my $i = 0; $i < $ndiode; $i++) { 398 | $output .= $found_diode[$i] . " "; 399 | } 400 | } 401 | $output .= "Vhost"; 402 | if ($nvhost == 0) { $output .= ": none "; } 403 | else { 404 | $output .= "(" . $nvhost . "): :"; 405 | for (my $i = 0; $i < $nvhost; $i++) { 406 | $output .= $found_vhost[$i] . " "; 407 | } 408 | } 409 | $output .= " < " . $o_ndiode . "," . $o_nvhost . " : CRITICAL"; 410 | print $output, "\n"; 411 | exit $ERRORS{"CRITICAL"}; 412 | } 413 | 414 | $output = $ndiode . " diodes, " . $nvhost . " vhosts :"; 415 | if (($ndiode > $o_ndiode) || ($nvhost > $o_nvhost)) { 416 | $output .= " > " . $o_ndiode . "," . $o_nvhost . " : WARNING"; 417 | } else { 418 | $output .= " OK"; 419 | } 420 | print $output, "\n"; 421 | exit $ERRORS{"OK"}; 422 | 423 | --------------------------------------------------------------------------------