A
download check_ora_table_space.pl
Language: Perl
LOC: 52
Project Info
pkg-nagios
Server: Debian-SVN
Type: svn
...ugins\tags\1.4.2‑1\contrib\
   check_adptraid.sh
   check_apache.pl
   check_apc_ups.pl
   check_appletalk.pl
   check_arping.pl
   check_asterisk.pl
   check_axis.sh
   check_backup.pl
   check_bgpstate.pl
   check_breeze.pl
   check_cluster.c
   check_cluster2.c
   check_compaq_insight.pl
   check_cpqarray.c
   check_digitemp.pl
   check_disk_snmp.pl
   check_dlswcircuit.pl
   check_dns_random.pl
   check_email_loop.pl
   check_flexlm.pl
   check_hltherm.c
   check_hprsc.pl
   ...th-client-certificate.c
   check_hw.sh
   ...k_ica_master_browser.pl
   ...a_metaframe_pub_apps.pl
   ...program_neigbourhood.pl
   check_inodes-freebsd.pl
   check_inodes.pl
   check_ipxping.c
   check_javaproc.pl
   check_joy.sh
   check_linux_raid.pl
   check_lmmon.pl
   check_log2.pl
   check_lotus.pl
   check_maxchannels.pl
   check_maxwanstate.pl
   check_mem.pl
   check_ms_spooler.pl
   check_mssql.sh
   check_nagios.pl
   check_nagios_db.pl
   check_nagios_db_pg.pl
   check_netapp.pl
   check_nmap.py
   check_ora_table_space.pl
   check_oracle_instance.pl
   check_pcpmetric.py
   check_qmailq.pl
   check_rbl.c
   ...remote_nagios_status.pl
   check_rrd_data.pl
   check_sap.sh
   check_smart.pl
   check_smb.sh
   check_snmp_disk_monitor.pl
   check_snmp_printer.pl
   ...snmp_process_monitor.pl
   check_snmp_procs.pl
   check_sockets.pl
   check_timeout.c
   ...traceroute-pure_perl.pl
   check_traceroute.pl
   check_uptime.c
   check_vcs.pl
   check_wave.pl
   check_wins.pl
   checkciscotemp.pl
   mrtgext.pl
   nagios_sendim.pl
   packet_utils.pm
   restrict.pl
   sched_downtime.pl
   urlize.pl
   utils.py

#!/usr/bin/perl
#
# Program check_ora_table_space
# Written by: Erwan Arzur (erwan@netvalue.com)
# License: GPL
#
# Last Modified: $Date: 2002/02/28 06:42:54 $
# Revisiin: $Revision: 1.1.1.1 $
#
# "check_ora_table_space.pl" plugin to check the state of Oracle 
# table spaces. Scarce documentation.
#
# you need DBD-Oracle-1.03.tar.gz and DBI-1.13.tar.gz from CPAN.org as
# well as some Oracle client stuff to use it.
#
# The SQL request comes from www.dbasupport.com
#

use DBI;
$ENV{"ORACLE_HOME"}="/intranet/apps/oracle";

my $host = shift || &usage ("no host specified");
my $sid  = shift || &usage ("no sid specified");
my $port = shift || &usage ("no port specified");
my $dbuser = shift || &usage ("no user specified");
my $dbpass = shift || &usage ("no password specified");
my $tablespace = shift || &usage ("no table space  specified");

my $alertpct = int(shift) || &usage ("no warning state percentage specified");
my $critpct =  int(shift) || &usage ("no critical state percentage specified");

my $dbh = DBI->connect(	"dbi:Oracle:host=$host;port=$port;sid=$sid", $dbuser, $dbpass, { PrintError => 0, AutoCommit => 1, RaiseError => 0 } )
	|| &error ("cannot connect to $dbname: $DBI::errstr\n");

#$sth = $dbh->prepare(q{SELECT tablespace_name, SUM(BYTES)/1024/1024 FreeSpace FROM dba_free_space group by tablespace_name}) 
my $exit_code = -1;
$sth = $dbh->prepare(<<EOF
select a.TABLESPACE_NAME, a.total,nvl(b.used,0) USED, 
nvl((b.used/a.total)*100,0) PCT_USED 
from (select TABLESPACE_NAME, sum(bytes)/(1024*1024) total 
from sys.dba_data_files group by TABLESPACE_NAME) a, 
(select TABLESPACE_NAME,bytes/(1024*1024) used from sys.SM\$TS_USED) b 
where  a.TABLESPACE_NAME='$tablespace' and 
 a.TABLESPACE_NAME=b.TABLESPACE_NAME(+)
EOF
)
	|| &error("Cannot prepare request : $DBI::errstr\n");
$sth->execute 
	|| &error("Cannot execute request : $DBI::errstr\n");

while (($tbname, $total, $used, $pct_used) = $sth->fetchrow)
{
	$pct_used=int($pct_used);
	print STDOUT "size: " . $total . " MB Used:" . int($used) . " MB (" . int($pct_used) . "%)\n";
	#print "table space $answer\n";
	if ($pct_used > $alertpct) {
		if ($pct_used > $critpct) {
			$exit_code = 2
		} else {
			$exit_code = 1;
		}
	} else {
		$exit_code = 0;	
	}
}

$rc = $dbh->disconnect 
	|| &error ("Cannot disconnect from database : $dbh->errstr\n");

exit ($exit_code);

sub usage {
	print "@_\n" if @_;
	print "usage : check_ora_table_space.pl <host> <sid> <port> <user> <passwd> <tablespace> <pctwarn> <pctcrit>\n";
	exit (-1);
}

sub error {
	print "@_\n" if @_;
	exit (2);
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us