|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Test connection to databaseHi
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 |
|
|
Re: Test connection to databaseJack van Zanen wrote:
> 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. Across your network I assume. All internal or some db's are external? Don't forget about network overhead, and even more so if you're going out to the internet at some point. -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
|
|
Re: Test connection to databaseDatabases are located in several datacentres throughout the area/country and
we connect through dedicated lines not internet. I realize that there may be many factors to consider, I just would like to have the PHP experts have a look at my method/PHP code to check that this is fairly optimized Jack On 27/08/2008, Chris <dmagick@...> wrote: > > Jack van Zanen wrote: > >> 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. >> > > Across your network I assume. All internal or some db's are external? Don't > forget about network overhead, and even more so if you're going out to the > internet at some point. > > -- > Postgresql & php tutorials > http://www.designmagick.com/ > > -- J.A. van Zanen |
|
|
Re: Test connection to databaseJack van Zanen wrote:
> Databases are located in several datacentres throughout the area/country > and we connect through dedicated lines not internet. > > I realize that there may be many factors to consider, I just would like > to have the PHP experts have a look at my method/PHP code to check that > this is fairly optimized Looks ok. You can also use something like nagios or monit (or others) to do all of this for you.. and they also monitor other services (eg http, ftp, also disk-space, load etc etc). Another avenue to check out anyway :) -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php |
| Free Forum Powered by Nabble | Forum Help |