[Nagiosplug-devel] Nagios SQLPlus query monitor?

Helder Oliveira hrpoliveira at gmail.com
Fri Jan 15 16:34:53 CET 2010


here is the code:

CHange whatever you need to.

and sorry for the delay

#!/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 ;


On Fri, Jan 15, 2010 at 2:17 PM, Christopher McAtackney
<cristoir at gmail.com> wrote:
> 2010/1/14 Litwin, Matthew <mlitwin at stubhub.com>:
>>
>> On Jan 12, 2010, at 9:37 PM, Joerg Linge wrote:
>>
>>> Am 12.01.10 22:07, schrieb Litwin, Matthew:
>>>> Hello,
>>>>
>>>> Similar to the check_oracle plugin I need a nagios plugin that will SQL from say a secondary text file and then report on the lines that it results. Ideally it would return the number of lines as output where WARN and CRITICAL conditions could be checked against, but also the actual rows would be listed as perfdata. Does any plugin like this exist?
>>>>
>>>> I wrote a plugin that will use sqlplus to return a line count and report on those values in Perl, but honestly my scripting capabilities are pretty weak. If you are a Perl guy and see an elegant way of doing this, any guidance on this would be very helpful.
>>>
>>> check_oracle_health can do this.
>>>
>>> http://labs.consol.de/lang/de/nagios/check_oracle_health/
>>>
>>> nagios$ check_oracle_health --mode sql \
>>>  --name 'select 200,300,1000 from dual' \
>>>  --name2 'kaspar melchior balthasar' \
>>>  --warning 180 --critical 500
>>>
>>> WARNING - kaspar melchior balthasar: 200 300 1000 |
>>> 'kaspar'=200;180;500 'melchior'=300;; 'balthasar'=1000;;
>>
>> Thank you, I will keep looking for how I can use the SQL mode for check_oracle_health to see how I can do this. Unfortunately the developers website doesn't have an english version. :-(
>>
>> Thanks,
>> Matthew Litwin
>> mlitwin at stubhub.com
>> 415.222.8475
>
> Matthew,
>
> Download the plugin and use the --help option - it presents all the
> info in English. Also, the developer of the plugin, Gerhard, is very
> helpful and will respond to your help requests if you mail him.
>
> Cheers,
> Chris
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for Conference
> attendees to learn about information security's most important issues through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________________
> Nagios Plugin Development Mailing List Nagiosplug-devel at lists.sourceforge.net
> Unsubscribe at https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
> ::: Please include plugins version (-v) and OS when reporting any issue.
> ::: Messages without supporting info will risk being sent to /dev/null
>




More information about the Devel mailing list