Imported Upstream version 1.4.8
This commit is contained in:
		
							parent
							
								
									6a280f6f24
								
							
						
					
					
						commit
						6dd54dd8e2
					
				
					 352 changed files with 42813 additions and 27251 deletions
				
			
		| 
						 | 
				
			
			@ -1,87 +0,0 @@
 | 
			
		|||
/README.TXT/1.4/Thu Jan 27 02:27:13 2005//Tr1_4_5
 | 
			
		||||
/check_adptraid.sh/1.1/Sun Feb  9 14:20:30 2003//Tr1_4_5
 | 
			
		||||
/check_apache.pl/1.1.1.1/Thu Feb 28 06:42:53 2002//Tr1_4_5
 | 
			
		||||
/check_apc_ups.pl/1.2/Wed Aug 14 19:02:31 2002//Tr1_4_5
 | 
			
		||||
/check_appletalk.pl/1.1/Tue Feb 18 04:05:01 2003//Tr1_4_5
 | 
			
		||||
/check_arping.pl/1.1/Thu Jan 27 04:44:29 2005//Tr1_4_5
 | 
			
		||||
/check_asterisk.pl/1.1/Tue Feb  1 04:19:31 2005//Tr1_4_5
 | 
			
		||||
/check_axis.sh/1.2/Mon May 26 10:09:23 2003//Tr1_4_5
 | 
			
		||||
/check_backup.pl/1.1/Sun Apr  7 05:13:57 2002//Tr1_4_5
 | 
			
		||||
/check_bgpstate.pl/1.2/Sun Feb 23 17:10:39 2003//Tr1_4_5
 | 
			
		||||
/check_breeze.pl/1.1/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_cluster.c/1.1/Tue Jun 18 01:05:26 2002//Tr1_4_5
 | 
			
		||||
/check_cluster2.c/1.1/Fri Mar 12 03:40:57 2004//Tr1_4_5
 | 
			
		||||
/check_compaq_insight.pl/1.1/Sun Feb  9 14:20:30 2003//Tr1_4_5
 | 
			
		||||
/check_cpqarray.c/1.1/Thu Jan 27 04:46:08 2005//Tr1_4_5
 | 
			
		||||
/check_digitemp.pl/1.1/Thu Aug  1 04:46:01 2002//Tr1_4_5
 | 
			
		||||
/check_dlswcircuit.pl/1.1.1.1/Thu Feb 28 06:42:53 2002//Tr1_4_5
 | 
			
		||||
/check_dns_random.pl/1.2/Wed Jan 29 05:27:20 2003//Tr1_4_5
 | 
			
		||||
/check_email_loop.pl/1.5/Tue Nov 29 23:21:06 2005//Tr1_4_5
 | 
			
		||||
/check_fan_cpq_present/1.1/Thu Jan 27 04:52:58 2005//Tr1_4_5
 | 
			
		||||
/check_fan_fsc_present/1.1/Thu Jan 27 04:53:21 2005//Tr1_4_5
 | 
			
		||||
/check_flexlm.pl/1.1/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_frontpage/1.1/Thu Jan 27 04:45:00 2005//Tr1_4_5
 | 
			
		||||
/check_hltherm.c/1.1/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_hprsc.pl/1.2/Thu Nov 25 03:01:23 2004//Tr1_4_5
 | 
			
		||||
/check_http-with-client-certificate.c/1.1/Tue Feb  1 04:19:42 2005//Tr1_4_5
 | 
			
		||||
/check_hw.sh/1.1/Thu Nov 25 04:30:04 2004//Tr1_4_5
 | 
			
		||||
/check_ica_master_browser.pl/1.1/Tue Jan 25 09:09:33 2005//Tr1_4_5
 | 
			
		||||
/check_ica_metaframe_pub_apps.pl/1.1/Tue Jan 25 09:07:39 2005//Tr1_4_5
 | 
			
		||||
/check_ica_program_neigbourhood.pl/1.1/Tue Jan 25 09:05:53 2005//Tr1_4_5
 | 
			
		||||
/check_inodes-freebsd.pl/1.1/Wed Aug 14 19:00:17 2002//Tr1_4_5
 | 
			
		||||
