summaryrefslogtreecommitdiffstats
path: root/Monitoring/nagios/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/nagios/plugins')
-rwxr-xr-xMonitoring/nagios/plugins/check.bat0
-rwxr-xr-xMonitoring/nagios/plugins/check.sh5
-rwxr-xr-xMonitoring/nagios/plugins/check_aptbin0 -> 106120 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_bgpstate215
-rwxr-xr-xMonitoring/nagios/plugins/check_breeze87
-rwxr-xr-xMonitoring/nagios/plugins/check_btcguild_miner36
-rwxr-xr-xMonitoring/nagios/plugins/check_by_sshbin0 -> 46192 bytes
l---------Monitoring/nagios/plugins/check_clamd1
-rwxr-xr-xMonitoring/nagios/plugins/check_clusterbin0 -> 32072 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_cpu165
-rwxr-xr-xMonitoring/nagios/plugins/check_dhcpbin0 -> 44816 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_digbin0 -> 41392 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_diskbin0 -> 119216 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_disk_smb307
-rwxr-xr-xMonitoring/nagios/plugins/check_dnsbin0 -> 45488 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_dummybin0 -> 28968 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_dummy.sh5
-rwxr-xr-xMonitoring/nagios/plugins/check_file_age112
-rwxr-xr-xMonitoring/nagios/plugins/check_flexlm244
-rwxr-xr-xMonitoring/nagios/plugins/check_fpingbin0 -> 44656 bytes
l---------Monitoring/nagios/plugins/check_ftp1
-rwxr-xr-xMonitoring/nagios/plugins/check_gamebin0 -> 36584 bytes
l---------Monitoring/nagios/plugins/check_host1
-rwxr-xr-xMonitoring/nagios/plugins/check_hpjdbin0 -> 41136 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_httpbin0 -> 164624 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_icmpbin0 -> 49264 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_ide_smartbin0 -> 34536 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_ifoperstatus472
-rwxr-xr-xMonitoring/nagios/plugins/check_ifstatus425
l---------Monitoring/nagios/plugins/check_imap1
-rwxr-xr-xMonitoring/nagios/plugins/check_ircd239
l---------Monitoring/nagios/plugins/check_jabber1
-rwxr-xr-xMonitoring/nagios/plugins/check_ldapbin0 -> 40816 bytes
l---------Monitoring/nagios/plugins/check_ldaps1
-rwxr-xr-xMonitoring/nagios/plugins/check_linux_raid115
-rwxr-xr-xMonitoring/nagios/plugins/check_loadbin0 -> 36168 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_log219
-rwxr-xr-xMonitoring/nagios/plugins/check_mailq608
-rwxr-xr-xMonitoring/nagios/plugins/check_mem.pl263
-rwxr-xr-xMonitoring/nagios/plugins/check_mrtgbin0 -> 36264 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_mrtgtrafbin0 -> 34440 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_mysqlbin0 -> 45936 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_mysql_querybin0 -> 44688 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_nagiosbin0 -> 36616 bytes
l---------Monitoring/nagios/plugins/check_nntp1
l---------Monitoring/nagios/plugins/check_nntps1
-rwxr-xr-xMonitoring/nagios/plugins/check_ntbin0 -> 48720 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_ntpbin0 -> 46288 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_ntp_peerbin0 -> 44880 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_ntp_timebin0 -> 42224 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_nwstatbin0 -> 60912 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_oracle287
-rwxr-xr-xMonitoring/nagios/plugins/check_overcrbin0 -> 40400 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_pgsqlbin0 -> 40656 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_pingbin0 -> 48848 bytes
l---------Monitoring/nagios/plugins/check_pop1
-rwxr-xr-xMonitoring/nagios/plugins/check_procsbin0 -> 114640 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_radiusbin0 -> 40624 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_realbin0 -> 40464 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_rpc375
l---------Monitoring/nagios/plugins/check_rta_multi1
-rwxr-xr-xMonitoring/nagios/plugins/check_sensors65
-rwxr-xr-xMonitoring/nagios/plugins/check_shinken.py157
l---------Monitoring/nagios/plugins/check_simap1
-rwxr-xr-xMonitoring/nagios/plugins/check_sip252
-rwxr-xr-xMonitoring/nagios/plugins/check_smtpbin0 -> 127216 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_snmpbin0 -> 152008 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_speed34
l---------Monitoring/nagios/plugins/check_spop1
-rwxr-xr-xMonitoring/nagios/plugins/check_sshbin0 -> 36688 bytes
l---------Monitoring/nagios/plugins/check_ssmtp1
-rwxr-xr-xMonitoring/nagios/plugins/check_swapbin0 -> 37832 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_tcpbin0 -> 49328 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_temper31
-rwxr-xr-xMonitoring/nagios/plugins/check_timebin0 -> 38128 bytes
l---------Monitoring/nagios/plugins/check_udp1
-rwxr-xr-xMonitoring/nagios/plugins/check_upsbin0 -> 44560 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_usersbin0 -> 36168 bytes
-rwxr-xr-xMonitoring/nagios/plugins/check_wave122
-rwxr-xr-xMonitoring/nagios/plugins/getwmic.sh7
-rwxr-xr-xMonitoring/nagios/plugins/link_vmware_host_vm.py184
-rwxr-xr-xMonitoring/nagios/plugins/negatebin0 -> 38152 bytes
-rwxr-xr-xMonitoring/nagios/plugins/nmap_discovery_runner.py419
-rwxr-xr-xMonitoring/nagios/plugins/notify.sh6
-rwxr-xr-xMonitoring/nagios/plugins/notify_irc87
-rwxr-xr-xMonitoring/nagios/plugins/nsca_client.py184
-rwxr-xr-xMonitoring/nagios/plugins/sendmailhost.pl96
-rwxr-xr-xMonitoring/nagios/plugins/sendmailservices.pl105
-rwxr-xr-xMonitoring/nagios/plugins/urlizebin0 -> 36104 bytes
-rw-r--r--Monitoring/nagios/plugins/utils.pm67
-rwxr-xr-xMonitoring/nagios/plugins/utils.sh23
-rwxr-xr-xMonitoring/nagios/plugins/vmware_discovery_runner.py225
92 files changed, 6257 insertions, 0 deletions
diff --git a/Monitoring/nagios/plugins/check.bat b/Monitoring/nagios/plugins/check.bat
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/Monitoring/nagios/plugins/check.bat
diff --git a/Monitoring/nagios/plugins/check.sh b/Monitoring/nagios/plugins/check.sh
new file mode 100755
index 00000000..9e62fbee
--- /dev/null
+++ b/Monitoring/nagios/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/nagios/plugins/check_apt b/Monitoring/nagios/plugins/check_apt
new file mode 100755
index 00000000..2371c32d
--- /dev/null
+++ b/Monitoring/nagios/plugins/check_apt
Binary files differ
diff --git a/Monitoring/nagios/plugins/check_bgpstate b/Monitoring/nagios/plugins/check_bgpstate
new file mode 100755
index 00000000..645d7505
--- /dev/null
+++ b/Monitoring/nagios/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 <READCOMMUNITY> -p <PORT> <HOSTNAME>\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<BR>",
+ $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<BR>",
+ $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/nagios/plugins/check_breeze b/Monitoring/nagios/plugins/check_breeze
new file mode 100755
index 00000000..d0382e69
--- /dev/null
+++ b/Monitoring/nagios/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 <host> [-C community] -w <warn> -c <crit>\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/nagios/plugins/check_btcguild_miner b/Monitoring/nagios/plugins/check_btcguild_miner
new file mode 100755
index 00000000..2e6a8de3
--- /dev/null
+++ b/Monitoring/nagios/plugins/check_btcguild_miner
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+
+import sys
+from urllib2 import urlopen
+try:
+ import json
+ getattr(json,"load")
+except: #deal with it
+ import simplejson as json
+
+if len(sys.argv) != 4 :
+ print "** Usage: %s APIKEY WORKER_NAME LOW_WORKER_SPEED" % sys.argv[0]
+ print "** aka YOU ARE MADE OF STUPID"
+ exit (3)
+
+API_KEY=sys.argv[1]
+WORKER_NAME=sys.argv[2]
+LOW_WORKER_SPEED=float(sys.argv[3])
+url="http://www.btcguild.com/api.php?api_key=%s" % API_KEY
+try:
+ fh = urlopen(url)
+ result = json.load(fh)
+except Exception,e:
+ print "?? cannot parse json or connect to server: %s"% str(e)
+ exit (1)
+
+for k,v in result["workers"].iteritems():
+ if v["worker_name"] == WORKER_NAME:
+ curr = v["hash_rate"]
+ if curr < LOW_WORKER_SPEED:
+ print "!! %f is below expected %f" % (curr,LOW_WORKER_SPEED)
+ exit (2)
+ else:
+ print "++ everything fine, current speed is %f" % curr
+ exit(0)
+
diff --git a/Monitoring/nagios/plugins/check_by_ssh b/Monitoring/nagios/plugins/check_by_ssh
new file mode 100755
index 00000000..5f969058
--- /dev/null
+++ b/Monitoring/nagios/plugins/check_by_ssh
Binary files differ
diff --git a/Monitoring/nagios/plugins/check_clamd b/Monitoring/nagios/plugins/check_clamd
new file mode 120000
index 00000000..e838da97
--- /dev/null
+++ b/Monitoring/nagios/plugins/check_clamd
@@ -0,0 +1 @@
+check_tcp \ No newline at end of file
diff --git a/Monitoring/nagios/plugins/check_cluster b/Monitoring/nagios/plugins/check_cluster
new file mode 100755
index 00000000..8d6dbb90
--- /dev/null
+++ b/Monitoring/nagios/plugins/check_cluster
Binary files differ
diff --git a/Monitoring/nagios/plugins/check_cpu b/Monitoring/nagios/plugins/check_cpu
new file mode 100755
index 00000000..26a93da5
--- /dev/null
+++ b/Monitoring/nagios/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()