Subject | MON$DATABASE test |
---|---|
Author | lee_domain |
Post date | 2007-11-02T04:47:40Z |
Hi, all
I found that wether or not the database is connected by any other
client(s), some parts of the result from the MON$DATABASE is always
the same.
<?php
echo "
Following is a PHP script to test the Firebird <br>
System Monitoring Tables with the new SQL commands in FB2.1++ <br>
Folowing functions require that the database is on the connection <br>
Here is it, test it, and expecting your reply. <br> " ;
// Global Variables
// set this var to 1 will set a silent mode
$tmpsilent = 0;
// make sure it will not generate the SAME time
sleep(1);
$time_ext = date("Y-m-d-H-i-s");
if ( $tmpsilent == 0)
echo "<br> $time_ext.<br>";
// 1) connect to a database server
$srv_db = 'localhost:/home/litaoman/employee.fdb';
$usrname = 'sysdba';
$pswd = 'masterkey';
// get and report connection result
$conn = fbird_connect($srv_db, $usrname, $pswd);
if (!$conn )
{
echo "monitor table connection failed <br>";
exit;
}
echo "monitor table connection OK <br>";
// get connected database information
$sql = "select * from MON\$DATABASE";
if ( $tmpsilent == 0)
echo $sql."<br>";
// process the query
$res = fbird_query($conn, $sql);
while ( $row = fbird_fetch_object($res) )
{
$mon_dbnm = "MON\$DATABASE_NAME"; //(database pathname or alias)
$mondbnm = trim($row->$mon_dbnm);
echo "<br> MON\$DATABASE_NAME: ".$mondbnm."<br>";
$mon_psz = "MON\$PAGE_SIZE"; // (page size)
$monpsz= trim($row->$mon_psz);
echo "MON\$PAGE_SIZE: ".$monpsz."<br>";
$mon_odsa = "MON\$ODS_MAJOR"; // (major ODS version)
$monodsa = trim($row->$mon_odsa);
echo "MON\$ODS_MAJOR: ".$monodsa."<br>";
$mon_odsr = "MON\$ODS_MINOR"; // (minor ODS version)
$monodsr = trim($row->$mon_odsr);
echo "MON\$ODS_MINOR: ".$monodsr."<br>";
$mon_oit = "MON\$OLDEST_TRANSACTION"; // (OIT number)
$monoit = trim($row->$mon_oit);
echo "MON\$OLDEST_TRANSACTION: ".$monoit."<br>";
$mon_oat = "MON\$OLDEST_ACTIVE"; // (OAT number)
$monoat = trim($row->$mon_oat);
echo "MON\$OLDEST_ACTIVE: ".$monoat."<br>";
$mon_ost = "MON\$OLDEST_SNAPSHOT"; // (OST number)
$monost = trim($row->$mon_ost);
echo "MON\$OLDEST_SNAPSHOT: ".$monost."<br>";
$mon_nit = "MON\$NEXT_TRANSACTION"; // (next transaction number)
$monnit = trim($row->$mon_nit);
echo "MON\$NEXT_TRANSACTION: ".$monnit."<br>";
$mon_buf = "MON\$PAGE_BUFFERS"; // (number of pages allocated in the
cache)
$monbuf = trim($row->$mon_buf);
echo "MON\$PAGE_BUFFERS: ".$monbuf."<br>";
$mon_dlt = "MON\$SQL_DIALECT"; // (SQL dialect of the database)
$mondlt = trim($row->$mon_dlt);
echo "MON\$SQL_DIALECT: ".$mondlt."<br>";
$mon_sht = "MON\$SHUTDOWN_MODE"; // (current shutdown mode)
// 0: online
// 1: multi-user shutdown
// 2: single-user shutdown
// 3: full shutdown
$monsht = trim($row->$mon_sht);
echo "MON\$SHUTDOWN_MODE: ".$monsht."<br>";
$mon_swp = "MON\$SWEEP_INTERVAL"; // (sweep interval)
$monswp = trim($row->$mon_swp);
echo "MON\$SWEEP_INTERVAL: ".$monswp."<br>";
$mon_red = "MON\$READ_ONLY"; // (read-only flag)
$monred = trim($row->$mon_red);
echo "MON\$READ_ONLY: ".$monred."<br>";
$mon_swt = "MON\$FORCED_WRITES"; // (sync writes flag)
$monswt = trim($row->$mon_swt);
echo "MON\$FORCED_WRITES: ".$monswt."<br>";
$mon_spc = "MON\$RESERVE_SPACE"; // (reserve space flag)
$monspc = trim($row->$mon_spc);
echo "MON\$RESERVE_SPACE: ".$monspc."<br>";
$mon_cdt = "MON\$CREATION_DATE"; // (creation date/time)
$moncdt = trim($row->$mon_cdt);
echo "MON\$CREATION_DATE: ".$moncdt."<br>";
$mon_pgs = "MON\$PAGES"; // (number of pages allocated on disk)
$monpgs = trim($row->$mon_pgs);
echo "MON\$PAGES: ".$monpgs."<br>";
$mon_bst = "MON\$BACKUP_STATE"; // (current physical backup state)
// 0: normal
// 1: stalled
// 2: merge
$monbst = trim($row->$mon_bst);
echo "MON\$BACKUP_STATE: ".$monbst."<br>";
$mon_sid = "MON\$STAT_ID"; // (statistics ID)
$monsid = trim($row->$mon_sid);
echo "MON\$STAT_ID: ".$monsid."<br>";
}
// relaese the results
fbird_free_result($res);
// close the connected database, and report result
$closedb = fbird_close($conn);
if ($closedb == 1)
{
echo "<br> disconnect from database OK ! <br>";
} else {
echo "<br> disconnect from database failed ! <br>";
}
?>
Yours
O'Li
I found that wether or not the database is connected by any other
client(s), some parts of the result from the MON$DATABASE is always
the same.
<?php
echo "
Following is a PHP script to test the Firebird <br>
System Monitoring Tables with the new SQL commands in FB2.1++ <br>
Folowing functions require that the database is on the connection <br>
Here is it, test it, and expecting your reply. <br> " ;
// Global Variables
// set this var to 1 will set a silent mode
$tmpsilent = 0;
// make sure it will not generate the SAME time
sleep(1);
$time_ext = date("Y-m-d-H-i-s");
if ( $tmpsilent == 0)
echo "<br> $time_ext.<br>";
// 1) connect to a database server
$srv_db = 'localhost:/home/litaoman/employee.fdb';
$usrname = 'sysdba';
$pswd = 'masterkey';
// get and report connection result
$conn = fbird_connect($srv_db, $usrname, $pswd);
if (!$conn )
{
echo "monitor table connection failed <br>";
exit;
}
echo "monitor table connection OK <br>";
// get connected database information
$sql = "select * from MON\$DATABASE";
if ( $tmpsilent == 0)
echo $sql."<br>";
// process the query
$res = fbird_query($conn, $sql);
while ( $row = fbird_fetch_object($res) )
{
$mon_dbnm = "MON\$DATABASE_NAME"; //(database pathname or alias)
$mondbnm = trim($row->$mon_dbnm);
echo "<br> MON\$DATABASE_NAME: ".$mondbnm."<br>";
$mon_psz = "MON\$PAGE_SIZE"; // (page size)
$monpsz= trim($row->$mon_psz);
echo "MON\$PAGE_SIZE: ".$monpsz."<br>";
$mon_odsa = "MON\$ODS_MAJOR"; // (major ODS version)
$monodsa = trim($row->$mon_odsa);
echo "MON\$ODS_MAJOR: ".$monodsa."<br>";
$mon_odsr = "MON\$ODS_MINOR"; // (minor ODS version)
$monodsr = trim($row->$mon_odsr);
echo "MON\$ODS_MINOR: ".$monodsr."<br>";
$mon_oit = "MON\$OLDEST_TRANSACTION"; // (OIT number)
$monoit = trim($row->$mon_oit);
echo "MON\$OLDEST_TRANSACTION: ".$monoit."<br>";
$mon_oat = "MON\$OLDEST_ACTIVE"; // (OAT number)
$monoat = trim($row->$mon_oat);
echo "MON\$OLDEST_ACTIVE: ".$monoat."<br>";
$mon_ost = "MON\$OLDEST_SNAPSHOT"; // (OST number)
$monost = trim($row->$mon_ost);
echo "MON\$OLDEST_SNAPSHOT: ".$monost."<br>";
$mon_nit = "MON\$NEXT_TRANSACTION"; // (next transaction number)
$monnit = trim($row->$mon_nit);
echo "MON\$NEXT_TRANSACTION: ".$monnit."<br>";
$mon_buf = "MON\$PAGE_BUFFERS"; // (number of pages allocated in the
cache)
$monbuf = trim($row->$mon_buf);
echo "MON\$PAGE_BUFFERS: ".$monbuf."<br>";
$mon_dlt = "MON\$SQL_DIALECT"; // (SQL dialect of the database)
$mondlt = trim($row->$mon_dlt);
echo "MON\$SQL_DIALECT: ".$mondlt."<br>";
$mon_sht = "MON\$SHUTDOWN_MODE"; // (current shutdown mode)
// 0: online
// 1: multi-user shutdown
// 2: single-user shutdown
// 3: full shutdown
$monsht = trim($row->$mon_sht);
echo "MON\$SHUTDOWN_MODE: ".$monsht."<br>";
$mon_swp = "MON\$SWEEP_INTERVAL"; // (sweep interval)
$monswp = trim($row->$mon_swp);
echo "MON\$SWEEP_INTERVAL: ".$monswp."<br>";
$mon_red = "MON\$READ_ONLY"; // (read-only flag)
$monred = trim($row->$mon_red);
echo "MON\$READ_ONLY: ".$monred."<br>";
$mon_swt = "MON\$FORCED_WRITES"; // (sync writes flag)
$monswt = trim($row->$mon_swt);
echo "MON\$FORCED_WRITES: ".$monswt."<br>";
$mon_spc = "MON\$RESERVE_SPACE"; // (reserve space flag)
$monspc = trim($row->$mon_spc);
echo "MON\$RESERVE_SPACE: ".$monspc."<br>";
$mon_cdt = "MON\$CREATION_DATE"; // (creation date/time)
$moncdt = trim($row->$mon_cdt);
echo "MON\$CREATION_DATE: ".$moncdt."<br>";
$mon_pgs = "MON\$PAGES"; // (number of pages allocated on disk)
$monpgs = trim($row->$mon_pgs);
echo "MON\$PAGES: ".$monpgs."<br>";
$mon_bst = "MON\$BACKUP_STATE"; // (current physical backup state)
// 0: normal
// 1: stalled
// 2: merge
$monbst = trim($row->$mon_bst);
echo "MON\$BACKUP_STATE: ".$monbst."<br>";
$mon_sid = "MON\$STAT_ID"; // (statistics ID)
$monsid = trim($row->$mon_sid);
echo "MON\$STAT_ID: ".$monsid."<br>";
}
// relaese the results
fbird_free_result($res);
// close the connected database, and report result
$closedb = fbird_close($conn);
if ($closedb == 1)
{
echo "<br> disconnect from database OK ! <br>";
} else {
echo "<br> disconnect from database failed ! <br>";
}
?>
Yours
O'Li