/check_inodes.pl/1.1/Thu Apr 18 21:59:26 2002//Tr1_4_5
 | 
			
		||||
/check_ipxping.c/1.2/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_javaproc.pl/1.1/Mon Nov 18 21:58:58 2002//Tr1_4_5
 | 
			
		||||
/check_joy.sh/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_linux_raid.pl/1.5/Wed Jun  7 14:28:33 2006//Tr1_4_5
 | 
			
		||||
/check_lmmon.pl/1.1/Tue Jun 25 13:55:07 2002//Tr1_4_5
 | 
			
		||||
/check_log2.pl/1.2/Fri Dec 16 18:41:45 2005//Tr1_4_5
 | 
			
		||||
/check_lotus.pl/1.1/Tue Jan 25 09:04:26 2005//Tr1_4_5
 | 
			
		||||
/check_maxchannels.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_maxwanstate.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_mem.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_ms_spooler.pl/1.1/Tue Jul 16 00:04:42 2002//Tr1_4_5
 | 
			
		||||
/check_mssql.sh/1.3/Tue Aug  5 09:56:13 2003//Tr1_4_5
 | 
			
		||||
/check_nagios.pl/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
/check_nagios_db.pl/1.1/Wed Aug 14 19:01:58 2002//Tr1_4_5
 | 
			
		||||
/check_nagios_db_pg.pl/1.1/Mon Apr 19 13:13:23 2004//Tr1_4_5
 | 
			
		||||
/check_netapp.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_nmap.py/1.2/Wed Dec  1 03:50:37 2004//Tr1_4_5
 | 
			
		||||
/check_ora_table_space.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_oracle_instance.pl/1.1/Wed Apr  3 02:58:47 2002//Tr1_4_5
 | 
			
		||||
/check_oracle_tbs/1.2/Fri Feb  4 00:27:38 2005//Tr1_4_5
 | 
			
		||||
/check_pcpmetric.py/1.1/Thu Jan 27 04:45:46 2005//Tr1_4_5
 | 
			
		||||
/check_pfstate/1.1/Thu Jan 27 04:43:49 2005//Tr1_4_5
 | 
			
		||||
/check_qmailq.pl/1.1.1.1/Thu Feb 28 06:42:53 2002//Tr1_4_5
 | 
			
		||||
/check_rbl.c/1.3/Thu Dec  2 00:30:32 2004//Tr1_4_5
 | 
			
		||||
/check_remote_nagios_status.pl/1.1/Sun Feb  9 14:16:28 2003//Tr1_4_5
 | 
			
		||||
/check_rrd_data.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_sap.sh/1.2/Tue May 27 13:10:01 2003//Tr1_4_5
 | 
			
		||||
/check_smart.pl/1.1/Thu Jan 27 10:32:48 2005//Tr1_4_5
 | 
			
		||||
/check_smb.sh/1.1/Wed Aug 14 15:29:58 2002//Tr1_4_5
 | 
			
		||||
/check_snmp_disk_monitor.pl/1.1/Thu Aug 22 14:42:43 2002//Tr1_4_5
 | 
			
		||||
/check_snmp_printer.pl/1.1/Sun Jan 18 20:07:01 2004//Tr1_4_5
 | 
			
		||||
/check_snmp_process_monitor.pl/1.2/Thu Aug 22 22:08:46 2002//Tr1_4_5
 | 
			
		||||
/check_snmp_procs.pl/1.1/Tue Feb 17 13:23:31 2004//Tr1_4_5
 | 
			
		||||
/check_sockets.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/check_sybase/1.3/Fri Apr 29 00:27:49 2005//Tr1_4_5
 | 
			
		||||
/check_temp_cpq/1.1/Thu Jan 27 04:53:41 2005//Tr1_4_5
 | 
			
		||||
/check_temp_fsc/1.1/Thu Jan 27 04:53:59 2005//Tr1_4_5
 | 
			
		||||
/check_timeout.c/1.1.1.1/Thu Feb 28 06:42:53 2002//Tr1_4_5
 | 
			
		||||
/check_traceroute-pure_perl.pl/1.1/Tue Feb  1 12:43:58 2005//Tr1_4_5
 | 
			
		||||
/check_traceroute.pl/1.1/Thu Jan 27 10:34:16 2005//Tr1_4_5
 | 
			
		||||
/check_uptime.c/1.2/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_vcs.pl/1.1/Thu May 23 16:39:59 2002//Tr1_4_5
 | 
			
		||||
/check_wave.pl/1.1/Fri Mar  1 02:42:56 2002//Tr1_4_5
 | 
			
		||||
/check_wins.pl/1.3/Thu Nov 25 04:46:16 2004//Tr1_4_5
 | 
			
		||||
/checkciscotemp.pl/1.3/Tue Jan 28 07:44:56 2003//Tr1_4_5
 | 
			
		||||
/mrtgext.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/nagios_sendim.pl/1.1/Mon Nov 18 21:58:58 2002//Tr1_4_5
 | 
			
		||||
/packet_utils.pm/1.1/Tue Jan 25 09:12:47 2005//Tr1_4_5
 | 
			
		||||
/rblcheck-dns/1.1/Mon Nov 29 05:07:33 2004//Tr1_4_5
 | 
			
		||||
/rblcheck-web/1.1/Mon Nov 29 05:07:33 2004//Tr1_4_5
 | 
			
		||||
/restrict.pl/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
/sched_downtime.pl/1.1/Sun Feb  9 14:16:29 2003//Tr1_4_5
 | 
			
		||||
/urlize.pl/1.2/Tue Jun 10 05:04:09 2003//Tr1_4_5
 | 
			
		||||
/utils.py/1.1.1.1/Thu Feb 28 06:42:54 2002//Tr1_4_5
 | 
			
		||||
D
 | 
			
		||||
| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
A D/aix////
 | 
			
		||||
A D/tarballs////
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
nagiosplug/contrib
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
Nr1_4_5
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
/check_failed/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
/check_io/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
/check_kerberos/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
/check_queue/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
/pg_stat/1.1.1.1/Thu Feb 28 06:42:55 2002//Tr1_4_5
 | 
			
		||||
D
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
nagiosplug/contrib/aix
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
Nr1_4_5
 | 
			
		||||
| 
						 | 
				
			
			@ -1,370 +0,0 @@
 | 
			
		|||
#!/usr/bin/perl
 | 
			
		||||
# check_sybase
 | 
			
		||||
# A nagios plugin that connects to a Sybase database and checks free space.
 | 
			
		||||
#
 | 
			
		||||
# Copyright 2004-2005 Simon Bellwood, NetMan Network Management and IT 
 | 
			
		||||
# 								Services GmbH
 | 
			
		||||
# Portions Copyright 2001 Michael Peppler.
 | 
			
		||||
# License: GPL
 | 
			
		||||
#
 | 
			
		||||
# Bugs and feedback to simon.bellwood@NOSPAM.net-man.at
 | 
			
		||||
# Latest version available from:
 | 
			
		||||
# 	http://www.net-man.at/software/check_sybase-LATEST.zip
 | 
			
		||||
#
 | 
			
		||||
# Revision history:
 | 
			
		||||
# 0.1	01-OCT-2004	Initial version.
 | 
			
		||||
# 0.2	08-NOV-2004	Initial release.
 | 
			
		||||
# 0.3	13-JAN-2005	Fixed lib path, improved timeouts.
 | 
			
		||||
# 0.4	26-JAN-2005	Added loginTimeout.
 | 
			
		||||
# 0.5	04-FEB-2005	Fixed dates in history. Oops.
 | 
			
		||||
# 0.6	29-MAR-2005	Added --explain option.
 | 
			
		||||
# 0.7	08-APR-2005	Added initial performance data support.
 | 
			
		||||
my $VERSION = "0.7";
 | 
			
		||||
 | 
			
		||||
#use warnings;
 | 
			
		||||
use strict;
 | 
			
		||||
use DBI;
 | 
			
		||||
use Getopt::Long;
 | 
			
		||||
use lib qw( /usr/lib/nagios/plugins/ /usr/local/nagios/libexec/ );
 | 
			
		||||
use utils qw(%ERRORS &print_revision &support &usage $TIMEOUT);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
my $PROGNAME = "check_sybase";
 | 
			
		||||
my $DEFAULT_CHECKTYPE = "FREESPACE";
 | 
			
		||||
my $DEFAULT_WARNING   = "25";
 | 
			
		||||
my $DEFAULT_CRITICAL  = "10";
 | 
			
		||||
my $DEFAULT_TIMEOUT   = "30";
 | 
			
		||||
 | 
			
		||||
my ($user, $pass, $dbsvr, $dbname, $config, $checktype, $explain,
 | 
			
		||||
    $warn, $crit, $timeout, $help, $version);
 | 
			
		||||
 | 
			
		||||
my $options_okay = GetOptions(
 | 
			
		||||
	"U|user=s"	=> \$user,
 | 
			
		||||
	"P|pass:s"	=> \$pass, # ":" means optional
 | 
			
		||||
	"S|dbsvr=s"	=> \$dbsvr,
 | 
			
		||||
	"D|dbname=s"	=> \$dbname,
 | 
			
		||||
	"config=s"	=> \$config,
 | 
			
		||||
	"checktype=s"	=> \$checktype,
 | 
			
		||||
	"explain"	=> \$explain,
 | 
			
		||||
	"w|warning=i"	=> \$warn,
 | 
			
		||||
	"c|critical=i"	=> \$crit,
 | 
			
		||||
	"t|timeout=i"	=> \$timeout,
 | 
			
		||||
	"h|help"	=> \$help,
 | 
			
		||||
	"V|version"	=> \$version
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if (! $options_okay) # Bad option passed
 | 
			
		||||
{
 | 
			
		||||
	&help;
 | 
			
		||||
	&nunk("Bad command line option passed!");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Use defaults, if needed
 | 
			
		||||
$warn = $warn || $DEFAULT_WARNING;
 | 
			
		||||
$crit = $crit || $DEFAULT_CRITICAL;
 | 
			
		||||
$checktype = $checktype || $DEFAULT_CHECKTYPE;
 | 
			
		||||
$timeout = $timeout || $TIMEOUT || $DEFAULT_TIMEOUT;
 | 
			
		||||
 | 
			
		||||
if ($help)
 | 
			
		||||
{
 | 
			
		||||
	&help;
 | 
			
		||||
	&nok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($version)
 | 
			
		||||
{
 | 
			
		||||
	print_revision($PROGNAME,"\$Revision: 1.3 $VERSION \$");
 | 
			
		||||
	&nok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if ($config) # Read any of "user", "pass", "dbsvr", "dbname" from config file
 | 
			
		||||
{
 | 
			
		||||
	&read_config;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Some more descriptive syntax checks
 | 
			
		||||
my $syntax_error;
 | 
			
		||||
$syntax_error .= "No dbsvr given! " unless $dbsvr;
 | 
			
		||||
$syntax_error .= "No dbname given! " unless $dbname;
 | 
			
		||||
$syntax_error .= "No user given! " unless $user;
 | 
			
		||||
$syntax_error .= "Bad checktype given!"
 | 
			
		||||
	unless $checktype =~ m/^CONNECT|FREESPACE$/;
 | 
			
		||||
&nunk($syntax_error) if $syntax_error;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Just in case of problems, let's not hang Nagios
 | 
			
		||||
$SIG{'ALRM'} = sub {
 | 
			
		||||
	&nunk("Timeout: no response from dbsvr $dbsvr within $timeout seconds");
 | 
			
		||||
};
 | 
			
		||||
alarm($timeout);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Decide on what we are checking
 | 
			
		||||
if ($checktype eq "CONNECT")
 | 
			
		||||
{
 | 
			
		||||
	&connect;
 | 
			
		||||
}
 | 
			
		||||
elsif ($checktype eq "FREESPACE")
 | 
			
		||||
{
 | 
			
		||||
	&check_space;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
my $dbh;
 | 
			
		||||
my $is_connected;
 | 
			
		||||
sub connect
 | 
			
		||||
{
 | 
			
		||||
	$dbh = DBI->connect("dbi:Sybase:server=$dbsvr;database=$dbname;".
 | 
			
		||||
	               "timeout=$timeout,loginTimeout=$timeout", $user, $pass)
 | 
			
		||||
		or &ncrit("Could not connect to '$dbname' on '$dbsvr'");
 | 
			
		||||
 | 
			
		||||
	# Report success for a check of type CONNECT
 | 
			
		||||
	&nok("Connect okay") if $checktype ne "FREESPACE";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub disconnect
 | 
			
		||||
{
 | 
			
		||||
	$dbh->disconnect if $is_connected;
 | 
			
		||||
	$is_connected = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub check_space
 | 
			
		||||
{
 | 
			
		||||
	&connect;
 | 
			
		||||
 | 
			
		||||
	# Most of this sub based on Michael Peppler's check-space.pl
 | 
			
		||||
	# For debugging purposes, more values are collected than needed.
 | 
			
		||||
 | 
			
		||||
	$dbh->{syb_do_proc_status} = 1;
 | 
			
		||||
 | 
			
		||||
	my $dbinfo;
 | 
			
		||||
 | 
			
		||||
	# First check space in the database
 | 
			
		||||
	my $sth = $dbh->prepare("sp_spaceused")
 | 
			
		||||
		or &nunk("Failed to call sp_spaceused on '$dbsvr'");
 | 
			
		||||
	$sth->execute
 | 
			
		||||
		or &nunk("Failed to call sp_spaceused on '$dbsvr'");
 | 
			
		||||
	do {
 | 
			
		||||
		while(my $d = $sth->fetch)
 | 
			
		||||
		{
 | 
			
		||||
			if($d->[0] =~ /$dbname/)
 | 
			
		||||
			{
 | 
			
		||||
				# Grab "database_size"
 | 
			
		||||
				$d->[1] =~ s/[^\d.]//g;
 | 
			
		||||
				$dbinfo->{size} = $d->[1];
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				# Reserved, data, index, unused
 | 
			
		||||
				foreach (@$d)
 | 
			
		||||
				{
 | 
			
		||||
					s/\D//g;
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				# Grab "reserved", "data", "index"
 | 
			
		||||
				$dbinfo->{reserved} = $d->[0] / 1024;
 | 
			
		||||
				$dbinfo->{data} = $d->[1] / 1024;
 | 
			
		||||
				$dbinfo->{index} = $d->[2] / 1024;
 | 
			
		||||
				$dbinfo->{unused} = $d->[3] / 1024;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} while($sth->{syb_more_results});
 | 
			
		||||
 | 
			
		||||
	&explain("db size:  ".$dbinfo->{size});
 | 
			
		||||
	&explain("reserved: ".$dbinfo->{reserved});
 | 
			
		||||
	&explain(" data:    ".$dbinfo->{data});
 | 
			
		||||
	&explain(" index:   ".$dbinfo->{index});
 | 
			
		||||
	&explain(" unused:  ".$dbinfo->{unused});
 | 
			
		||||
 | 
			
		||||
	# Get the actual device usage from sp_helpdb to get the free log space
 | 
			
		||||
	$sth = $dbh->prepare("sp_helpdb $dbname")
 | 
			
		||||
		or &nunk("Failed to call sp_helpdb $dbname on '$dbsvr'");
 | 
			
		||||
	$sth->execute
 | 
			
		||||
		or &nunk("Failed to call sp_helpdb $dbname on '$dbsvr'");
 | 
			
		||||
	do {
 | 
			
		||||
		while(my $d = $sth->fetch)
 | 
			
		||||
		{
 | 
			
		||||
			# Look for "usage" column with value "log only"
 | 
			
		||||
			if($d->[2] && $d->[2] =~ /log only/)
 | 
			
		||||
			{
 | 
			
		||||
				# Grab "size", add it to our log size
 | 
			
		||||
				$d->[1] =~ s/[^\d\.]//g;
 | 
			
		||||
				$dbinfo->{log} += $d->[1];
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			# Look for "device fragments" column with "log only"
 | 
			
		||||
			# followed by a number.
 | 
			
		||||
			if($d->[0] =~ /log only .* (\d+)/)
 | 
			
		||||
			{
 | 
			
		||||
				$dbinfo->{logfree} = $1 / 1024;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	} while($sth->{syb_more_results});
 | 
			
		||||
 | 
			
		||||
	&explain("log: ".$dbinfo->{log});
 | 
			
		||||
	&explain("logfree: ".$dbinfo->{logfree});
 | 
			
		||||
 | 
			
		||||
	# Subtract the log size from the database size
 | 
			
		||||
	$dbinfo->{realsize} = $dbinfo->{size} - $dbinfo->{log};
 | 
			
		||||
	&explain("realsize (i.e. size - log) = ".$dbinfo->{realsize});
 | 
			
		||||
 | 
			
		||||
	# The "reserved" space is free for use by the table that freed it, so 
 | 
			
		||||
	# it is not truly free space. To be safe, our calculation ignores it.
 | 
			
		||||
	my $free = ($dbinfo->{realsize} - $dbinfo->{reserved})/$dbinfo->{realsize};
 | 
			
		||||
	$free = sprintf("%.2f", $free*100);
 | 
			
		||||
 | 
			
		||||
	&explain("(realsize-reserved)/realsize = $free%");
 | 
			
		||||
	&explain("For safety, this calculation assumes no log space reuse. ".
 | 
			
		||||
	"Because of this, you may get negative values.");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if ($free < $crit)
 | 
			
		||||
	{
 | 
			
		||||
		&ncrit("Free space is $free%! (critical threshold is $crit%)".
 | 
			
		||||
			"|free_space=$free%");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ($free < $warn)
 | 
			
		||||
	{
 | 
			
		||||
		&nwarn("Free space is $free%! (warning threshold is $warn%)".
 | 
			
		||||
			"|free_space=$free%");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	&nok("Free space within thresholds ($free% free)".
 | 
			
		||||
		"|free_space=$free%");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub read_config
 | 
			
		||||
{
 | 
			
		||||
	open (CONFIG, "<$config")
 | 
			
		||||
		or &nunk("Failed to open config file '$config': $!");
 | 
			
		||||
	while (<CONFIG>)
 | 
			
		||||
	{
 | 
			
		||||
		chomp;
 | 
			
		||||
		next if m/^#/; # skip comments
 | 
			
		||||
		next if m/^$/; # skip blanks
 | 
			
		||||
 | 
			
		||||
		# Each case-insensitive argument can be followed by an optional
 | 
			
		||||
		# colon, then must be followed by whitespace and the value.
 | 
			
		||||
		# Options in the config file override those given on the 
 | 
			
		||||
		# command line, but don't rely on this!
 | 
			
		||||
 | 
			
		||||
		if    (m/USER:?\s+(\S+)/i)
 | 
			
		||||
		{
 | 
			
		||||
			$user = $1;
 | 
			
		||||
		}
 | 
			
		||||
		elsif (m/PASS:?\s+(\S+)/i)
 | 
			
		||||
		{
 | 
			
		||||
			$pass = $1;
 | 
			
		||||
		}
 | 
			
		||||
		elsif (m/DBSVR:?\s+(\S+)/i)
 | 
			
		||||
		{
 | 
			
		||||
			$dbsvr = $1;
 | 
			
		||||
		}
 | 
			
		||||
		elsif (m/DBNAME:?\s+(\S+)/i)
 | 
			
		||||
		{
 | 
			
		||||
			$dbname = $1;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			&nunk("Invalid line $. in config file '$config'");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	close (CONFIG);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub help
 | 
			
		||||
{
 | 
			
		||||
	print <<_HELP_;
 | 
			
		||||
Usage: $PROGNAME OPTIONS
 | 
			
		||||
A nagios plugin that connects to a Sybase database and checks free space.
 | 
			
		||||
 | 
			
		||||
Mandatory arguments to long options are mandatory for short options too.
 | 
			
		||||
  -U, --user		Username to connect to database.
 | 
			
		||||
  -P, --pass		Password to connect to database.
 | 
			
		||||
  -S, --dbsvr		Database server (as in the interfaces file).
 | 
			
		||||
  -D, --dbname		Database name to check.
 | 
			
		||||
  --config=FILE		Config file (see SECURITY below)
 | 
			
		||||
  --checktype=TYPE	Type of check to run (see TYPEs below)
 | 
			
		||||
  --explain		Explains how we calculated the free space.
 | 
			
		||||
  -w, --warning		Warning threshold, in percent (default 25)
 | 
			
		||||
  -c, --critical	Critical threshold, in percent (default 10)
 | 
			
		||||
  -t, --timeout		Timeout value, in seconds (default 30)
 | 
			
		||||
  -h, --help		This help message
 | 
			
		||||
  -V, --version		Version information ($VERSION)
 | 
			
		||||
 | 
			
		||||
Examples:
 | 
			
		||||
	$PROGNAME -U sa -P secret -S bigbox -D orders
 | 
			
		||||
	$PROGNAME --config=/secure/nagios-sybase.cfg --checktype=CONNECT
 | 
			
		||||
 | 
			
		||||
TYPEs
 | 
			
		||||
 There are two types of checks you can run:
 | 
			
		||||
 --checktype=CONNECT
 | 
			
		||||
    Checks just the connection to the database.
 | 
			
		||||
 --checktype=FREESPACE
 | 
			
		||||
    (Default) Checks both the connection to the database and the free space.
 | 
			
		||||
 | 
			
		||||
SECURITY - Using a config file
 | 
			
		||||
 Since a "ps ax" will reveal your database username and password, you can 
 | 
			
		||||
 instead specify them in a config file. Pass the config file with --config.
 | 
			
		||||
 The format of the file is:
 | 
			
		||||
   USER     value
 | 
			
		||||
   PASS     value
 | 
			
		||||
 You can also specify a DBSVR and DBNAME in the file. Comments (#) and blank
 | 
			
		||||
 lines are ignored. Use whitespace to separate argument and value.
 | 
			
		||||
_HELP_
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub explain
 | 
			
		||||
{
 | 
			
		||||
	return unless $explain;
 | 
			
		||||
 | 
			
		||||
	my $msg = shift;
 | 
			
		||||
	print "$msg\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Some wrappers..
 | 
			
		||||
 | 
			
		||||
# Returns code 0, OK
 | 
			
		||||
sub nok
 | 
			
		||||
{
 | 
			
		||||
	my $msg = shift;
 | 
			
		||||
	print "OK: $msg\n" if $msg;
 | 
			
		||||
 | 
			
		||||
	&disconnect;
 | 
			
		||||
	exit $ERRORS{OK};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Returns code 1, Warning
 | 
			
		||||
sub nwarn
 | 
			
		||||
{
 | 
			
		||||
	my $msg = shift;
 | 
			
		||||
	print "WARNING: $msg\n";
 | 
			
		||||
 | 
			
		||||
	&disconnect;
 | 
			
		||||
	exit $ERRORS{WARNING};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Returns code 2, Critical
 | 
			
		||||
sub ncrit
 | 
			
		||||
{
 | 
			
		||||
	my $msg = shift;
 | 
			
		||||
	print "CRITICAL: $msg\n";
 | 
			
		||||
 | 
			
		||||
	&disconnect;
 | 
			
		||||
	exit $ERRORS{CRITICAL};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Returns code 3, Unknown
 | 
			
		||||
sub nunk
 | 
			
		||||
{
 | 
			
		||||
	my $msg = shift;
 | 
			
		||||
	print "ERROR: $msg\n";
 | 
			
		||||
 | 
			
		||||
	&disconnect;
 | 
			
		||||
	exit $ERRORS{UNKNOWN};
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,6 +0,0 @@
 | 
			
		|||
/bowen-langley_plugins.tar.gz/1.2/Fri Mar  1 02:42:56 2002/-kb/Tr1_4_5
 | 
			
		||||
/check_bgp-1.0.tar.gz/1.2/Fri Mar  1 02:42:56 2002/-kb/Tr1_4_5
 | 
			
		||||
/check_radius.tar.gz/1.2/Fri Mar  1 02:42:56 2002/-kb/Tr1_4_5
 | 
			
		||||
/check_traffic-0.91b.tar.gz/1.1/Tue Feb  1 04:20:04 2005/-kb/Tr1_4_5
 | 
			
		||||
/fetchlog-0.94.tar.gz/1.1/Sun Feb  9 14:03:22 2003/-kb/Tr1_4_5
 | 
			
		||||
D
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
nagiosplug/contrib/tarballs
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
:ext:tonvoon@nagiosplug.cvs.sourceforge.net:/cvsroot/nagiosplug
 | 
			
		||||
| 
						 | 
				
			
			@ -1 +0,0 @@
 | 
			
		|||
Nr1_4_5
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue