- ติดตั้งระบบฐานข้อมูล Oracle 11g บน Windows XP
- ทดสอบและแก้ไข LISTENER
- ตรวจสอบการใช้งานฐานข้อมูลที่ติดตั้งสำเร็จแล้ว
function get_graph_title($local_graph_id) { global $config; include_once($config["library_path"] . "/addon_data_input_field.php"); $graph = db_fetch_row("select graph_local.host_id, graph_local.snmp_query_id, graph_local.snmp_index, graph_templates_graph.title from (graph_templates_graph,graph_local) where graph_templates_graph.local_graph_id=graph_local.id and graph_local.id=$local_graph_id"); if ((strstr($graph["title"], "|")) && (!empty($graph["host_id"]))) { $graph["title"] = substitute_data_input_field($graph["title"], $graph["host_id"], $local_graph_id); return expand_title($graph["host_id"], $graph["snmp_query_id"], $graph["snmp_index"], $graph["title"]); }else{ return $graph["title"]; } }
<? /* do NOT run this script through a web browser */ if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) { die("<br><strong>This script is only meant to run at the command line.</strong>"); } /* display No errors */ error_reporting(0); if (!isset($called_by_script_server)) { array_shift($_SERVER["argv"]); print call_user_func_array("ss_oracle_tbls", $_SERVER["argv"])."\n"; } function ss_oracle_tbls ($tnsnames, $sql_path, $username, $password,$tablespacename) { putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1"); putenv("TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin"); $ret = ''; $gdb_conn = ocilogon($username, $password,$tnsnames); $gdb_statement = OCIParse ($gdb_conn, "alter session set nls_date_format='MM/DD/YYYY HH24:MI:SS' "); OCIExecute ($gdb_statement); if (! OCIExecute($gdb_statement)){ return; } include $sql_path; $gdb_statement = OCIParse ($gdb_conn, $query); OCIExecute ($gdb_statement); while (OCIFetchInto ($gdb_statement, $row, OCI_RETURN_NULLS + OCI_ASSOC)) { reset($row); $tbls_current=$row['CURR']; $tbls_free=$row['FREE']; $tbls_total=$row['TOTAL']; $tbls_curr_percent=$row['CURRENT_PERCENT']; } OCIFreeStatement($gdb_statement); $ret .= 'current:'.$tbls_current.' current_percent:'.$tbls_curr_percent.' free:'.$tbls_free.' total:'.$tbls_total.' '; return trim($ret); } ?>
<? $query = " SELECT DISTINCT a.tablespace_name, (SUM (a.bytes) / 1024 / 1024 - ROUND (c.free / 1024 / 1024)) curr, ( SUM (DECODE (b.maxextend, NULL, a.bytes / 1024 / 1024, b.maxextend * (SELECT VALUE FROM v\$parameter WHERE name = 'db_block_size') / 1024 / 1024)) - (SUM (a.bytes) / 1024 / 1024 - ROUND (c.Free / 1024 / 1024))) free, SUM (DECODE (b.maxextend, NULL, a.bytes / 1024 / 1024, b.maxextend * (SELECT VALUE FROM v\$parameter WHERE name = 'db_block_size') / 1024 / 1024)) total, ROUND ( 100 * (SUM (a.bytes) / 1024 / 1024 - ROUND (c.free / 1024 / 1024)) / (SUM (DECODE (b.maxextend, NULL, a.bytes / 1024 / 1024, b.maxextend * (SELECT VALUE FROM v\$parameter WHERE name = 'db_block_size') / 1024 / 1024)))) current_percent FROM dba_data_files a, sys.filext$ b, ( SELECT d.tablespace_name, SUM (NVL (c.bytes, 0)) free FROM dba_tablespaces d, dba_free_space c WHERE d.tablespace_name = c.tablespace_name(+) GROUP BY d.tablespace_name) c WHERE a.file_id = b.file#(+) AND a.tablespace_name = c.tablespace_name AND a.tablespace_name = UPPER ('$tablespacename') GROUP BY a.tablespace_name, c.free / 1024 "; ?>
|host_description|/|input_tnsnames| - Tablespace - |input_tablespace_name|
|host_description| - Tablespace - |input_tnsnames| : |input_tablespace_name|
<? $query = " select round( (sum(decode(name,'free memory',bytes))/sum(bytes))*100 ,2) as free from v\$sgastat where pool = 'shared pool' "; ?>
<? /* do NOT run this script through a web browser */ if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) { die("<br><strong>This script is only meant to run at the command line.</strong>"); } /* display No errors */ error_reporting(0); if (!isset($called_by_script_server)) { array_shift($_SERVER["argv"]); print call_user_func_array("ss_oracle_query", $_SERVER["argv"])."\n"; } function ss_oracle_query ($tnsnames, $sql_path, $username, $password) { putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1"); putenv("TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin"); $ret = ''; $gdb_conn = ocilogon($username, $password,$tnsnames); $gdb_statement = OCIParse ($gdb_conn, "alter session set nls_date_format='MM/DD/YYYY HH24:MI:SS' "); OCIExecute ($gdb_statement); if (! OCIExecute($gdb_statement)){ return; } include $sql_path; $gdb_statement = OCIParse ($gdb_conn, $query); OCIExecute ($gdb_statement); while (OCIFetchInto ($gdb_statement, $row, OCI_RETURN_NULLS + OCI_ASSOC)) { reset($row); $shared_pool_free=$row['FREE']; } OCIFreeStatement($gdb_statement); $ret .= 'value:'.$shared_pool_free.' '; return trim($ret); } ?>
putenv("ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1"); putenv("TNS_ADMIN=/u01/app/oracle/product/11.2.0/db_1/network/admin");2 บรรทัดนี้ในไฟล์ ss_oracle_query.php ท่านจะต้องแก้ให้ตรงกับระบบที่ท่านใช้งานในการกำหนด Environment เพื่อให้ PHP OCI8 ใช้งานในการเชื่อมต่อไปยังฐานข้อมูล ORACLE