Test connection to database

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

 



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.


<?php

//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

<snip>

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
.........
........
........

</snip
Is this the best way to do this or are there any other ways that may lead to
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

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux