[Date Prev]   [Date Next] [Thread Prev]   [Thread Next] [Date Index]   [Thread Index]

 

     Re: SQL Monitors

I don't know about some of the other PERL modules, but bgpmon is pretty
minimal .. just rip out the parsing, etc.

Here's some basic code I usually re-use to make a connection to the DB.
Depending on what you monitor, you'll need to modify it...if you just want
to monitor SQL's state (connection refused, etc) thought it might be of
help...

use DBI;
use DBD::Oracle;
use strict;
use vars qw { %CONFIG $DBH $STH $RET $CMD };

$CONFIG{'USER'} = "USERNAME";
$CONFIG{'PASS'} = "PASSWORD";

$DBH = DBI->connect("dbi:Oracle:", $CONFIG{'USER'}, $CONFIG{'PASS'})
  || return (-1, "$0: connect: $DBI::errstr");

print "Connected.\n";

$STH=$DBH->prepare("SELECT COUNT(*) FROM SOME_TABLE");
$RET=$STH->execute;
if (! $RET) { 
  return (-2, "$0: select: $DBI::errstr");
}
$RET = $STH->fetchrow_arrayref;
($RET) = @$RET;
$STH->finish;
$DBH->disconnect;
return $RET;

On Fri, 28 May 1999, Nathan Clemons [Staff] wrote:

> Does anyone have prepared SQL monitors, or can anyone point me to the most
> minimal Perl based monitor in NOCOL that I can look at to code my own DBI
> && DBD based Perl SQL monitor?
> 
> Thanks,
> Nathan.
> 
> _________________________________________________________________________
> Nathan Clemons
> Associate Systems Engineer
> WinStar iCi
> Broadband Services		
> Great Woods Office Park 800 South Main St. Mansfield, MA  02048
> _________________________________________________________________________  
> nclemons@winstar.com  	www.winstar.com 	(v) 800-234-0002 ext.1109
>    nathan@ici.net	  www.ici.net		(f) 508-261-0430
> 
> 

Thank you,

Jonathan A. Zdziarski
Sr. Systems Administrator
Netrail, inc. 
888.NET.RAIL x240