From bfa204a580a503a216cedbedd36586fb00458181 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 18 Nov 2011 10:10:13 +0100 Subject: //Monitoring: add shinken configs --- Monitoring/plugins/check.bat | 0 Monitoring/plugins/check.sh | 5 + Monitoring/plugins/check_apt | Bin 0 -> 106120 bytes Monitoring/plugins/check_bgpstate | 215 +++++++++ Monitoring/plugins/check_breeze | 87 ++++ Monitoring/plugins/check_by_ssh | Bin 0 -> 46192 bytes Monitoring/plugins/check_clamd | 1 + Monitoring/plugins/check_cluster | Bin 0 -> 32072 bytes Monitoring/plugins/check_cpu | 165 +++++++ Monitoring/plugins/check_dhcp | Bin 0 -> 44816 bytes Monitoring/plugins/check_dig | Bin 0 -> 41392 bytes Monitoring/plugins/check_disk | Bin 0 -> 119216 bytes Monitoring/plugins/check_disk_smb | 307 +++++++++++++ Monitoring/plugins/check_dns | Bin 0 -> 45488 bytes Monitoring/plugins/check_dummy | Bin 0 -> 28968 bytes Monitoring/plugins/check_dummy.sh | 5 + Monitoring/plugins/check_file_age | 112 +++++ Monitoring/plugins/check_flexlm | 244 +++++++++++ Monitoring/plugins/check_fping | Bin 0 -> 44656 bytes Monitoring/plugins/check_ftp | 1 + Monitoring/plugins/check_game | Bin 0 -> 36584 bytes Monitoring/plugins/check_host | 1 + Monitoring/plugins/check_hpjd | Bin 0 -> 41136 bytes Monitoring/plugins/check_http | Bin 0 -> 164624 bytes Monitoring/plugins/check_icmp | Bin 0 -> 49264 bytes Monitoring/plugins/check_ide_smart | Bin 0 -> 34536 bytes Monitoring/plugins/check_ifoperstatus | 472 ++++++++++++++++++++ Monitoring/plugins/check_ifstatus | 425 ++++++++++++++++++ Monitoring/plugins/check_imap | 1 + Monitoring/plugins/check_ircd | 239 ++++++++++ Monitoring/plugins/check_jabber | 1 + Monitoring/plugins/check_ldap | Bin 0 -> 40816 bytes Monitoring/plugins/check_ldaps | 1 + Monitoring/plugins/check_linux_raid | 115 +++++ Monitoring/plugins/check_load | Bin 0 -> 36168 bytes Monitoring/plugins/check_log | 219 ++++++++++ Monitoring/plugins/check_mailq | 608 ++++++++++++++++++++++++++ Monitoring/plugins/check_mem.pl | 263 +++++++++++ Monitoring/plugins/check_mrtg | Bin 0 -> 36264 bytes Monitoring/plugins/check_mrtgtraf | Bin 0 -> 34440 bytes Monitoring/plugins/check_mysql | Bin 0 -> 45936 bytes Monitoring/plugins/check_mysql_query | Bin 0 -> 44688 bytes Monitoring/plugins/check_nagios | Bin 0 -> 36616 bytes Monitoring/plugins/check_nntp | 1 + Monitoring/plugins/check_nntps | 1 + Monitoring/plugins/check_nt | Bin 0 -> 48720 bytes Monitoring/plugins/check_ntp | Bin 0 -> 46288 bytes Monitoring/plugins/check_ntp_peer | Bin 0 -> 44880 bytes Monitoring/plugins/check_ntp_time | Bin 0 -> 42224 bytes Monitoring/plugins/check_nwstat | Bin 0 -> 60912 bytes Monitoring/plugins/check_oracle | 287 ++++++++++++ Monitoring/plugins/check_overcr | Bin 0 -> 40400 bytes Monitoring/plugins/check_pgsql | Bin 0 -> 40656 bytes Monitoring/plugins/check_ping | Bin 0 -> 48848 bytes Monitoring/plugins/check_pop | 1 + Monitoring/plugins/check_procs | Bin 0 -> 114640 bytes Monitoring/plugins/check_radius | Bin 0 -> 40624 bytes Monitoring/plugins/check_real | Bin 0 -> 40464 bytes Monitoring/plugins/check_rpc | 375 ++++++++++++++++ Monitoring/plugins/check_rta_multi | 1 + Monitoring/plugins/check_sensors | 65 +++ Monitoring/plugins/check_shinken.py | 157 +++++++ Monitoring/plugins/check_simap | 1 + Monitoring/plugins/check_smtp | Bin 0 -> 127216 bytes Monitoring/plugins/check_snmp | Bin 0 -> 152008 bytes Monitoring/plugins/check_spop | 1 + Monitoring/plugins/check_ssh | Bin 0 -> 36688 bytes Monitoring/plugins/check_ssmtp | 1 + Monitoring/plugins/check_swap | Bin 0 -> 37832 bytes Monitoring/plugins/check_tcp | Bin 0 -> 49328 bytes Monitoring/plugins/check_time | Bin 0 -> 38128 bytes Monitoring/plugins/check_udp | 1 + Monitoring/plugins/check_ups | Bin 0 -> 44560 bytes Monitoring/plugins/check_users | Bin 0 -> 36168 bytes Monitoring/plugins/check_wave | 122 ++++++ Monitoring/plugins/getwmic.sh | 7 + Monitoring/plugins/link_vmware_host_vm.py | 184 ++++++++ Monitoring/plugins/negate | Bin 0 -> 38152 bytes Monitoring/plugins/nmap_discovery_runner.py | 419 ++++++++++++++++++ Monitoring/plugins/notify.sh | 6 + Monitoring/plugins/nsca_client.py | 184 ++++++++ Monitoring/plugins/sendmailhost.pl | 96 ++++ Monitoring/plugins/sendmailservices.pl | 105 +++++ Monitoring/plugins/urlize | Bin 0 -> 36104 bytes Monitoring/plugins/utils.pm | 67 +++ Monitoring/plugins/utils.sh | 23 + Monitoring/plugins/vmware_discovery_runner.py | 225 ++++++++++ 87 files changed, 5817 insertions(+) create mode 100755 Monitoring/plugins/check.bat create mode 100755 Monitoring/plugins/check.sh create mode 100755 Monitoring/plugins/check_apt create mode 100755 Monitoring/plugins/check_bgpstate create mode 100755 Monitoring/plugins/check_breeze create mode 100755 Monitoring/plugins/check_by_ssh create mode 120000 Monitoring/plugins/check_clamd create mode 100755 Monitoring/plugins/check_cluster create mode 100755 Monitoring/plugins/check_cpu create mode 100755 Monitoring/plugins/check_dhcp create mode 100755 Monitoring/plugins/check_dig create mode 100755 Monitoring/plugins/check_disk create mode 100755 Monitoring/plugins/check_disk_smb create mode 100755 Monitoring/plugins/check_dns create mode 100755 Monitoring/plugins/check_dummy create mode 100755 Monitoring/plugins/check_dummy.sh create mode 100755 Monitoring/plugins/check_file_age create mode 100755 Monitoring/plugins/check_flexlm create mode 100755 Monitoring/plugins/check_fping create mode 120000 Monitoring/plugins/check_ftp create mode 100755 Monitoring/plugins/check_game create mode 120000 Monitoring/plugins/check_host create mode 100755 Monitoring/plugins/check_hpjd create mode 100755 Monitoring/plugins/check_http create mode 100755 Monitoring/plugins/check_icmp create mode 100755 Monitoring/plugins/check_ide_smart create mode 100755 Monitoring/plugins/check_ifoperstatus create mode 100755 Monitoring/plugins/check_ifstatus create mode 120000 Monitoring/plugins/check_imap create mode 100755 Monitoring/plugins/check_ircd create mode 120000 Monitoring/plugins/check_jabber create mode 100755 Monitoring/plugins/check_ldap create mode 120000 Monitoring/plugins/check_ldaps create mode 100755 Monitoring/plugins/check_linux_raid create mode 100755 Monitoring/plugins/check_load create mode 100755 Monitoring/plugins/check_log create mode 100755 Monitoring/plugins/check_mailq create mode 100755 Monitoring/plugins/check_mem.pl create mode 100755 Monitoring/plugins/check_mrtg create mode 100755 Monitoring/plugins/check_mrtgtraf create mode 100755 Monitoring/plugins/check_mysql create mode 100755 Monitoring/plugins/check_mysql_query create mode 100755 Monitoring/plugins/check_nagios create mode 120000 Monitoring/plugins/check_nntp create mode 120000 Monitoring/plugins/check_nntps create mode 100755 Monitoring/plugins/check_nt create mode 100755 Monitoring/plugins/check_ntp create mode 100755 Monitoring/plugins/check_ntp_peer create mode 100755 Monitoring/plugins/check_ntp_time create mode 100755 Monitoring/plugins/check_nwstat create mode 100755 Monitoring/plugins/check_oracle create mode 100755 Monitoring/plugins/check_overcr create mode 100755 Monitoring/plugins/check_pgsql create mode 100755 Monitoring/plugins/check_ping create mode 120000 Monitoring/plugins/check_pop create mode 100755 Monitoring/plugins/check_procs create mode 100755 Monitoring/plugins/check_radius create mode 100755 Monitoring/plugins/check_real create mode 100755 Monitoring/plugins/check_rpc create mode 120000 Monitoring/plugins/check_rta_multi create mode 100755 Monitoring/plugins/check_sensors create mode 100755 Monitoring/plugins/check_shinken.py create mode 120000 Monitoring/plugins/check_simap create mode 100755 Monitoring/plugins/check_smtp create mode 100755 Monitoring/plugins/check_snmp create mode 120000 Monitoring/plugins/check_spop create mode 100755 Monitoring/plugins/check_ssh create mode 120000 Monitoring/plugins/check_ssmtp create mode 100755 Monitoring/plugins/check_swap create mode 100755 Monitoring/plugins/check_tcp create mode 100755 Monitoring/plugins/check_time create mode 120000 Monitoring/plugins/check_udp create mode 100755 Monitoring/plugins/check_ups create mode 100755 Monitoring/plugins/check_users create mode 100755 Monitoring/plugins/check_wave create mode 100755 Monitoring/plugins/getwmic.sh create mode 100755 Monitoring/plugins/link_vmware_host_vm.py create mode 100755 Monitoring/plugins/negate create mode 100755 Monitoring/plugins/nmap_discovery_runner.py create mode 100755 Monitoring/plugins/notify.sh create mode 100755 Monitoring/plugins/nsca_client.py create mode 100755 Monitoring/plugins/sendmailhost.pl create mode 100755 Monitoring/plugins/sendmailservices.pl create mode 100755 Monitoring/plugins/urlize create mode 100644 Monitoring/plugins/utils.pm create mode 100755 Monitoring/plugins/utils.sh create mode 100755 Monitoring/plugins/vmware_discovery_runner.py (limited to 'Monitoring/plugins') diff --git a/Monitoring/plugins/check.bat b/Monitoring/plugins/check.bat new file mode 100755 index 00000000..e69de29b diff --git a/Monitoring/plugins/check.sh b/Monitoring/plugins/check.sh new file mode 100755 index 00000000..9e62fbee --- /dev/null +++ b/Monitoring/plugins/check.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "When in doubt... blow it up. | cpu=100%" +#sleep 1.5 +exit 0 diff --git a/Monitoring/plugins/check_apt b/Monitoring/plugins/check_apt new file mode 100755 index 00000000..2371c32d Binary files /dev/null and b/Monitoring/plugins/check_apt differ diff --git a/Monitoring/plugins/check_bgpstate b/Monitoring/plugins/check_bgpstate new file mode 100755 index 00000000..645d7505 --- /dev/null +++ b/Monitoring/plugins/check_bgpstate @@ -0,0 +1,215 @@ +#!/usr/bin/perl -w +# +# check_bgpstate.pl - nagios plugin +# +# Copyright (C) 2000 Christoph Kron +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# Report bugs to: ck@zet.net +# +# 11.01.2000 Version 1.0 + + + +use strict; + +use Net::SNMP; +use Getopt::Long; +&Getopt::Long::config('auto_abbrev'); + + +# whois programm for RIPE database queries +my $whois = '/usr/bin/whois'; +my $status; +my $TIMEOUT = 30; + +# critical bgp sessions +my %uplinks = ( 1273, 'Uplink ECRC', + 1755, 'Uplink EBONE', + 3300, 'Uplink AUCS' + ); + +my %ERRORS = ('UNKNOWN' , '-1', + 'OK' , '0', + 'WARNING', '1', + 'CRITICAL', '2'); + + +my %bgpPeerState = ( + '1',"idle", + '2',"connect", + '3',"active", + '4',"opensent", + '5',"openconfirm", + '6',"established" + ); +my $state = "UNKNOWN"; +my $answer = ""; +my $snmpkey; +my $snmpoid; +my $key; +my $community = "public"; +my $port = 161; +my @snmpoids; +my $snmpbgpPeerState = '1.3.6.1.2.1.15.3.1.2'; +my $snmpbgpPeerLocalAddr = '1.3.6.1.2.1.15.3.1.5'; +my $snmpbgpPeerRemoteAddr = '1.3.6.1.2.1.15.3.1.7'; +my $snmpbgpPeerRemoteAs = '1.3.6.1.2.1.15.3.1.9'; +my $hostname; +my $session; +my $error; +my $response; +my %bgpStatus; +my $bgpestablished =0 ; +my $bgpcritical =0; +my $bgpdown =0; +my $bgpidle =0; +my $bgpmessage; +my $asname; +my $remoteas; +my @output; + +sub usage { + printf "\nMissing arguments!\n"; + printf "\n"; + printf "Perl bgpstate plugin for Nagios\n"; + printf "monitors all BGP sessions\n"; + printf "usage: \n"; + printf "check_bgpstate.pl -c -p \n"; + printf "Copyright (C) 2000 Christoph Kron\n"; + printf "check_bgpstate.pl comes with ABSOLUTELY NO WARRANTY\n"; + printf "This programm is licensed under the terms of the "; + printf "GNU General Public License\n(check source code for details)\n"; + printf "\n\n"; + exit $ERRORS{"UNKNOWN"}; +} + +# Just in case of problems, let's not hang Nagios +$SIG{'ALRM'} = sub { + print ("ERROR: No snmp response from $hostname (alarm)\n"); + exit $ERRORS{"UNKNOWN"}; +}; +alarm($TIMEOUT); + + +$status = GetOptions("community=s",\$community, + "port=i",\$port); +if ($status == 0) +{ + &usage; +} + + #shift; + $hostname = shift || &usage; + + +push(@snmpoids, $snmpbgpPeerState); +push(@snmpoids, $snmpbgpPeerLocalAddr); +push(@snmpoids, $snmpbgpPeerRemoteAddr); +push(@snmpoids, $snmpbgpPeerRemoteAs); + +foreach $snmpoid (@snmpoids) { + + ($session, $error) = Net::SNMP->session( + -hostname => $hostname, + -community => $community, + -port => $port + ); + + if (!defined($session)) { + $state='UNKNOWN'; + $answer=$error; + print ("$state: $answer"); + exit $ERRORS{$state}; + } + + if (!defined($response = $session->get_table($snmpoid))) { + $answer=$session->error; + $session->close; + $state = 'CRITICAL'; + print ("$state: $answer,$snmpkey"); + exit $ERRORS{$state}; + } + + foreach $snmpkey (keys %{$response}) { + $snmpkey =~ m/.*\.(\d+\.\d+\.\d+\.\d+$)/; + $key = $1; +# printf "debug: $snmpkey: $key -> $response->{$snmpkey}\n"; + $bgpStatus{$key}{$snmpoid} = $response->{$snmpkey}; + } + $session->close; +} + +foreach $key (keys %bgpStatus) { + if ($bgpStatus{$key}{$snmpbgpPeerState} == 6 ) { + $bgpestablished++; + } + elsif ($bgpStatus{$key}{$snmpbgpPeerState} == 1 ) { + $bgpidle++; + } + else { + $bgpdown++ ; + if (exists($uplinks{$bgpStatus{$key}{$snmpbgpPeerRemoteAs}}) ) { + $bgpcritical++; + } + @output = `$whois -T aut-num AS$bgpStatus{$key}{$snmpbgpPeerRemoteAs}`; + + $asname = ""; + foreach (@output) { + if (m/as-name/) { + $asname = $_; + $asname =~ s/as-name://; + last; + } + if ( $asname =~ "" && m/descr/ ) { + $asname = $_; + $asname =~ s/descr://; + } + } + $asname =~ s/^\s*//; + $asname =~ s/\s*$//; + $bgpmessage .= sprintf("Peering with AS%s not established -> %s
", + $bgpStatus{$key}{$snmpbgpPeerRemoteAs}, + $asname); + } +} + + + if ($bgpdown > 0) { + if ($bgpcritical > 0) { + $state = 'CRITICAL'; + } + else { + $state = 'WARNING'; + } + $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d
", + $hostname, + $bgpestablished, + $bgpdown, $bgpidle); + $answer = $answer . $bgpmessage . "\n"; + } + else { + $state = 'OK'; + $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d\n", + $hostname, + $bgpestablished, + $bgpdown,$bgpidle); + } + +print ("$state: $answer"); +exit $ERRORS{$state}; + diff --git a/Monitoring/plugins/check_breeze b/Monitoring/plugins/check_breeze new file mode 100755 index 00000000..d0382e69 --- /dev/null +++ b/Monitoring/plugins/check_breeze @@ -0,0 +1,87 @@ +#! /usr/bin/perl -wT + + +use strict; +use Getopt::Long; +use vars qw($opt_V $opt_h $opt_w $opt_c $opt_H $opt_C $PROGNAME); +use lib "/usr/lib/nagios/plugins" ; +use utils qw(%ERRORS &print_revision &support &usage); + +$PROGNAME = "check_breeze"; + +sub print_help (); +sub print_usage (); + +$ENV{'PATH'}=''; +$ENV{'BASH_ENV'}=''; +$ENV{'ENV'}=''; + +Getopt::Long::Configure('bundling'); +GetOptions + ("V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "w=s" => \$opt_w, "warning=s" => \$opt_w, + "c=s" => \$opt_c, "critical=s" => \$opt_c, + "H=s" => \$opt_H, "hostname=s" => \$opt_H, + "C=s" => \$opt_C, "community=s" => \$opt_C); + +if ($opt_V) { + print_revision($PROGNAME,'1.4.15'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) {print_help(); exit $ERRORS{'OK'};} + +($opt_H) || usage("Host name/address not specified\n"); +my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); +($host) || usage("Invalid host: $opt_H\n"); + +($opt_w) || usage("Warning threshold not specified\n"); +my $warning = $1 if ($opt_w =~ /([0-9]{1,2}|100)+/); +($warning) || usage("Invalid warning threshold: $opt_w\n"); + +($opt_c) || usage("Critical threshold not specified\n"); +my $critical = $1 if ($opt_c =~ /([0-9]{1,2}|100)/); +($critical) || usage("Invalid critical threshold: $opt_c\n"); + +($opt_C) || ($opt_C = "public") ; + +my $sig=0; +$sig = `snmpget $host $opt_C .1.3.6.1.4.1.710.3.2.3.1.3.0`; +my @test=split(/ /,$sig); +$sig=$test[2]; +$sig=int($sig); +if ($sig>100){$sig=100} + +print "Signal Strength at: $sig%\n"; + +exit $ERRORS{'CRITICAL'} if ($sig<$critical); +exit $ERRORS{'WARNING'} if ($sig<$warning); +exit $ERRORS{'OK'}; + + +sub print_usage () { + print "Usage: $PROGNAME -H [-C community] -w -c \n"; +} + +sub print_help () { + print_revision($PROGNAME,'1.4.15'); + print "Copyright (c) 2000 Jeffrey Blank/Karl DeBisschop + +This plugin reports the signal strength of a Breezecom wireless equipment + +"; + print_usage(); + print " +-H, --hostname=HOST + Name or IP address of host to check +-C, --community=community + SNMPv1 community (default public) +-w, --warning=INTEGER + Percentage strength below which a WARNING status will result +-c, --critical=INTEGER + Percentage strength below which a CRITICAL status will result + +"; + support(); +} diff --git a/Monitoring/plugins/check_by_ssh b/Monitoring/plugins/check_by_ssh new file mode 100755 index 00000000..5f969058 Binary files /dev/null and b/Monitoring/plugins/check_by_ssh differ diff --git a/Monitoring/plugins/check_clamd b/Monitoring/plugins/check_clamd new file mode 120000 index 00000000..e838da97 --- /dev/null +++ b/Monitoring/plugins/check_clamd @@ -0,0 +1 @@ +check_tcp \ No newline at end of file diff --git a/Monitoring/plugins/check_cluster b/Monitoring/plugins/check_cluster new file mode 100755 index 00000000..8d6dbb90 Binary files /dev/null and b/Monitoring/plugins/check_cluster differ diff --git a/Monitoring/plugins/check_cpu b/Monitoring/plugins/check_cpu new file mode 100755 index 00000000..26a93da5 --- /dev/null +++ b/Monitoring/plugins/check_cpu @@ -0,0 +1,165 @@ +#!/usr/bin/python + +import string, os, sys, re +#from optik import OptionParser +from optparse import OptionParser + + + +####################################### +### Define a set of strings to handle +### any info output requirements. + + +check_cpu_version = "check_cpu (nagios-plugins 1.5.1!?) 0.4.0a\n" + +intro = "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\ncopies of the plugins under the terms of the GNU General Public License.\nFor more information about these matters, see the file named COPYING.\nCopyright (c) 2004 Ethan Galstad/Karl DeBisschop\n\n" + +preamble = "This plugin will check the percent of idle CPU usage on the system it is\nexecuted on and generate an alert if the percentage is below\none of the threshold values.\n\n" + +use = "Usage:\tcheck_cpu -w limit -c limit [-t timeout]\n\tcheck_cpu (-h|--help)\n\tcheck_cpu (-V|--version)\n" + +options = "\n -w, --warning=PERCENT\n\tExit with WARNING status if idle CPU percentage is less than PERCENT\n -c, --critical=PERCENT\n\tExit with CRITICAL status if idle CPU percentage is less than PERCENT\n -t, --timeout=INTEGER\n\tSeconds before check attempt times out (default: 10)\n -s, --sample=INTEGER\n\tSeconds to use as sample time. (default: 5)\n -h, --help\n\tPrint detailed help screen\n -V, --version\n\tPrint version information\n\n" + +bugs = "Bugs:\tTimeout does not do what has been documented here. Rather, it does \nnothing. The plugin seems to ignore characters that are not attached to \nparameter syntax. This has been tested on RedHat 8.0+, Fedora Core 1 & 2, \nOpenBSD 3.x and Debian. I would appreciate feedback and/or patches if it doesn't\nfunction under your chosen operating system.\n\n" + +query = "Send email to nagios-users@lists.sourceforge.net if you have questions\nregarding the use of this software. To submit patches or suggest improvements,\nsend email to nagiosplug-devel@lists.sourceforge.net.\n\nFor questions and suggestions pertaining to the check_cpu plugin,\nplease send email to nemir@hotmail.com.\n" + +fullHelp = check_cpu_version + intro + preamble + use + options + bugs + query + + + + + +def helpFunc(option, opt, value, parser): + print fullHelp + sys.exit(3) + +def verFunc(option, opt, value, parser): + print check_cpu_version + sys.exit(3) + + + + +####################################### +### Parse all the parameters. Define +### variables for later use. + + + +parser = OptionParser(add_help_option=0) + +parser.add_option("-h", "--help", action="callback", callback=helpFunc) +parser.add_option("-V", "--version", action="callback", callback=verFunc) +parser.add_option("-w", "--warning", action="store", type="int", dest="warn", default=-1) +parser.add_option("-c", "--critical", action="store", type="int", dest="crit", default=-2) +parser.add_option("-s", "--sample", action="store", type="int", dest="sample", default=5) +parser.add_option("-t", "--timeout", action="store", type="int", dest="timeout", default=10) + +(options, args) = parser.parse_args() + +critical = options.crit +warning = options.warn +sample = options.sample +timeout = options.timeout + + +if -3 > critical or 101 < critical: + print "Critical value is a percentage and must be between 0 and 100.\n" + use + sys.exit(3) + +if -2 > warning or 101 < warning: + print "Warning value is a percentage and must be between 0 and 100.\n" + use + sys.exit(3) + +if critical >= warning: + print "Critical value must be less than the warning value.\n" + use + sys.exit(3) + +if sample >= timeout -1: + print "Sample time must be 2 seconds less than timeout.\n" + use + sys.exit(3) + +strSample = str(sample) + + +####################################### +### Determine what OS we are being run +### on, to figure syntax required. + + +v = os.popen("uname", "r") +l = v.read() + +if l == "Linux\n": + vmcmd = "/usr/bin/vmstat " + strSample + " 2" +elif l == "OpenBSD\n": + vmcmd = "/usr/bin/vmstat -c 2 -w " + strSample +elif l == "FreeBSD\n": + vmcmd = "/usr/bin/vmstat -c 2 -w " + strSample +elif l == "NetBSD\n": + vmcmd = "/usr/bin/vmstat -c 2 -w " + strSample +elif l == "SunOS\n": + vmcmd = "/usr/bin/vmstat " + strSample + " 2" +else: + print "Unknown operating system, unable to continue.\n" + sys.exit(3) + + +####################################### +### Grab the CPU sample and convert the +### the relevent info to an int. + + +vmstat = os.popen( vmcmd, "r" ) +statOut = vmstat.read() + + +statLines = string.split( statOut, '\n') +lastLine = statLines[-2].strip() + +n = len(statLines) +for i in range(0, n): + idcheck = re.search("id", statLines[i]) + if idcheck: + idLine = statLines[i].strip() + + + +idStr = re.sub( "[ \t\n\r\v]+", " ", idLine ) +idList = string.split(idStr, " ") +idColumn = idList.index("id") + +valueStr = re.sub( "[ \t\n\r\v]+", " ", lastLine ) +values = string.split( valueStr, ' ') + +idleCPU = values[idColumn] +sysCPU = values[-2] +userCPU = values[-3] + +idleValue = string.atoi(idleCPU) + + +####################################### +### Finally, determine and report CPU +### state, and exit the plugin. + + +if idleValue <= critical: + status = "CPU CRITICAL" + print status + ": CPU is only " + idleCPU + "% idle" + sys.exit(2) +elif idleValue <= warning: + status = "WARNING" + print status + ": CPU is only " + idleCPU + "% idle" + sys.exit(1) +elif warning < idleValue: + status = "OK" + print status + ": CPU is " + idleCPU + "% idle" + sys.exit(0) +else: + status = "CPU STATUS UNKNOWN" + print status + ": Could not complete check." + sys.exit(3) + diff --git a/Monitoring/plugins/check_dhcp b/Monitoring/plugins/check_dhcp new file mode 100755 index 00000000..6b51224f Binary files /dev/null and b/Monitoring/plugins/check_dhcp differ diff --git a/Monitoring/plugins/check_dig b/Monitoring/plugins/check_dig new file mode 100755 index 00000000..650608dc Binary files /dev/null and b/Monitoring/plugins/check_dig differ diff --git a/Monitoring/plugins/check_disk b/Monitoring/plugins/check_disk new file mode 100755 index 00000000..43dc43a3 Binary files /dev/null and b/Monitoring/plugins/check_disk differ diff --git a/Monitoring/plugins/check_disk_smb b/Monitoring/plugins/check_disk_smb new file mode 100755 index 00000000..80fa6779 --- /dev/null +++ b/Monitoring/plugins/check_disk_smb @@ -0,0 +1,307 @@ +#! /usr/bin/perl -w +# +# +# check_disk.pl [warn] [critical] [port] +# +# Nagios host script to get the disk usage from a SMB share +# +# Changes and Modifications +# ========================= +# 7-Aug-1999 - Michael Anthon +# Created from check_disk.pl script provided with netsaint_statd (basically +# cause I was too lazy (or is that smart?) to write it from scratch) +# 8-Aug-1999 - Michael Anthon +# Modified [warn] and [critical] parameters to accept format of nnn[M|G] to +# allow setting of limits in MBytes or GBytes. Percentage settings for large +# drives is a pain in the butt +# 2-May-2002 - SGhosh fix for embedded perl +# +# + +require 5.004; +use POSIX; +use strict; +use Getopt::Long; +use vars qw($opt_P $opt_V $opt_h $opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $opt_a $verbose); +use vars qw($PROGNAME); +use lib "/usr/lib/nagios/plugins" ; +use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); + +sub print_help (); +sub print_usage (); + +$PROGNAME = "check_disk_smb"; + +$ENV{'PATH'}=''; +$ENV{'BASH_ENV'}=''; +$ENV{'ENV'}=''; + +Getopt::Long::Configure('bundling'); +GetOptions + ("v" => \$verbose, "verbose" => \$verbose, + "P=s" => \$opt_P, "port=s" => \$opt_P, + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "w=s" => \$opt_w, "warning=s" => \$opt_w, + "c=s" => \$opt_c, "critical=s" => \$opt_c, + "p=s" => \$opt_p, "password=s" => \$opt_p, + "u=s" => \$opt_u, "username=s" => \$opt_u, + "s=s" => \$opt_s, "share=s" => \$opt_s, + "W=s" => \$opt_W, "workgroup=s" => \$opt_W, + "H=s" => \$opt_H, "hostname=s" => \$opt_H, + "a=s" => \$opt_a, "address=s" => \$opt_a); + +if ($opt_V) { + print_revision($PROGNAME,'1.4.15'); #' + exit $ERRORS{'OK'}; +} + +if ($opt_h) {print_help(); exit $ERRORS{'OK'};} + +my $smbclient = $utils::PATH_TO_SMBCLIENT; + +# Options checking + +($opt_H) || ($opt_H = shift @ARGV) || usage("Host name not specified\n"); +my $host = $1 if ($opt_H =~ /^([-_.A-Za-z0-9 ]+\$?)$/); +($host) || usage("Invalid host: $opt_H\n"); + +($opt_s) || ($opt_s = shift @ARGV) || usage("Share volume not specified\n"); +my $share = $1 if ($opt_s =~ /^([-_.A-Za-z0-9 ]+\$?)$/); +($share) || usage("Invalid share: $opt_s\n"); + +defined($opt_u) || ($opt_u = shift @ARGV) || ($opt_u = "guest"); +my $user = $1 if ($opt_u =~ /^([-_.A-Za-z0-9\\]*)$/); +defined($user) || usage("Invalid user: $opt_u\n"); + +defined($opt_p) || ($opt_p = shift @ARGV) || ($opt_p = ""); +my $pass = $1 if ($opt_p =~ /(.*)/); + +($opt_w) || ($opt_w = shift @ARGV) || ($opt_w = 85); +my $warn = $1 if ($opt_w =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); +($warn) || usage("Invalid warning threshold: $opt_w\n"); + +($opt_c) || ($opt_c = shift @ARGV) || ($opt_c = 95); +my $crit = $1 if ($opt_c =~ /^([0-9]{1,2}\%?|100\%?|[0-9]+[kMG])$/); +($crit) || usage("Invalid critical threshold: $opt_c\n"); + +# Execute the given command line and return anything it writes to STDOUT and/or +# STDERR. (This might be useful for other plugins, too, so it should possibly +# be moved to utils.pm.) +sub output_and_error_of { + local *CMD; + local $/ = undef; + my $pid = open CMD, "-|"; + if (defined($pid)) { + if ($pid) { + return ; + } else { + open STDERR, ">&STDOUT" and exec @_; + exit(1); + } + } + return undef; +} + +# split the type from the unit value +#Check $warn and $crit for type (%/M/G) and set up for tests +#P = Percent, K = KBytes +my $warn_type; +my $crit_type; + +if ($opt_w =~ /^([0-9]+)\%?$/) { + $warn = "$1"; + $warn_type = "P"; +} elsif ($opt_w =~ /^([0-9]+)k$/) { + $warn_type = "K"; + $warn = $1; +} elsif ($opt_w =~ /^([0-9]+)M$/) { + $warn_type = "K"; + $warn = $1 * 1024; +} elsif ($opt_w =~ /^([0-9]+)G$/) { + $warn_type = "K"; + $warn = $1 * 1048576; +} +if ($opt_c =~ /^([0-9]+)\%?$/) { + $crit = "$1"; + $crit_type = "P"; +} elsif ($opt_c =~ /^([0-9]+)k$/) { + $crit_type = "K"; + $crit = $1; +} elsif ($opt_c =~ /^([0-9]+)M$/) { + $crit_type = "K"; + $crit = $1 * 1024; +} elsif ($opt_c =~ /^([0-9]+)G$/) { + $crit_type = "K"; + $crit = $1 * 1048576; +} + +# check if both warning and critical are percentage or size +unless( ( $warn_type eq "P" && $crit_type eq "P" ) || ( $warn_type ne "P" && $crit_type ne "P" ) ){ + $opt_w =~ s/\%/\%\%/g; + $opt_c =~ s/\%/\%\%/g; + usage("Both warning and critical should be same type- warning: $opt_w critical: $opt_c \n"); +} + +# verify warning is less than critical +if ( $warn_type eq "K") { + unless ( $warn > $crit) { + usage("Disk size: warning ($opt_w) should be greater than critical ($opt_c) \n"); + } +}else{ + unless ( $warn < $crit) { + $opt_w =~ s/\%/\%\%/g; + $opt_c =~ s/\%/\%\%/g; + usage("Percentage: warning ($opt_w) should be less than critical ($opt_c) \n"); + } +} + +my $workgroup = $1 if (defined($opt_W) && $opt_W =~ /(.*)/); + +my $address = $1 if (defined($opt_a) && $opt_a =~ /(.*)/); + +# end of options checking + + +my $state = "OK"; +my $answer = undef; +my $res = undef; +my @lines = undef; + +# Just in case of problems, let's not hang Nagios +$SIG{'ALRM'} = sub { + print "No Answer from Client\n"; + exit $ERRORS{"UNKNOWN"}; +}; +alarm($TIMEOUT); + +# Execute an "ls" on the share using smbclient program +# get the results into $res +my @cmd = ( + $smbclient, + "//$host/$share", + "-U", "$user%$pass", + defined($workgroup) ? ("-W", $workgroup) : (), + defined($address) ? ("-I", $address) : (), + defined($opt_P) ? ("-p", $opt_P) : (), + "-c", "ls" +); + +print join(" ", @cmd) . "\n" if ($verbose); +$res = output_and_error_of(@cmd) or exit $ERRORS{"UNKNOWN"}; + +#Turn off alarm +alarm(0); + +#Split $res into an array of lines +@lines = split /\n/, $res; + +#Get the last line into $_ +$_ = $lines[$#lines]; +#print "$_\n"; + +#Process the last line to get free space. +#If line does not match required regexp, return an UNKNOWN error +if (/\s*(\d*) blocks of size (\d*)\. (\d*) blocks available/) { + + my ($avail) = ($3*$2)/1024; + my ($avail_bytes) = $avail; + my ($capper) = int(($3/$1)*100); + my ($mountpt) = "\\\\$host\\$share"; + + + if (int($avail / 1024) > 0) { + $avail = int($avail / 1024); + if (int($avail /1024) > 0) { + $avail = (int(($avail / 1024)*100))/100; + $avail = $avail ."G"; + } else { + $avail = $avail ."M"; + } + } else { + $avail = $avail ."K"; + } + +#print ":$warn:$warn_type:\n"; +#print ":$crit:$crit_type:\n"; +#print ":$avail:$avail_bytes:$capper:$mountpt:\n"; + + if ((($warn_type eq "P") && (100 - $capper) < $warn) || (($warn_type eq "K") && ($avail_bytes > $warn))) { + $answer = "Disk ok - $avail ($capper%) free on $mountpt\n"; + } elsif ((($crit_type eq "P") && (100 - $capper) < $crit) || (($crit_type eq "K") && ($avail_bytes > $crit))) { + $state = "WARNING"; + $answer = "WARNING: Only $avail ($capper%) free on $mountpt\n"; + } else { + $state = "CRITICAL"; + $answer = "CRITICAL: Only $avail ($capper%) free on $mountpt\n"; + } +} else { + $answer = "Result from smbclient not suitable\n"; + $state = "UNKNOWN"; + foreach (@lines) { + if (/(Access denied|NT_STATUS_LOGON_FAILURE|NT_STATUS_ACCESS_DENIED)/) { + $answer = "Access Denied\n"; + $state = "CRITICAL"; + last; + } + if (/(Unknown host \w*|Connection.*failed)/) { + $answer = "$1\n"; + $state = "CRITICAL"; + last; + } + if (/(You specified an invalid share name|NT_STATUS_BAD_NETWORK_NAME)/) { + $answer = "Invalid share name \\\\$host\\$share\n"; + $state = "CRITICAL"; + last; + } + } +} + + +print $answer; +print "$state\n" if ($verbose); +exit $ERRORS{$state}; + +sub print_usage () { + print "Usage: $PROGNAME -H -s -u -p + -w -c [-W ] [-P ] [-a ]\n"; +} + +sub print_help () { + print_revision($PROGNAME,'1.4.15'); + print "Copyright (c) 2000 Michael Anthon/Karl DeBisschop + +Perl Check SMB Disk plugin for Nagios + +"; + print_usage(); + print " +-H, --hostname=HOST + NetBIOS name of the server +-s, --share=STRING + Share name to be tested +-W, --workgroup=STRING + Workgroup or Domain used (Defaults to \"WORKGROUP\") +-a, --address=IP + IP-address of HOST (only necessary if HOST is in another network) +-u, --user=STRING + Username to log in to server. (Defaults to \"guest\") +-p, --password=STRING + Password to log in to server. (Defaults to an empty password) +-w, --warning=INTEGER or INTEGER[kMG] + Percent of used space at which a warning will be generated (Default: 85%) + +-c, --critical=INTEGER or INTEGER[kMG] + Percent of used space at which a critical will be generated (Defaults: 95%) +-P, --port=INTEGER + Port to be used to connect to. Some Windows boxes use 139, others 445 (Defaults to smbclient default) + + If thresholds are followed by either a k, M, or G then check to see if that + much disk space is available (kilobytes, Megabytes, Gigabytes) + + Warning percentage should be less than critical + Warning (remaining) disk space should be greater than critical. + +"; + support(); +} diff --git a/Monitoring/plugins/check_dns b/Monitoring/plugins/check_dns new file mode 100755 index 00000000..8a80b991 Binary files /dev/null and b/Monitoring/plugins/check_dns differ diff --git a/Monitoring/plugins/check_dummy b/Monitoring/plugins/check_dummy new file mode 100755 index 00000000..b66006ac Binary files /dev/null and b/Monitoring/plugins/check_dummy differ diff --git a/Monitoring/plugins/check_dummy.sh b/Monitoring/plugins/check_dummy.sh new file mode 100755 index 00000000..fe834bd0 --- /dev/null +++ b/Monitoring/plugins/check_dummy.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "Return in Dummy" $1 + +exit $1 \ No newline at end of file diff --git a/Monitoring/plugins/check_file_age b/Monitoring/plugins/check_file_age new file mode 100755 index 00000000..7f20bad7 --- /dev/null +++ b/Monitoring/plugins/check_file_age @@ -0,0 +1,112 @@ +#! /usr/bin/perl -w + +# check_file_age.pl Copyright (C) 2003 Steven Grimm +# +# Checks a file's size and modification time to make sure it's not empty +# and that it's sufficiently recent. +# +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty +# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# you should have received a copy of the GNU General Public License +# along with this program (or with Nagios); if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA + +use strict; +use English; +use Getopt::Long; +use File::stat; +use vars qw($PROGNAME); +use lib "/usr/lib/nagios/plugins"; +use utils qw (%ERRORS &print_revision &support); + +sub print_help (); +sub print_usage (); + +my ($opt_c, $opt_f, $opt_w, $opt_C, $opt_W, $opt_h, $opt_V); +my ($result, $message, $age, $size, $st); + +$PROGNAME="check_file_age"; + +$opt_w = 240; +$opt_c = 600; +$opt_W = 0; +$opt_C = 0; +$opt_f = ""; + +Getopt::Long::Configure('bundling'); +GetOptions( + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "f=s" => \$opt_f, "file" => \$opt_f, + "w=f" => \$opt_w, "warning-age=f" => \$opt_w, + "W=f" => \$opt_W, "warning-size=f" => \$opt_W, + "c=f" => \$opt_c, "critical-age=f" => \$opt_c, + "C=f" => \$opt_C, "critical-size=f" => \$opt_C); + +if ($opt_V) { + print_revision($PROGNAME, '1.4.15'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_f = shift unless ($opt_f); + +if (! $opt_f) { + print "FILE_AGE UNKNOWN: No file specified\n"; + exit $ERRORS{'UNKNOWN'}; +} + +# Check that file exists (can be directory or link) +unless (-e $opt_f) { + print "FILE_AGE CRITICAL: File not found - $opt_f\n"; + exit $ERRORS{'CRITICAL'}; +} + +$st = File::stat::stat($opt_f); +$age = time - $st->mtime; +$size = $st->size; + + +$result = 'OK'; + +if (($opt_c and $age > $opt_c) or ($opt_C and $size < $opt_C)) { + $result = 'CRITICAL'; +} +elsif (($opt_w and $age > $opt_w) or ($opt_W and $size < $opt_W)) { + $result = 'WARNING'; +} + +print "FILE_AGE $result: $opt_f is $age seconds old and $size bytes\n"; +exit $ERRORS{$result}; + +sub print_usage () { + print "Usage:\n"; + print " $PROGNAME [-w ] [-c ] [-W ] [-C ] -f \n"; + print " $PROGNAME [-h | --help]\n"; + print " $PROGNAME [-V | --version]\n"; +} + +sub print_help () { + print_revision($PROGNAME, '1.4.15'); + print "Copyright (c) 2003 Steven Grimm\n\n"; + print_usage(); + print "\n"; + print " File must be no more than this many seconds old (default: warn 240 secs, crit 600)\n"; + print " File must be at least this many bytes long (default: crit 0 bytes)\n"; + print "\n"; + support(); +} diff --git a/Monitoring/plugins/check_flexlm b/Monitoring/plugins/check_flexlm new file mode 100755 index 00000000..532785ef --- /dev/null +++ b/Monitoring/plugins/check_flexlm @@ -0,0 +1,244 @@ +#! /usr/bin/perl -w +# +# usage: +# check_flexlm.pl license_file +# +# Check available flexlm license managers. +# Use lmstat to check the status of the license server +# described by the license file given as argument. +# Check and interpret the output of lmstat +# and create returncodes and output. +# +# Contrary to the nagios concept, this script takes +# a file, not a hostname as an argument and returns +# the status of hosts and services described in that +# file. Use these hosts.cfg entries as an example +# +#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1; +#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic +#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic +#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$ +# +# Notes: +# - you need the lmstat utility which comes with flexlm. +# - set the correct path in the variable $lmstat. +# +# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com +# +# License: GPL +# +# lmstat output patches from Steve Rigler/Cliff Rice 13-Apr-2002 +# srigler@marathonoil.com,cerice@marathonoil.com + + + +use strict; +use Getopt::Long; +use vars qw($opt_V $opt_h $opt_F $opt_t $verbose $PROGNAME); +use lib "/usr/lib/nagios/plugins"; +use utils qw(%ERRORS &print_revision &support &usage); + +$PROGNAME="check_flexlm"; + +sub print_help (); +sub print_usage (); + +$ENV{'PATH'}=''; +$ENV{'BASH_ENV'}=''; +$ENV{'ENV'}=''; + +Getopt::Long::Configure('bundling'); +GetOptions + ("V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "v" => \$verbose, "verbose" => \$verbose, + "F=s" => \$opt_F, "filename=s" => \$opt_F, + "t=i" => \$opt_t, "timeout=i" => \$opt_t); + +if ($opt_V) { + print_revision($PROGNAME,'1.4.15'); + exit $ERRORS{'OK'}; +} + +unless (defined $opt_t) { + $opt_t = $utils::TIMEOUT ; # default timeout +} + + +if ($opt_h) {print_help(); exit $ERRORS{'OK'};} + +unless (defined $opt_F) { + print "Missing license.dat file\n"; + print_usage(); + exit $ERRORS{'UNKNOWN'}; +} +# Just in case of problems, let's not hang Nagios +$SIG{'ALRM'} = sub { + print "Timeout: No Answer from Client\n"; + exit $ERRORS{'UNKNOWN'}; +}; +alarm($opt_t); + +my $lmstat = $utils::PATH_TO_LMSTAT ; +unless (-x $lmstat ) { + print "Cannot find \"lmstat\"\n"; + exit $ERRORS{'UNKNOWN'}; +} + +($opt_F) || ($opt_F = shift) || usage("License file not specified\n"); +my $licfile = $1 if ($opt_F =~ /^(.*)$/); +($licfile) || usage("Invalid filename: $opt_F\n"); + +print "$licfile\n" if $verbose; + +if ( ! open(CMD,"$lmstat -c $licfile |") ) { + print "ERROR: Could not open \"$lmstat -c $licfile\" ($!)\n"; + exit exit $ERRORS{'UNKNOWN'}; +} + +my $serverup = 0; +my @upsrv; +my @downsrv; # list of servers up and down + +#my ($ls1,$ls2,$ls3,$lf1,$lf2,$lf3,$servers); + +# key off of the term "license server" and +# grab the status. Keep going until "Vendor" is found +# + +# +# Collect list of license servers by their status +# Vendor daemon status is ignored for the moment. + +while ( ) { + next if (/^lmstat/); # ignore 1st line - copyright + next if (/^Flexible/); # ignore 2nd line - timestamp + (/^Vendor/) && last; # ignore Vendor daemon status + print $_ if $verbose; + + if ($_ =~ /license server /) { # matched 1 (of possibly 3) license server + s/^\s*//; #some servers start at col 1, other have whitespace + # strip staring whitespace if any + if ( $_ =~ /UP/) { + $_ =~ /^(.*):/ ; + push(@upsrv, $1); + print "up:$1:\n" if $verbose; + } else { + $_ =~ /^(.*):/; + push(@downsrv, $1); + print "down:$1:\n" if $verbose; + } + + } + + +# if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) { +# $ls1 = $1; +# $ls2 = $2; +# $ls3 = $3; +# $lf1 = $lf2 = $lf3 = 0; +# $servers = 3; +# } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) { +# $ls1 = $1; +# $ls2 = $ls3 = ""; +# $lf1 = $lf2 = $lf3 = 0; +# $servers = 1; +# } elsif ( / *$ls1: license server UP/ ) { +# print "$ls1 UP, "; +# $lf1 = 1 +# } elsif ( / *$ls2: license server UP/ ) { +# print "$ls2 UP, "; +# $lf2 = 1 +# } elsif ( / *$ls3: license server UP/ ) { +# print "$ls3 UP, "; +# $lf3 = 1 +# } elsif ( / *([^:]*: UP .*)/ ) { +# print " license server for $1\n"; +# $serverup = 1; +# } + +} + +#if ( $serverup == 0 ) { +# print " license server not running\n"; +# exit 2; +#} + +close CMD; + +if ($verbose) { + print "License Servers running: ".scalar(@upsrv) ."\n"; + foreach my $upserver (@upsrv) { + print "$upserver\n"; + } + print "License servers not running: ".scalar(@downsrv)."\n"; + foreach my $downserver (@downsrv) { + print "$downserver\n"; + } +} + +# +# print list of servers which are up. +# +if (scalar(@upsrv) > 0) { + print "License Servers running:"; + foreach my $upserver (@upsrv) { + print "$upserver,"; + } +} +# +# Ditto for those which are down. +# +if (scalar(@downsrv) > 0) { + print "License servers NOT running:"; + foreach my $downserver (@downsrv) { + print "$downserver,"; + } +} + +# perfdata +print "\n|flexlm::up:".scalar(@upsrv).";down:".scalar(@downsrv)."\n"; + +exit $ERRORS{'OK'} if ( scalar(@downsrv) == 0 ); +exit $ERRORS{'WARNING'} if ( (scalar(@upsrv) > 0) && (scalar(@downsrv) > 0)); + +#exit $ERRORS{'OK'} if ( $servers == $lf1 + $lf2 + $lf3 ); +#exit $ERRORS{'WARNING'} if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 ); +exit $ERRORS{'CRITICAL'}; + + +sub print_usage () { + print "Usage: + $PROGNAME -F [-v] [-t] [-V] [-h] + $PROGNAME --help + $PROGNAME --version +"; +} + +sub print_help () { + print_revision($PROGNAME,'1.4.15'); + print "Copyright (c) 2000 Ernst-Dieter Martin/Karl DeBisschop + +Check available flexlm license managers + +"; + print_usage(); + print " +-F, --filename=FILE + Name of license file (usually \"license.dat\") +-v, --verbose + Print some extra debugging information (not advised for normal operation) +-t, --timeout + Plugin time out in seconds (default = $utils::TIMEOUT ) +-V, --version + Show version and license information +-h, --help + Show this help screen + +Flexlm license managers usually run as a single server or three servers and a +quorum is needed. The plugin return OK if 1 (single) or 3 (triple) servers +are running, CRITICAL if 1(single) or 3 (triple) servers are down, and WARNING +if 1 or 2 of 3 servers are running\n +"; + support(); +} diff --git a/Monitoring/plugins/check_fping b/Monitoring/plugins/check_fping new file mode 100755 index 00000000..3d2b16f9 Binary files /dev/null and b/Monitoring/plugins/check_fping differ diff --git a/Monitoring/plugins/check_ftp b/Monitoring/plugins/check_ftp new file mode 120000 index 00000000..e838da97 --- /dev/null +++ b/Monitoring/plugins/check_ftp @@ -0,0 +1 @@ +check_tcp \ No newline at end of file diff --git a/Monitoring/plugins/check_game b/Monitoring/plugins/check_game new file mode 100755 index 00000000..68c4bda4 Binary files /dev/null and b/Monitoring/plugins/check_game differ diff --git a/Monitoring/plugins/check_host b/Monitoring/plugins/check_host new file mode 120000 index 00000000..97878096 --- /dev/null +++ b/Monitoring/plugins/check_host @@ -0,0 +1 @@ +check_icmp \ No newline at end of file diff --git a/Monitoring/plugins/check_hpjd b/Monitoring/plugins/check_hpjd new file mode 100755 index 00000000..75af60de Binary files /dev/null and b/Monitoring/plugins/check_hpjd differ diff --git a/Monitoring/plugins/check_http b/Monitoring/plugins/check_http new file mode 100755 index 00000000..2143dc6e Binary files /dev/null and b/Monitoring/plugins/check_http differ diff --git a/Monitoring/plugins/check_icmp b/Monitoring/plugins/check_icmp new file mode 100755 index 00000000..3e43c4d6 Binary files /dev/null and b/Monitoring/plugins/check_icmp differ diff --git a/Monitoring/plugins/check_ide_smart b/Monitoring/plugins/check_ide_smart new file mode 100755 index 00000000..e52727f4 Binary files /dev/null and b/Monitoring/plugins/check_ide_smart differ diff --git a/Monitoring/plugins/check_ifoperstatus b/Monitoring/plugins/check_ifoperstatus new file mode 100755 index 00000000..23b25d5d --- /dev/null +++ b/Monitoring/plugins/check_ifoperstatus @@ -0,0 +1,472 @@ +#! /usr/bin/perl -w +# +# check_ifoperstatus.pl - nagios plugin +# +# Copyright (C) 2000 Christoph Kron, +# Modified 5/2002 to conform to updated Nagios Plugin Guidelines +# Added support for named interfaces per Valdimir Ivaschenko (S. Ghosh) +# Added SNMPv3 support (10/2003) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# Report bugs to: nagiosplug-help@lists.sourceforge.net +# +# 11.01.2000 Version 1.0 +# +# Patches from Guy Van Den Bergh to warn on ifadminstatus down interfaces +# instead of critical. +# +# Primary MIB reference - RFC 2863 + + +use POSIX; +use strict; +use lib "/usr/lib/nagios/plugins" ; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +use Net::SNMP; +use Getopt::Long; +&Getopt::Long::config('bundling'); + +my $PROGNAME = "check_ifoperstatus"; +sub print_help (); +sub usage ($); +sub print_usage (); +sub process_arguments (); + +my $timeout; +my $status; +my %ifOperStatus = ('1','up', + '2','down', + '3','testing', + '4','unknown', + '5','dormant', + '6','notPresent', + '7','lowerLayerDown'); # down due to the state of lower layer interface(s) + +my $state = "UNKNOWN"; +my $answer = ""; +my $snmpkey = 0; +my $community = "public"; +my $maxmsgsize = 1472 ; # Net::SNMP default is 1472 +my ($seclevel, $authproto, $secname, $authpass, $privpass, $privproto, $auth, $priv, $context); +my $port = 161; +my @snmpoids; +my $sysUptime = '1.3.6.1.2.1.1.3.0'; +my $snmpIfDescr = '1.3.6.1.2.1.2.2.1.2'; +my $snmpIfType = '1.3.6.1.2.1.2.2.1.3'; +my $snmpIfAdminStatus = '1.3.6.1.2.1.2.2.1.7'; +my $snmpIfOperStatus = '1.3.6.1.2.1.2.2.1.8'; +my $snmpIfName = '1.3.6.1.2.1.31.1.1.1.1'; +my $snmpIfLastChange = '1.3.6.1.2.1.2.2.1.9'; +my $snmpIfAlias = '1.3.6.1.2.1.31.1.1.1.18'; +my $snmpLocIfDescr = '1.3.6.1.4.1.9.2.2.1.1.28'; +my $hostname; +my $ifName; +my $session; +my $error; +my $response; +my $snmp_version = 1 ; +my $ifXTable; +my $opt_h ; +my $opt_V ; +my $ifdescr; +my $iftype; +my $key; +my $lastc; +my $dormantWarn; +my $adminWarn; +my $name; +my %session_opts; + +### Validate Arguments + +$status = process_arguments(); + + +# Just in case of problems, let's not hang Nagios +$SIG{'ALRM'} = sub { + print ("ERROR: No snmp response from $hostname (alarm)\n"); + exit $ERRORS{"UNKNOWN"}; +}; + +alarm($timeout); + +($session, $error) = Net::SNMP->session(%session_opts); + + +if (!defined($session)) { + $state='UNKNOWN'; + $answer=$error; + print ("$state: $answer\n"); + exit $ERRORS{$state}; +} + +## map ifdescr to ifindex - should look at being able to cache this value + +if (defined $ifdescr || defined $iftype) { + # escape "/" in ifdescr - very common in the Cisco world + if (defined $iftype) { + $status=fetch_ifindex($snmpIfType, $iftype); + } else { + $ifdescr =~ s/\//\\\//g; + $status=fetch_ifindex($snmpIfDescr, $ifdescr); # if using on device with large number of interfaces + # recommend use of SNMP v2 (get-bulk) + } + if ($status==0) { + $state = "UNKNOWN"; + printf "$state: could not retrive ifdescr/iftype snmpkey - $status-$snmpkey\n"; + $session->close; + exit $ERRORS{$state}; + } +} + + +## Main function + +$snmpIfAdminStatus = $snmpIfAdminStatus . "." . $snmpkey; +$snmpIfOperStatus = $snmpIfOperStatus . "." . $snmpkey; +$snmpIfDescr = $snmpIfDescr . "." . $snmpkey; +$snmpIfName = $snmpIfName . "." . $snmpkey ; +$snmpIfAlias = $snmpIfAlias . "." . $snmpkey ; + +push(@snmpoids,$snmpIfAdminStatus); +push(@snmpoids,$snmpIfOperStatus); +push(@snmpoids,$snmpIfDescr); +push(@snmpoids,$snmpIfName) if (defined $ifXTable) ; +push(@snmpoids,$snmpIfAlias) if (defined $ifXTable) ; + +if (!defined($response = $session->get_request(@snmpoids))) { + $answer=$session->error; + $session->close; + $state = 'WARNING'; + print ("$state: SNMP error: $answer\n"); + exit $ERRORS{$state}; +} + +$answer = sprintf("host '%s', %s(%s) is %s\n", + $hostname, + $response->{$snmpIfDescr}, + $snmpkey, + $ifOperStatus{$response->{$snmpIfOperStatus}} +); + + +## Check to see if ifName match is requested and it matches - exit if no match +## not the interface we want to monitor +if ( defined $ifName && not ($response->{$snmpIfName} eq $ifName) ) { + $state = 'UNKNOWN'; + $answer = "Interface name ($ifName) doesn't match snmp value ($response->{$snmpIfName}) (index $snmpkey)"; + print ("$state: $answer\n"); + exit $ERRORS{$state}; +} + +## define the interface name +if (defined $ifXTable) { + $name = $response->{$snmpIfName} ." - " .$response->{$snmpIfAlias} ; +}else{ + $name = $response->{$snmpIfDescr} ; +} + +## if AdminStatus is down - some one made a consious effort to change config +## +if ( not ($response->{$snmpIfAdminStatus} == 1) ) { + $answer = "Interface $name (index $snmpkey) is administratively down."; + if ( not defined $adminWarn or $adminWarn eq "w" ) { + $state = 'WARNING'; + } elsif ( $adminWarn eq "i" ) { + $state = 'OK'; + } elsif ( $adminWarn eq "c" ) { + $state = 'CRITICAL'; + } else { # If wrong value for -a, say warning + $state = 'WARNING'; + } +} +## Check operational status +elsif ( $response->{$snmpIfOperStatus} == 2 ) { + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) is down."; +} elsif ( $response->{$snmpIfOperStatus} == 5 ) { + if (defined $dormantWarn ) { + if ($dormantWarn eq "w") { + $state = 'WARNING'; + $answer = "Interface $name (index $snmpkey) is dormant."; + }elsif($dormantWarn eq "c") { + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) is dormant."; + }elsif($dormantWarn eq "i") { + $state = 'OK'; + $answer = "Interface $name (index $snmpkey) is dormant."; + } + }else{ + # dormant interface - but warning/critical/ignore not requested + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) is dormant."; + } +} elsif ( $response->{$snmpIfOperStatus} == 6 ) { + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) notPresent - possible hotswap in progress."; +} elsif ( $response->{$snmpIfOperStatus} == 7 ) { + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) down due to lower layer being down."; +} elsif ( $response->{$snmpIfOperStatus} == 3 || $response->{$snmpIfOperStatus} == 4 ) { + $state = 'CRITICAL'; + $answer = "Interface $name (index $snmpkey) down (testing/unknown)."; +} else { + $state = 'OK'; + $answer = "Interface $name (index $snmpkey) is up."; +} + + + +print ("$state: $answer\n"); +exit $ERRORS{$state}; + + +### subroutines + +sub fetch_ifindex { + my $oid = shift; + my $lookup = shift; + + if (!defined ($response = $session->get_table($oid))) { + $answer=$session->error; + $session->close; + $state = 'CRITICAL'; + printf ("$state: SNMP error with snmp version $snmp_version ($answer)\n"); + $session->close; + exit $ERRORS{$state}; + } + + foreach $key ( keys %{$response}) { + if ($response->{$key} =~ /^$lookup$/) { + $key =~ /.*\.(\d+)$/; + $snmpkey = $1; + #print "$lookup = $key / $snmpkey \n"; #debug + } + } + unless (defined $snmpkey) { + $session->close; + $state = 'CRITICAL'; + printf "$state: Could not match $ifdescr on $hostname\n"; + exit $ERRORS{$state}; + } + + return $snmpkey; +} + +sub usage($) { + print "$_[0]\n"; + print_usage(); + exit $ERRORS{"UNKNOWN"}; +} + +sub print_usage() { + printf "\n"; + printf "usage: \n"; + printf "check_ifoperstatus -k -H [-C ]\n"; + printf "Copyright (C) 2000 Christoph Kron\n"; + printf "check_ifoperstatus.pl comes with ABSOLUTELY NO WARRANTY\n"; + printf "This programm is licensed under the terms of the "; + printf "GNU General Public License\n(check source code for details)\n"; + printf "\n\n"; +} + +sub print_help() { + print_revision($PROGNAME, '1.4.15'); + print_usage(); + printf "check_ifoperstatus plugin for Nagios monitors operational \n"; + printf "status of a particular network interface on the target host\n"; + printf "\nUsage:\n"; + printf " -H (--hostname) Hostname to query - (required)\n"; + printf " -C (--community) SNMP read community (defaults to public,\n"; + printf " used with SNMP v1 and v2c\n"; + printf " -v (--snmp_version) 1 for SNMP v1 (default)\n"; + printf " 2 for SNMP v2c\n"; + printf " SNMP v2c will use get_bulk for less overhead\n"; + printf " if monitoring with -d\n"; + printf " -L (--seclevel) choice of \"noAuthNoPriv\", \"authNoPriv\", or \"authPriv\"\n"; + printf " -U (--secname) username for SNMPv3 context\n"; + printf " -c (--context) SNMPv3 context name (default is empty string)\n"; + printf " -A (--authpass) authentication password (cleartext ascii or localized key\n"; + printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; + printf " auth password and authEngineID\n"; + printf " -a (--authproto) Authentication protocol (MD5 or SHA1)\n"; + printf " -X (--privpass) privacy password (cleartext ascii or localized key\n"; + printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; + printf " privacy password and authEngineID\n"; + printf " -P (--privproto) privacy protocol (DES or AES; default: DES)\n"; + printf " -k (--key) SNMP IfIndex value\n"; + printf " -d (--descr) SNMP ifDescr value\n"; + printf " -T (--type) SNMP ifType integer value (see http://www.iana.org/assignments/ianaiftype-mib)\n"; + printf " -p (--port) SNMP port (default 161)\n"; + printf " -I (--ifmib) Agent supports IFMIB ifXTable. Do not use if\n"; + printf " you don't know what this is. \n"; + printf " -n (--name) the value should match the returned ifName\n"; + printf " (Implies the use of -I)\n"; + printf " -w (--warn =i|w|c) ignore|warn|crit if the interface is dormant (default critical)\n"; + printf " -D (--admin-down =i|w|c) same for administratively down interfaces (default warning)\n"; + printf " -M (--maxmsgsize) Max message size - usefull only for v1 or v2c\n"; + printf " -t (--timeout) seconds before the plugin times out (default=$TIMEOUT)\n"; + printf " -V (--version) Plugin version\n"; + printf " -h (--help) usage help \n\n"; + printf " -k or -d or -T must be specified\n\n"; + printf "Note: either -k or -d or -T must be specified and -d and -T are much more network \n"; + printf "intensive. Use it sparingly or not at all. -n is used to match against\n"; + printf "a much more descriptive ifName value in the IfXTable to verify that the\n"; + printf "snmpkey has not changed to some other network interface after a reboot.\n\n"; + +} + +sub process_arguments() { + $status = GetOptions( + "V" => \$opt_V, "version" => \$opt_V, + "h" => \$opt_h, "help" => \$opt_h, + "v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version, + "C=s" => \$community, "community=s" => \$community, + "L=s" => \$seclevel, "seclevel=s" => \$seclevel, + "a=s" => \$authproto, "authproto=s" => \$authproto, + "U=s" => \$secname, "secname=s" => \$secname, + "A=s" => \$authpass, "authpass=s" => \$authpass, + "X=s" => \$privpass, "privpass=s" => \$privpass, + "P=s" => \$privproto, "privproto=s" => \$privproto, + "c=s" => \$context, "context=s" => \$context, + "k=i" => \$snmpkey, "key=i",\$snmpkey, + "d=s" => \$ifdescr, "descr=s" => \$ifdescr, + "l=s" => \$lastc, "lastchange=s" => \$lastc, + "p=i" => \$port, "port=i" =>\$port, + "H=s" => \$hostname, "hostname=s" => \$hostname, + "I" => \$ifXTable, "ifmib" => \$ifXTable, + "n=s" => \$ifName, "name=s" => \$ifName, + "w=s" => \$dormantWarn, "warn=s" => \$dormantWarn, + "D=s" => \$adminWarn, "admin-down=s" => \$adminWarn, + "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize, + "t=i" => \$timeout, "timeout=i" => \$timeout, + "T=i" => \$iftype, "type=i" => \$iftype, + ); + + + if ($status == 0){ + print_help(); + exit $ERRORS{'OK'}; + } + + if ($opt_V) { + print_revision($PROGNAME,'1.4.15'); + exit $ERRORS{'OK'}; + } + + if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; + } + + if (! utils::is_hostname($hostname)){ + usage("Hostname invalid or not given"); + } + + unless ($snmpkey > 0 || defined $ifdescr || defined $iftype){ + usage("Either a valid snmp key (-k) or a ifDescr (-d) must be provided"); + } + + if (defined $ifName) { + $ifXTable=1; + } + + if (defined $dormantWarn) { + unless ($dormantWarn =~ /^(w|c|i)$/ ) { + printf "Dormant alerts must be one of w|c|i \n"; + exit $ERRORS{'UNKNOWN'}; + } + } + + unless (defined $timeout) { + $timeout = $TIMEOUT; + } + + if ($snmp_version !~ /[123]/){ + $state='UNKNOWN'; + print ("$state: No support for SNMP v$snmp_version yet\n"); + exit $ERRORS{$state}; + } + + %session_opts = ( + -hostname => $hostname, + -port => $port, + -version => $snmp_version, + -maxmsgsize => $maxmsgsize + ); + + $session_opts{'-community'} = $community if (defined $community && $snmp_version =~ /[12]/); + + if ($snmp_version =~ /3/ ) { + # Must define a security level even though default is noAuthNoPriv + # v3 requires a security username + if (defined $seclevel && defined $secname) { + $session_opts{'-username'} = $secname; + + # Must define a security level even though defualt is noAuthNoPriv + unless ( grep /^$seclevel$/, qw(noAuthNoPriv authNoPriv authPriv) ) { + usage("Must define a valid security level even though default is noAuthNoPriv"); + } + + # Authentication wanted + if ( $seclevel eq 'authNoPriv' || $seclevel eq 'authPriv' ) { + if (defined $authproto && $authproto ne 'MD5' && $authproto ne 'SHA1') { + usage("Auth protocol can be either MD5 or SHA1"); + } + $session_opts{'-authprotocol'} = $authproto if(defined $authproto); + + if ( !defined $authpass) { + usage("Auth password/key is not defined"); + }else{ + if ($authpass =~ /^0x/ ) { + $session_opts{'-authkey'} = $authpass ; + }else{ + $session_opts{'-authpassword'} = $authpass ; + } + } + } + + # Privacy (DES encryption) wanted + if ($seclevel eq 'authPriv' ) { + if (! defined $privpass) { + usage("Privacy passphrase/key is not defined"); + }else{ + if ($privpass =~ /^0x/){ + $session_opts{'-privkey'} = $privpass; + }else{ + $session_opts{'-privpassword'} = $privpass; + } + } + + $session_opts{'-privprotocol'} = $privproto if(defined $privproto); + } + + # Context name defined or default + unless ( defined $context) { + $context = ""; + } + + }else { + usage("Security level or name is not defined"); + } + } # end snmpv3 + + +} +## End validation + diff --git a/Monitoring/plugins/check_ifstatus b/Monitoring/plugins/check_ifstatus new file mode 100755 index 00000000..b977675e --- /dev/null +++ b/Monitoring/plugins/check_ifstatus @@ -0,0 +1,425 @@ +#! /usr/bin/perl -w +# +# check_ifstatus.pl - nagios plugin +# +# +# Copyright (C) 2000 Christoph Kron +# Modified 5/2002 to conform to updated Nagios Plugin Guidelines (S. Ghosh) +# Added -x option (4/2003) +# Added -u option (4/2003) +# Added -M option (10/2003) +# Added SNMPv3 support (10/2003) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# +# Report bugs to: ck@zet.net, nagiosplug-help@lists.sf.net +# +# 11.01.2000 Version 1.0 +# + +use POSIX; +use strict; +use lib "/usr/lib/nagios/plugins" ; +use utils qw($TIMEO