[Nagiosplug-devel] Nagios SQLPlus query monitor?

Litwin, Matthew mlitwin at stubhub.com
Fri Jan 15 20:23:39 CET 2010


Thank you so much! This is perfect!

On Jan 15, 2010, at 7:34 AM, Helder Oliveira wrote:

#!/usr/bin/perl -w
require 5.004;
use strict;
use POSIX;
use Getopt::Long;
use vars qw($opt_V $opt_h $PROGNAME);
use lib "/srv/nagios/libexec" ;
use utils qw($TIMEOUT %ERRORS &print_revision &support);

# USAGE:
# args: <tsname> [warning_level] [critical_level]
# defaults:
#  tsname is mandatory
#  warning_level is 80
#  critical_level is 90

not(defined($ARGV[0])) and print "rtfm!\n" and exit(-1);
my $db = $ARGV[0];
my $warn = $ARGV[1] || 2 ;

$PROGNAME="check_oracle_instance_uptime";

$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';


my $ora = "/usr/bin/sudo /bin/su -c \"sqlplus -L user/pass\@$db
\@sql/instance_uptime.sql\" - oracle";
open(ORA, "$ora|") or die "Can't run sqlplus: $!\n";
my $ok = 0 ;
my $warning = 0 ;
my $critical = 0 ;
my $str = "";
my $tmp = "";
my $ret = 0 ;
while(my $item = <ORA>) {
$_ = $item ;
if ( /^(\d{1,3})$/ ) {
if ( $1 <= $warn ) {
print "Database Startup at $1 Days\n";
$ret = 1 ;
} else {
print "Database Startup at $1 days\n";
$ret = 0 ;
}
}
}
close(ORA);
exit $ret ;

Thanks,
Matthew Litwin
mlitwin at stubhub.com<mailto:mlitwin at stubhub.com>
415.222.8475





More information about the Devel mailing list