Test connection to database
am 27.08.2008 07:26:25 von Jack van Zanen------=_Part_19512_12653867.1219814785138
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hi
I have written a little program that cycles through a list of databases and
checks conectivity. it writes the status of this to a table
now to check all 143 databases it takes about 50 seconds and I was wondering
if this sounds about right to you guys.
//Include the required libraries and variables
include_once ("adodb5/adodb.inc.php");
include_once ("ola_ini.php");
//Setup the connection to the database to be updated
$db = NewADOConnection('oci8');
$db->Connect(false, $ola_usr, $ola_pwd, $ola_dbs);
//Get the current status of the database (UP, DOWN or CHECKING)
$stmt = $db->Prepare("select nvl(status,'NEW') from sla_monitoring where
upper(database)=upper(:dbs)");
$rs=$db->Execute($stmt, array('dbs' => $argv[1]));
//Logon check for ORACLE (OCI)
if($argv[2]=='Oracle')
{
if($rs->fields[0] == 'CHECKING') //If current status is CHECKING than the
previous check has not completed. Find out why!!!
{
echo "exiting";
exit;
}
else
{
$stmt = $db->Prepare("update sla_monitoring set status=:status,
last_check=to_date(:checkdate,'ddmmyyyyhh24miss') where
upper(database)=upper(:dbs)");
$rs=$db->Execute($stmt, array('dbs' =>
$argv[1],'status'=>'CHECKING','checkdate'=>$argv[3])); //set status to
CHECKING for current database before proceding
if($db->Connect(false, $ora_usr, $ora_pwd,$argv[1] ))
{
$db->Execute($stmt, array('dbs' => $argv[1],'status'=>'UP'));
}
else
{
$rs=$db->Execute($stmt, array('dbs' => $argv[1],'status'=>'DOWN'));
}
}
}
?>
this script gets called from a windows batch file to try and mimic a bit of
multithreading
start php-win check_connect.php B2B Oracle 27082008145929 eamdasoplp01
start php-win check_connect.php B2B Oracle 27082008145929 opal
start php-win check_connect.php BOCMSDEV Oracle 27082008145929
eawalsbop02
start php-win check_connect.php BOCMSDR Oracle 27082008145929 eawalsbop02
start php-win check_connect.php BOCMSP Oracle 27082008145929 eahobsorap01
..........
.........
.........
better performance.
I realize I will have some contention on my table that can maybe be
addressed, but for now let's focus on the PHP/BAT process
Thanks
Jack
------=_Part_19512_12653867.1219814785138--