function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     $sql = "select t.* from {$this->report_monitor_v1} t where v1=:v1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['v1']);
     $oci_error = _ociexecute($stmt);
     $this->row_config = array();
     ocifetchinto($stmt, $this->row_config, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $sql = "select t.*,decode(as_name,null,v1,as_name) as_name1 from {$this->report_monitor_v1} t\n        order by decode(as_name,null,v1,as_name)  ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $this->v1_config_group = $this->v1_config = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $v1_config_group[$_row['GROUP_NAME_1']][$_row['GROUP_NAME_2']][$_row['GROUP_NAME']][] = $_row;
         if ($_REQUEST['v1'] == $_row['V1']) {
             $this->v1_config_act = $_row;
         }
     }
     $this->v1_config = $v1_config_group[$this->row_config['GROUP_NAME_1']][$this->row_config['GROUP_NAME_2']][$this->row_config['GROUP_NAME']];
     $sql = "select * from {$this->report_monitor_config} where v1=:v1 order by orderby ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['v1']);
     $oci_error = _ociexecute($stmt);
     $this->all = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $_row['V2_CONFIG_OTHER'] = unserialize($_row['V2_CONFIG_OTHER']);
         $this->all[] = $_row;
     }
     include PHPAPM_PATH . "./project_tpl/report_monitor_config.html";
 }
 function _initialize()
 {
     #每小时执行一次
     if (date('i') != 30) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     $sql = "select * from {$this->report_monitor_config} order by v1, orderby,v2 ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $this->all = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $this->all[$_row['V1']][] = $_row;
     }
     //排序更新初始化
     foreach ($this->all as $k => $v) {
         foreach ($v as $kk => $vv) {
             $sql = "update  {$this->report_monitor_config}  set orderby=:orderby where v1=:v1 and v2=:v2  ";
             $stmt = _ociparse($conn_db, $sql);
             //每次都独立提交,所以这样绑定(相同变量$k,$v)没问题
             _ocibindbyname($stmt, ':v1', $vv['V1']);
             _ocibindbyname($stmt, ':v2', $vv['V2']);
             _ocibindbyname($stmt, ':orderby', intval($kk + 1));
             $oci_error = _ociexecute($stmt);
         }
     }
     echo 'ok';
 }
 function _initialize()
 {
     #每小时执行一次
     if (date('i') != 30) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     //获取V1级别的评分要求
     $_row_infos = array();
     $sql = "select * from {$this->report_monitor_v1} t where pinfen_rule is not null ";
     $stmt_list = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt_list);
     $_row = array();
     while (ocifetchinto($stmt_list, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $_row = unserialize($_row['PINFEN_RULE']);
         if ($_row['pinfen_name'] && $_row['koufen_name'] && $_row['base_num'] && $_row['just_rule'] && $_row['pinfen_step'] && $_row['rule_num']) {
             $_row_infos[] = $_row;
         }
     }
     //获取V2级别的评分要求
     $sql = "select * from {$this->report_monitor_config} t where pinfen_rule is not null ";
     $stmt_list = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt_list);
     $_row = array();
     while (ocifetchinto($stmt_list, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $_row = unserialize($_row['PINFEN_RULE']);
         if ($_row['pinfen_name'] && $_row['koufen_name'] && $_row['base_num'] && $_row['just_rule'] && $_row['pinfen_step'] && $_row['rule_num']) {
             $_row_infos[] = $_row;
         }
     }
     print_r($_row_infos);
     foreach ($_row_infos as $_row_info) {
         if ($_row_info['v2']) {
             if ($_row_info['just_rule'] == '>') {
                 $sql = "select   case  when nvl(t.fun_count,0) > :base_num then  - round((nvl(t.fun_count,0) - :base_num) / :pinfen_step)  else  0  end as num from {$this->report_monitor_date} t where v1 = :v1  and v2 = :v2  and cal_date = trunc(sysdate) ";
             } else {
                 $sql = "select t.fun_count, case  when nvl(t.fun_count,0) < :base_num then  - round((:base_num - nvl(t.fun_count,0)) / :pinfen_step)  else  0  end as num from {$this->report_monitor_date} t where v1 = :v1   and v2 = :v2  and cal_date = trunc(sysdate) ";
             }
         } else {
             if ($_row_info['just_rule'] == '>') {
                 $sql = "select  case  when sum(nvl(t.fun_count,0)) > :base_num then  - round((  sum(nvl(t.fun_count,0)) - :base_num) / :pinfen_step)  else  0  end as num from {$this->report_monitor_date} t where v1 = :v1    and cal_date = trunc(sysdate) ";
             } else {
                 $sql = "select  case  when  sum(nvl(t.fun_count,0)) < :base_num then  - round((:base_num -  sum(nvl(t.fun_count,0)) ) / :pinfen_step)  else  0  end as num from {$this->report_monitor_date} t where v1 = :v1     and cal_date = trunc(sysdate) ";
             }
         }
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':base_num', $_row_info['base_num']);
         _ocibindbyname($stmt, ':pinfen_step', $_row_info['pinfen_step']);
         _ocibindbyname($stmt, ':v1', $_row_info['v1']);
         if ($_row_info['v2']) {
             _ocibindbyname($stmt, ':v2', $_row_info['v2']);
         }
         $oci_error = _ociexecute($stmt);
         print_r($oci_error);
         $_row_num = array();
         ocifetchinto($stmt, $_row_num, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
         _status($_row_num['NUM'], $_row_info['pinfen_name'], $_row_info['koufen_name'], $_row_info['v1'] . "@" . $_row_info['v2']);
         print_r($_row_num);
     }
 }
Example #4
0
 function insert_id($table)
 {
     $sql = "SELECT max(id) ID FROM {$table}";
     $query = ociparse($this->conn, $sql);
     ociexecute($query);
     ocifetchinto($query, $row, OCI_BOTH);
     return $row[ID];
 }
 function &_fetch()
 {
     if (ocifetchinto($this->_idResult, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
         return (object) $row;
     } else {
         return false;
     }
 }
 function fetchTo($offset)
 {
     if ($offset > 1) {
         for ($i = 1; $i < $offset - 1; $i++) {
             if (!ocifetchinto($this->_idResult, $row, OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS)) {
                 break;
             }
         }
     }
 }
Example #7
0
/**
 *  db_query() - Query the database
 *
 *  NOTE - the OCI version of this may be somewhat inefficient
 *  for large result sets (hundreds or thousands of rows selected)
 *  However - most queries are returning 25-50 rows
 *
 *  @param		string	SQL statement
 *  @param		int		How many rows do you want returned
 *  @param		int		Of matching rows, return only rows starting here
 */
function db_query($qstring, $limit = '-1', $offset = 0)
{
    global $QUERY_COUNT, $sys_db_results, $sys_db_row_pointer, $sys_db_oci_commit_mode;
    $QUERY_COUNT++;
    $stmt = @ociparse($gfconn, $qstring);
    if (!$stmt) {
        return 0;
    } else {
        if ($limit > 0) {
            if (!$offset || $offset < 0) {
                $offset = 0;
            }
        }
        $res = @ociexecute($stmt, $sys_db_oci_commit_mode);
        if (!$res) {
            return 0;
        } else {
            //if offset, seek to starting point
            //potentially expensive if large offset
            //however there is no data_seek feature AFAICT
            $more_data = true;
            if ($offset > 0) {
                for ($i = 0; $i < $offset; $i++) {
                    //burn them off
                    @ocifetchinto($res, $x);
                    if (!$x[1]) {
                        //if no data be returned
                        //get out of loop
                        $more_data = false;
                        break;
                    }
                }
            }
            $i = 0;
            while ($more_data) {
                $i++;
                @ocifetchinto($res, $x, 'OCI_ASSOC+OCI_RETURN_NULLS+OCI_RETURN_LOBS');
                $sys_db_results[$res][$i - 1] = $x;
                //see if data is being returned && we are
                //still within the requested $limit
                if (count($x) < 1 || $limit > 0 && $i >= $limit) {
                    $more_data = false;
                }
            }
            $sys_db_row_pointer[$res] = 0;
            return $res;
        }
    }
}
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     if (!isset($_GET['NO_COUNT']) && !isset($_GET['DATA_UNITS']) && !isset($_GET['API_ID'])) {
         header("location:{$_SERVER['HTTP_REFERER']}");
         die;
     }
     $conn_db = _ocilogon($this->db);
     $sql = "select * from {$this->report_monitor_config} where id=:id ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':id', $_GET['id']);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $v2_config_other = unserialize($_row['V2_CONFIG_OTHER']);
     //修改是否参与
     if (isset($_GET['NO_COUNT'])) {
         $v2_config_other['NO_COUNT'] = $_GET['NO_COUNT'] == 'true' ? true : false;
     }
     //修改数据单位
     if (isset($_GET['DATA_UNITS'])) {
         if ($_GET['DATA_UNITS'] == 'capacity') {
             $v2_config_other['DATA_UNITS'] = 'capacity';
         } elseif ($_GET['DATA_UNITS'] == 'digital') {
             unset($v2_config_other['DATA_UNITS']);
         }
     }
     //修改对应api id
     if (isset($_GET['API_ID'])) {
         if (is_numeric($_GET['API_ID'])) {
             $v2_config_other['API_ID'] = $_GET['API_ID'];
         }
     }
     $v2_config_other = serialize($v2_config_other);
     $sql = "update {$this->report_monitor_config} set v2_config_other=:v2_config_other where id=:id ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v2_config_other', $v2_config_other);
     _ocibindbyname($stmt, ':id', $_GET['id']);
     $oci_error = _ociexecute($stmt);
     if (!$v2_config_other['API_ID']) {
         header("location:{$_SERVER['HTTP_REFERER']}");
     }
     die;
 }
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     $sql = "select * from {$this->report_monitor_config} where id=:id ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':id', $_POST['id']);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $sql = "update {$this->report_monitor_config} set as_name=:as_name where v2=:v2  ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':as_name', $_POST['as_name']);
     _ocibindbyname($stmt, ':v2', $_row['V2']);
     $oci_error = _ociexecute($stmt);
 }
Example #10
0
 function fetchArray($r = 0, $t = 0)
 {
     if (!$r) {
         $r = $this->lastResult;
     }
     if (!$t) {
         $t = OCI_ASSOC + OCI_RETURN_NULLS + OCI_RETURN_LOBS;
     }
     $res = ocifetchinto($r, $temp, $t);
     if (is_array($temp)) {
         while (list($k, $v) = each($temp)) {
             $x = strtolower($k);
             $row[$x] = $v;
         }
     } else {
         $row = 0;
     }
     return $row;
 }
 function _initialize()
 {
     $conn_db = _ocilogon($this->db);
     $this->pageObj = new page(10000, 100);
     if ($_REQUEST['fun_host'] == '汇总') {
         $sql = "select FUN_COUNT,v3 v4  from {$this->report_monitor_hour} t where v1=:v1 and v2=:v2  and cal_date=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss') order by FUN_COUNT desc  ";
         $stmt = _ociparse($conn_db, "{$this->pageObj->num_1} {$sql} {$this->pageObj->num_3}");
         _ocibindbyname($stmt, ':v1', $_REQUEST['fun_type']);
         _ocibindbyname($stmt, ':v2', $_REQUEST['fun_act']);
         _ocibindbyname($stmt, ':num_1', intval($this->pageObj->limit_1));
         _ocibindbyname($stmt, ':num_3', intval($this->pageObj->limit_3));
         _ocibindbyname($stmt, ':cal_date', $_REQUEST['cal_date']);
         $oci_error = _ociexecute($stmt);
         $_row = array();
         $monitor_more = array();
         while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $monitor_more[] = $_row;
         }
     } else {
         if ($_REQUEST['fun_act']) {
             $sql = "select * from {$this->report_monitor} where v1=:v1 and v2=:v2 and  v3=:v3 and cal_date=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss') order by FUN_COUNT desc ";
         } else {
             $sql = "select * from {$this->report_monitor} where v1=:v1 and v2=:v2 and v3 is null and cal_date=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss') order by FUN_COUNT desc ";
         }
         $stmt = _ociparse($conn_db, "{$this->pageObj->num_1} {$sql} {$this->pageObj->num_3}");
         _ocibindbyname($stmt, ':v1', $_REQUEST['fun_type']);
         _ocibindbyname($stmt, ':v2', $_REQUEST['fun_host']);
         _ocibindbyname($stmt, ':num_1', intval($this->pageObj->limit_1));
         _ocibindbyname($stmt, ':num_3', intval($this->pageObj->limit_3));
         if ($_REQUEST['fun_act']) {
             _ocibindbyname($stmt, ':v3', $_REQUEST['fun_act']);
         }
         _ocibindbyname($stmt, ':cal_date', $_REQUEST['cal_date']);
         $oci_error = _ociexecute($stmt);
         $_row = array();
         $monitor_more = array();
         while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $monitor_more[] = $_row;
         }
     }
     include PHPAPM_PATH . "./project_tpl/report_monitor_more.html";
 }
Example #12
0
 function _initialize()
 {
     #每小时执行一次,每天6点执行
     if (date('i') != 30 && date('H') != 6) {
         exit;
     }
     $date = date('Y-m-d', time() - 3600 * 24);
     $conn_db = _ocilogon($this->db);
     $sql = "select v1, v2, v2_config_other from {$this->report_monitor_config} where v2_config_other like '%stats_flag%'";
     $stmt = _ociparse($conn_db, $sql);
     $_row = array();
     $error = _ociexecute($stmt);
     print_r($error);
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         print_r($_row);
         $_row['V2_CONFIG_OTHER'] = unserialize($_row['V2_CONFIG_OTHER']);
         $stats_flag = $_row['V2_CONFIG_OTHER']['stats_flag'];
         $this->_get_stats_flag_data($conn_db, $_row['V1'], $_row['V2'], $stats_flag, $date);
     }
     echo 'ok';
 }
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     $sql = "select * from {$this->report_monitor_config} where id=:id";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':id', $_POST['id']);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $v2_config_other = unserialize($_row['V2_CONFIG_OTHER']);
     $v2_config_other['stats_flag'] = $_POST['stats_flag'];
     if (empty($_POST['stats_flag'])) {
         unset($v2_config_other['stats_flag']);
     }
     $v2_config_other = serialize($v2_config_other);
     $sql = "update {$this->report_monitor_config} set v2_config_other=:v2_config_other where v2=:v2";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v2_config_other', $v2_config_other);
     _ocibindbyname($stmt, ':v2', $_row['V2']);
     $oci_error = _ociexecute($stmt);
 }
Example #14
0
 /**
  * Build db-specific report
  * @access private
  */
 function _sql_report($mode, $query = '')
 {
     switch ($mode) {
         case 'start':
             $html_table = false;
             // Grab a plan table, any will do
             $sql = "SELECT table_name\n\t\t\t\t\tFROM USER_TABLES\n\t\t\t\t\tWHERE table_name LIKE '%PLAN_TABLE%'";
             $stmt = ociparse($this->db_connect_id, $sql);
             ociexecute($stmt);
             $result = array();
             if (ocifetchinto($stmt, $result, OCI_ASSOC + OCI_RETURN_NULLS)) {
                 $table = $result['TABLE_NAME'];
                 // This is the statement_id that will allow us to track the plan
                 $statement_id = substr(md5($query), 0, 30);
                 // Remove any stale plans
                 $stmt2 = ociparse($this->db_connect_id, "DELETE FROM {$table} WHERE statement_id='{$statement_id}'");
                 ociexecute($stmt2);
                 ocifreestatement($stmt2);
                 // Explain the plan
                 $sql = "EXPLAIN PLAN\n\t\t\t\t\t\tSET STATEMENT_ID = '{$statement_id}'\n\t\t\t\t\t\tFOR {$query}";
                 $stmt2 = ociparse($this->db_connect_id, $sql);
                 ociexecute($stmt2);
                 ocifreestatement($stmt2);
                 // Get the data from the plan
                 $sql = "SELECT operation, options, object_name, object_type, cardinality, cost\n\t\t\t\t\t\tFROM plan_table\n\t\t\t\t\t\tSTART WITH id = 0 AND statement_id = '{$statement_id}'\n\t\t\t\t\t\tCONNECT BY PRIOR id = parent_id\n\t\t\t\t\t\t\tAND statement_id = '{$statement_id}'";
                 $stmt2 = ociparse($this->db_connect_id, $sql);
                 ociexecute($stmt2);
                 $row = array();
                 while (ocifetchinto($stmt2, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
                     $html_table = $this->sql_report('add_select_row', $query, $html_table, $row);
                 }
                 ocifreestatement($stmt2);
                 // Remove the plan we just made, we delete them on request anyway
                 $stmt2 = ociparse($this->db_connect_id, "DELETE FROM {$table} WHERE statement_id='{$statement_id}'");
                 ociexecute($stmt2);
                 ocifreestatement($stmt2);
             }
             ocifreestatement($stmt);
             if ($html_table) {
                 $this->html_hold .= '</table>';
             }
             break;
         case 'fromcache':
             $endtime = explode(' ', microtime());
             $endtime = $endtime[0] + $endtime[1];
             $result = @ociparse($this->db_connect_id, $query);
             $success = @ociexecute($result, OCI_DEFAULT);
             $row = array();
             while (@ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
                 // Take the time spent on parsing rows into account
             }
             @ocifreestatement($result);
             $splittime = explode(' ', microtime());
             $splittime = $splittime[0] + $splittime[1];
             $this->sql_report('record_fromcache', $query, $endtime, $splittime);
             break;
     }
 }
Example #15
0
 while ($row3 = oci_fetch_array($sth3)) {
     //echo "<div>", $row['TITLE'], "</div>";
     $packageId = $row3['PACKAGE_ID'];
 }
 if (is_null($row1['CURRENT1']) && !is_null($packageId)) {
     // SIMILIAR PACKAGE
     // nav back to create package
     echo '<script type="text/javascript">';
     echo 'alert("YOU HAVE CREATED THE SAME KIND OF PACKAGE!");';
     echo 'window.location.href = "myProjectView.php";';
     echo '</script>';
 } else {
     $sql2 = "SELECT FUNDING_GOAL FROM Projects WHERE project_id={$project_id}";
     $sth2 = oci_parse($dbh, $sql2);
     oci_execute($sth2, OCI_DEFAULT);
     while (ocifetchinto($sth2, $row2, OCI_ASSOC + OCI_RETURN_NULLS)) {
         $maxGoal = $row2['FUNDING_GOAL'];
     }
     if ($maxGoal < $currentFund + $amount * $max_count) {
         echo '<script type="text/javascript">';
         echo 'alert("YOU HAVE EXCEEDED THE FUNDING GOAL!");';
         echo 'window.location.href = "myProjectView.php";';
         echo '</script>';
     } else {
         //not similiar package
         // prepare
         $sql = "insert into package ( project_id, amount, max_count, package_reward)  values ( :project_id, :amount, :max_count, :package_reward)";
         $sth = oci_parse($dbh, $sql);
         // execute
         //oci_bind_by_name($sth, ':package_id', $package_id);
         oci_bind_by_name($sth, ':project_id', $project_id);
 /**
  *	This function will execute the SQL statement and return the records as an associative array.
  *
  *	@param $sql	The SQL statement to use.
  *
  *	@returns	The records matching the SQL statement as an associative array.
  */
 function getRecords($sql)
 {
     $result = $this->_connectAndExec($sql);
     $dataset = array();
     while (ocifetchinto($result, $line, OCI_ASSOC)) {
         array_push($dataset, $this->_lowerKeyNames($line));
     }
     OCIFreeStatement($result);
     return $dataset;
 }
Example #17
0
function DBfetch(&$cursor)
{
    global $DB;
    $result = false;
    if (isset($DB['DB']) && !empty($DB['DB'])) {
        switch ($DB['TYPE']) {
            case 'MYSQL':
                $result = mysql_fetch_assoc($cursor);
                break;
            case 'POSTGRESQL':
                $result = pg_fetch_assoc($cursor);
                break;
            case 'ORACLE':
                if (ocifetchinto($cursor, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
                    $result = array();
                    foreach ($row as $key => $value) {
                        $result[strtolower($key)] = str_in_array(strtolower(ocicolumntype($cursor, $key)), array('varchar', 'varchar2', 'blob', 'clob')) && is_null($value) ? '' : $value;
                    }
                }
                break;
            case 'SQLITE3':
                if ($cursor) {
                    $result = array_shift($cursor);
                    if (is_null($result)) {
                        $result = false;
                    }
                }
                break;
        }
    }
    return $result;
}
 /**
  * Result - associative array
  *
  * Returns the result set as an array
  *
  * @access  private
  * @return  array
  */
 function _fetch_assoc(&$row)
 {
     // if pulling from a cursor, use curs_id
     if ($this->curs_id) {
         return ocifetchinto($this->curs_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
     } else {
         return ocifetchinto($this->stmt_id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
     }
 }
function querY($type, $host, $user, $pass, $db = '', $query)
{
    $res = '';
    switch ($type) {
        case 'MySQL':
            if (!function_exists('mysql_connect')) {
                return 0;
            }
            $link = mysql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mysql_select_db($db, $link);
                }
                $result = mysql_query($query, $link);
                while ($data = mysql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mysql_num_fields($result); $i++) {
                    $res .= mysql_field_name($result, $i) . '[-][-][-]';
                }
                mysql_close($link);
                return $res;
            }
            break;
        case 'MSSQL':
            if (!function_exists('mssql_connect')) {
                return 0;
            }
            $link = mssql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mssql_select_db($db, $link);
                }
                $result = mssql_query($query, $link);
                while ($data = mssql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mssql_num_fields($result); $i++) {
                    $res .= mssql_field_name($result, $i) . '[-][-][-]';
                }
                mssql_close($link);
                return $res;
            }
            break;
        case 'Oracle':
            if (!function_exists('ocilogon')) {
                return 0;
            }
            $link = ocilogon($user, $pass, $db);
            if ($link) {
                $stm = ociparse($link, $query);
                ociexecute($stm, OCI_DEFAULT);
                while ($data = ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < oci_num_fields($stm); $i++) {
                    $res .= oci_field_name($stm, $i) . '[-][-][-]';
                }
                return $res;
            }
            break;
        case 'PostgreSQL':
            if (!function_exists('pg_connect')) {
                return 0;
            }
            $link = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
            if ($link) {
                $result = pg_query($link, $query);
                while ($data = pg_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < pg_num_fields($result); $i++) {
                    $res .= pg_field_name($result, $i) . '[-][-][-]';
                }
                pg_close($link);
                return $res;
            }
            break;
    }
    return 0;
}
 /**
  * Advances the current row position.
  * Advances the current row position. If there are no more rows left, then
  * it returns <code>false</code>.
  * @access public
  * @return boolean True, if successful; False, otherwise.
  */
 function advanceRow()
 {
     // if no rows left, cannot advance
     if (!$this->hasMoreRows()) {
         return false;
     }
     // now, advance
     $this->_currentRowIndex++;
     ocifetchinto($this->_resourceId, $this->_currentRow[BOTH], OCI_NUM + OCI_ASSOC + OCI_RETURN_LOBS);
     foreach ($this->_currentRow[BOTH] as $key => $value) {
         if (is_int($key)) {
             $this->_currentRow[NUMERIC][$key] = $value;
         } else {
             $this->_currentRow[ASSOC][$key] = $value;
         }
     }
     return true;
 }
Example #21
0
 function _initialize()
 {
     $conn_db = _ocilogon($this->db);
     $s1 = date('Y-m-d', strtotime("-1 month"));
     $s2 = date('Y-m-d');
     if ($_REQUEST['s1']) {
         $s1 = $_REQUEST['s1'];
     }
     if ($_REQUEST['s2'] && strtotime($_REQUEST['s2']) < time()) {
         $s2 = $_REQUEST['s2'];
     }
     //
     $start_date = $_REQUEST["start_date"] ? $_REQUEST["start_date"] : date("Y-m-d");
     //强制看今天的第一列
     if ($_COOKIE['direct_date'] == 'true' && !$_REQUEST["start_date"]) {
         $_REQUEST["start_date"] = $start_date;
     }
     //时间乱传,不在范围之内
     if (strtotime($start_date) > strtotime($s2) || strtotime($start_date) < strtotime($s1)) {
         unset($start_date, $_REQUEST["start_date"]);
     }
     $start_date1 = $start_date;
     $group_name_2 = '默认';
     $group_name = '默认';
     if ($_COOKIE[md5($_SERVER['SCRIPT_FILENAME']) . '_v1_group_name']) {
         $group_name = $_COOKIE[md5($_SERVER['SCRIPT_FILENAME']) . '_v1_group_name'];
     }
     //别名替换
     $sql = "select t.*,decode(as_name,null,v1,as_name) as_name1 from {$this->report_monitor_v1} t where id>0\n            order by decode(as_name,null,v1,as_name)  ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $v1_config_group = $this->v1_config = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         if ($_REQUEST['type'] == $_row['V1']) {
             $group_name = $_row['GROUP_NAME'];
             $group_name_1 = $_row['GROUP_NAME_1'];
             $group_name_2 = $_row['GROUP_NAME_2'];
         }
         $v1_config_group[$_row['GROUP_NAME_1']][$_row['GROUP_NAME_2']][$_row['GROUP_NAME']][$_row['V1']] = $_row;
     }
     $this->v1_config = $v1_config_group[$group_name_1][$group_name_2][$group_name];
     //偏差时差
     if ($this->v1_config[$_REQUEST['type']]['START_CLOCK']) {
         $start_date1 = date('Y-m-d H:i:s', strtotime($start_date . " +{$this->v1_config[$_REQUEST['type']]['START_CLOCK']} hour"));
     }
     //所有类型
     $sql = "select v1 from {$this->report_monitor_config} where id>0  group by v1 order by v1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $this->type = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $this->type[] = $_row['V1'];
         if (!$_REQUEST['type'] && $this->v1_config[$_row['V1']]) {
             $_REQUEST['type'] = $_row['V1'];
         }
     }
     //当前类型下面的所有模块
     $sql = "select t.* ,decode(as_name,null,v2,as_name) as_name1  from {$this->report_monitor_config} t where v1=:v1 and v2<>'汇总'\n            order by orderby,as_name1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
     _ociexecute($stmt);
     $this->host = $_row = array();
     $this->v1_config[$_REQUEST['type']]['SHOW_ALL'] = 1;
     if ($this->v1_config[$_REQUEST['type']]['SHOW_ALL']) {
         $this->host[] = array('V1' => $_REQUEST['type'], 'V2' => '汇总', 'AS_NAME1' => '汇总');
     }
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $_row['V2_CONFIG_OTHER'] = unserialize($_row['V2_CONFIG_OTHER']);
         $this->host[$_row['V2']] = $_row;
         if ($_REQUEST['host'] == $_row['V2']) {
             $this->v_config = $_row;
         }
     }
     if ($_COOKIE['direct_date'] == 'true' && !$_REQUEST["host"]) {
         $_REQUEST["host"] = $this->host[0]['V2'];
     }
     //全部下级日统计数据
     $sql = "select t.*,to_char(cal_date, 'yyyy-mm-dd')  CAL_DATE_F  from\n            {$this->report_monitor_date} t where\n            cal_date>=to_date(:s1,'yyyy-mm-dd') and cal_date<=to_date(:s2,'yyyy-mm-dd')  and v1=:v1 and v2<>'汇总' ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
     _ocibindbyname($stmt, ':s1', $s1);
     _ocibindbyname($stmt, ':s2', $s2);
     $oci_error = _ociexecute($stmt);
     $this->all_start_date_all = $this->all_start_date_count = $this->all_start_date = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         if (!$this->v1_config[$_REQUEST['type']]['START_CLOCK']) {
             $this->all_start_date_count[$_row['V2']]['total'] += $_row['FUN_COUNT'];
             $this->all_start_date_count[$_row['V2']]['total_i']++;
             $this->all_start_date_count[$_row['V2']]['total_avg'] = round($this->all_start_date_count[$_row['V2']]['total'] / $this->all_start_date_count[$_row['V2']]['total_i'], 2);
             $this->all_start_date_all[$_row['CAL_DATE_F']] += $_row['FUN_COUNT'];
             $this->all_start_date[$_row['CAL_DATE_F']][$_row['V2']] += $_row['FUN_COUNT'];
             //统计汇总
             if ($this->v1_config[$_REQUEST['type']]['SHOW_ALL'] && !$this->host[$_row['V2']]['V2_CONFIG_OTHER']['NO_COUNT']) {
                 //查看当前数据是够需要统计
                 $this->all_start_date_count['汇总']['total'] += $_row['FUN_COUNT'];
                 $this->all_start_date_count['汇总']['total_i']++;
                 $this->all_start_date_count['汇总']['total_avg'] = round($this->all_start_date_count['汇总']['total'] / $this->all_start_date_count['汇总']['total_i'], 2);
                 if ($this->v1_config[$_REQUEST['type']]['SHOW_AVG'] == 1) {
                     $this->all_start_date[$_row['CAL_DATE_F']]['汇总'] = round($this->all_start_date_all[$_row['CAL_DATE_F']] / (count($this->all_start_date_count) - 1), 2);
                 } else {
                     $this->all_start_date[$_row['CAL_DATE_F']]['汇总'] += $_row['FUN_COUNT'];
                 }
             }
         }
         $this->all_start_date[$_row['CAL_DATE_F']]['LOOKUP'] = $_row['LOOKUP'];
     }
     //显示对比数据
     if ($this->host[$_row['V2']]['V2_COMPARE'] == 1) {
         $name = $_row['V2'] . '增量';
         $time = date('Y-m-d', strtotime($_row['CAL_DATE_F'] . " +1 day"));
         $this->all_start_date[$_row['CAL_DATE_F']][$name] = $this->all_start_date[$_row['CAL_DATE_F']][$_row['V2']] - $this->all_start_date[$time][$_row['V2']];
         $this->all_start_date_count[$name]['total'] += $this->all_start_date[$_row['CAL_DATE_F']][$name];
     }
     foreach ($this->all_start_date as $k => $v) {
         foreach ($v as $i => $c) {
             //显示对比数据
             if ($this->host[$i]['V2_COMPARE'] == 1) {
                 $name = $i . '增量';
                 $time = date('Y-m-d', strtotime($k . " -1 day"));
                 $this->all_start_date[$k][$name] = $this->all_start_date[$k][$i] - $this->all_start_date[$time][$i];
                 $this->all_start_date_count[$name]['total'] += $this->all_start_date[$k][$name];
             }
         }
     }
     //获取v2分组
     $sql = "select t.* ,decode(as_name,null,v2,as_name) as_name1  from {$this->report_monitor_config} t where v1=:v1 and v2<>'汇总'\n                            order by orderby,as_name1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
     _ociexecute($stmt);
     $this->group = array();
     if ($this->v1_config[$_REQUEST['type']]['SHOW_ALL']) {
         $this->group['汇总'][] = array('V1' => $_REQUEST['type'], 'V2' => '汇总', 'AS_NAME1' => '汇总');
     }
     $cospan = 1;
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         if ($_row['V2_GROUP'] == '') {
             $_row['V2_GROUP'] = '其它';
         } else {
             $is_group = true;
         }
         $cospan++;
         if ($_row['V2_CONFIG_OTHER']) {
             $_row['V2_CONFIG_OTHER'] = unserialize($_row['V2_CONFIG_OTHER']);
             //获取接口的基本信息,测试统计信息,联系人信息
             if ($_row['V2_CONFIG_OTHER']['API_ID']) {
                 $_row['API_INFO'] = $this->_get_apiinfo($conn_db, $_row['V2_CONFIG_OTHER']['API_ID']);
             }
         }
         $this->group[$_row['V2_GROUP']][] = $_row;
         //显示对比数据
         if ($_row['V2_COMPARE'] == 1) {
             $_row['AS_NAME1'] = $_row['AS_NAME1'] . '增量';
             $_row['V2'] = $_row['V2'] . '增量';
             $this->group[$_row['V2_GROUP']][] = $_row;
             $cospan++;
         }
     }
     //获取分组总数
     if ($is_group) {
         foreach ($this->group as $k => $v) {
             foreach ($v as $v2) {
                 foreach ($this->all_start_date_count as $c => $i) {
                     if ($c == $v2['V2']) {
                         $this->group_count[$k]['count'] += $i['total'];
                     }
                 }
             }
         }
     }
     //时区有偏差,改成从小时表读取数据
     if ($this->v1_config[$_REQUEST['type']]['START_CLOCK']) {
         $sql = "select v1,v2,sum(fun_count) fun_count, to_char(t.cal_date, 'yyyy-mm-dd hh24:mi:ss') as cal_date_f\n                    \tfrom  {$this->report_monitor_hour} t\n                        where cal_date>=to_date(:s1,'yyyy-mm-dd')+:diff/24 and cal_date<=to_date(:s2,'yyyy-mm-dd')+:diff/24\n                        and v1=:v1\n                        group by v1,v2,to_char(t.cal_date, 'yyyy-mm-dd hh24:mi:ss') ";
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':diff', $this->v1_config[$_REQUEST['type']]['START_CLOCK']);
         _ocibindbyname($stmt, ':s1', $s1);
         _ocibindbyname($stmt, ':s2', $s2);
         _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
         $oci_error = _ociexecute($stmt);
         $_row = array();
         while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             if (date('H', strtotime($_row['CAL_DATE_F'])) < $this->v1_config[$_REQUEST['type']]['START_CLOCK']) {
                 $_row['CAL_DATE_F'] = date('Y-m-d', strtotime($_row['CAL_DATE_F'] . " -1 day"));
             } else {
                 $_row['CAL_DATE_F'] = date('Y-m-d', strtotime($_row['CAL_DATE_F']));
             }
             //汇总计算
             if ($this->v1_config[$_REQUEST['type']]['SHOW_ALL'] == 1 && !$this->host[$_row['V2']]['V2_CONFIG_OTHER']['NO_COUNT']) {
                 //判断项目是否需要汇总
                 $this->all_start_date_count['汇总'] += $_row['FUN_COUNT'];
                 $this->all_start_date[$_row['CAL_DATE_F']]['汇总'] += $_row['FUN_COUNT'];
             }
             $this->all_start_date_count[$_row['V2']] += $_row['FUN_COUNT'];
             $this->all_start_date[$_row['CAL_DATE_F']][$_row['V2']] += $_row['FUN_COUNT'];
             $this->all_start_date_all[$_row['CAL_DATE_F']] += $_row['FUN_COUNT'];
         }
     }
     if ($start_date && $this->v1_config[$_REQUEST['type']]['SHOW_ALL'] && $_REQUEST['host'] == '汇总') {
         //当日数据
         $sql = "  select v2 as v3,sum(fun_count) fun_count,round(avg(fun_count),2) fun_count_avg,to_char(t.cal_date, 'dd hh24') as cal_date_f,\n                max(t.diff_time) diff_time, sum(t.total_diff_time) total_diff_time,max(t.memory_max) memory_max, sum(t.memory_total) memory_total,\n                max(t.cpu_user_time_max) cpu_user_time_max, sum(t.cpu_user_time_total) cpu_user_time_total,max(t.cpu_sys_time_max) cpu_sys_time_max, sum(t.cpu_sys_time_total) cpu_sys_time_total\n                from  {$this->report_monitor_hour} t where cal_date>=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')-1 and cal_date<to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')+1\n                and v1=:v1  and v2<>'汇总'\n                group by v1,v2,to_char(t.cal_date, 'dd hh24')  ";
         $stmt2 = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt2, ':cal_date', $start_date1);
         _ocibindbyname($stmt2, ':v1', $_REQUEST['type']);
         $oci_error = _ociexecute($stmt2);
         print_r($oci_error);
         $this->fun_count = $this->fun_count2 = $_row = array();
         while (ocifetchinto($stmt2, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $this->fun_count[$_row['V3']]['AS_NAME1'] = $_row['V3'];
             foreach ($this->host as $k => $v) {
                 if ($_row['V3'] == $v['V2']) {
                     $this->fun_count[$_row['V3']]['AS_NAME1'] = $v['AS_NAME1'];
                     break;
                 }
             }
             if ($this->v1_config[$_REQUEST['type']]['SHOW_AVG'] == 1) {
                 $_row['FUN_COUNT'] = $_row['FUN_COUNT_AVG'];
             }
             $this->fun_count[$_row['V3']][$_row['CAL_DATE_F']] = $_row;
             $this->fun_count[$_row['V3']]['DIFF_TIME'] = max($this->fun_count[$_row['V3']]['DIFF_TIME'], abs($_row['DIFF_TIME']));
             $this->fun_count[$_row['V3']]['TOTAL_DIFF_TIME'] += abs($_row['TOTAL_DIFF_TIME']);
             $this->fun_count[$_row['V3']]['MEMORY_MAX'] = max($this->fun_count[$_row['V3']]['MEMORY_MAX'], abs($_row['MEMORY_MAX']));
             $this->fun_count[$_row['V3']]['MEMORY_TOTAL'] += abs($_row['MEMORY_TOTAL']);
             $this->fun_count[$_row['V3']]['CPU_USER_TIME_MAX'] = max($this->fun_count[$_row['V3']]['CPU_USER_TIME_MAX'], abs($_row['CPU_USER_TIME_MAX']));
             $this->fun_count[$_row['V3']]['CPU_USER_TIME_TOTAL'] += abs($_row['CPU_USER_TIME_TOTAL']);
             $this->fun_count[$_row['V3']]['CPU_SYS_TIME_MAX'] = max($this->fun_count[$_row['V3']]['CPU_SYS_TIME_MAX'], abs($_row['CPU_SYS_TIME_MAX']));
             $this->fun_count[$_row['V3']]['CPU_SYS_TIME_TOTAL'] += abs($_row['CPU_SYS_TIME_TOTAL']);
             if ($this->v1_config[$_REQUEST['type']]['SHOW_AVG'] == 1) {
                 $this->fun_count[$_row['V3']]['FUN_COUNT'] = $_row['FUN_COUNT_AVG'];
             } elseif ($_row['CAL_DATE_F'] >= date("d H", strtotime($start_date))) {
                 $this->fun_count[$_row['V3']]['FUN_COUNT'] += $_row['FUN_COUNT'];
             }
             $this->fun_count[$_row['V3']]['FUN_COUNT_I'] += 1;
             $this->fun_count[$_row['V3']]['FUN_COUNT_AVG'] = round($this->fun_count[$_row['V3']]['FUN_COUNT'] / $this->fun_count[$_row['V3']]['FUN_COUNT_I'], 2);
             $this->fun_count2[$_row['CAL_DATE_F']] += $_row['FUN_COUNT'];
         }
         uasort($this->fun_count, create_function('$a,$b', 'if ($a["FUN_COUNT"] == $b["FUN_COUNT"]) return 0; return ($a["FUN_COUNT"]<$b["FUN_COUNT"]);'));
     } elseif ($start_date) {
         $this->pageObj = new page(10000, 300);
         //文档数据
         $sql_v2 = "select * from {$this->report_monitor_config} where v2=:v2";
         $stmt_v2 = _ociparse($conn_db, $sql_v2);
         _ocibindbyname($stmt_v2, ':v2', $_REQUEST['host']);
         _ociexecute($stmt_v2);
         $row_v2 = oci_fetch_assoc($stmt_v2);
         if ($row_v2['V2_CONFIG_OTHER']) {
             $row_v2['V2_CONFIG_OTHER'] = unserialize($row_v2['V2_CONFIG_OTHER']);
         }
         //当日数据
         $sql = "{$this->pageObj->num_1} select v3,sum(fun_count) fun_count from  {$this->report_monitor_hour}\n                    where cal_date>=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss') and cal_date<to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')+1\n                    and v1=:v1 and v2=:v2\n                    group by v1,v2,v3  {$this->pageObj->num_3} ";
         $stmt2 = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt2, ':cal_date', $start_date1);
         _ocibindbyname($stmt2, ':v1', $_REQUEST['type']);
         _ocibindbyname($stmt2, ':v2', $_REQUEST['host']);
         _ocibindbyname($stmt2, ':num_1', intval($this->pageObj->limit_1));
         _ocibindbyname($stmt2, ':num_3', intval($this->pageObj->limit_3));
         $oci_error = _ociexecute($stmt2);
         $this->fun_count = $this->fun_count2 = $_row2 = array();
         while (ocifetchinto($stmt2, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $sql = "select t.*,to_char(t.cal_date, 'dd hh24') as cal_date_f\n                       from {$this->report_monitor_hour} t\n                       where cal_date>=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')-1 and cal_date<to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')+1\n                       and v1=:v1 and v2=:v2 and v3=:v3   order by fun_count desc";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':cal_date', $start_date1);
             _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
             _ocibindbyname($stmt, ':v2', $_REQUEST['host']);
             _ocibindbyname($stmt, ':v3', $_row2['V3']);
             $oci_error = _ociexecute($stmt);
             $_row = array();
             while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
                 $this->fun_count[$_row['V3']]['AS_NAME1'] = $_row['V3'];
                 $this->fun_count[$_row['V3']][$_row['CAL_DATE_F']] = $_row;
                 $this->fun_count[$_row['V3']]['DIFF_TIME'] = max($this->fun_count[$_row['V3']]['DIFF_TIME'], abs($_row['DIFF_TIME']));
                 $this->fun_count[$_row['V3']]['TOTAL_DIFF_TIME'] += abs($_row['TOTAL_DIFF_TIME']);
                 $this->fun_count[$_row['V3']]['MEMORY_MAX'] = max($this->fun_count[$_row['V3']]['MEMORY_MAX'], abs($_row['MEMORY_MAX']));
                 $this->fun_count[$_row['V3']]['MEMORY_TOTAL'] += abs($_row['MEMORY_TOTAL']);
                 $this->fun_count[$_row['V3']]['CPU_USER_TIME_MAX'] = max($this->fun_count[$_row['V3']]['CPU_USER_TIME_MAX'], abs($_row['CPU_USER_TIME_MAX']));
                 $this->fun_count[$_row['V3']]['CPU_USER_TIME_TOTAL'] += abs($_row['CPU_USER_TIME_TOTAL']);
                 $this->fun_count[$_row['V3']]['CPU_SYS_TIME_MAX'] = max($this->fun_count[$_row['V3']]['CPU_SYS_TIME_MAX'], abs($_row['CPU_SYS_TIME_MAX']));
                 $this->fun_count[$_row['V3']]['CPU_SYS_TIME_TOTAL'] += abs($_row['CPU_SYS_TIME_TOTAL']);
                 if ($_row['CAL_DATE_F'] >= date("d H", strtotime($start_date))) {
                     $this->fun_count[$_row['V3']]['FUN_COUNT'] += $_row['FUN_COUNT'];
                     $this->fun_count[$_row['V3']]['FUN_COUNT_I'] += 1;
                     $this->fun_count[$_row['V3']]['FUN_COUNT_AVG'] = round($this->fun_count[$_row['V3']]['FUN_COUNT'] / $this->fun_count[$_row['V3']]['FUN_COUNT_I'], 2);
                     $this->fun_count2[$_row['CAL_DATE_F']] += $_row['FUN_COUNT'];
                     $this->fun_count3['FUN_COUNT_I']++;
                     $this->fun_count3['FUN_COUNT'] += $_row['FUN_COUNT'];
                     $this->fun_count3['FUN_COUNT_AVG'] = round($this->fun_count3['FUN_COUNT'] / $this->fun_count3['FUN_COUNT_I'], 2);
                 }
             }
         }
         uasort($this->fun_count, create_function('$a,$b', 'if ($a["FUN_COUNT"] == $b["FUN_COUNT"]) return 0; return ($a["FUN_COUNT"]<$b["FUN_COUNT"]);'));
     }
     //end today start yestoday
     //获取v2 30天内数据
     if ($_REQUEST['host'] && $_COOKIE['v2_month'] == 'true' && $_REQUEST['host'] != '汇总') {
         $sql = "select v2,to_char(t.cal_date, 'mm dd hh24') as cal_date_f,sum(fun_count) fun_count,to_char(t.cal_date, 'mm dd') as cal_date_d\n                                  from {$this->report_monitor_hour} t\n                                  where cal_date>=to_date(:s1,'yyyy-mm-dd hh24:mi:ss') and cal_date<=to_date(:s2,'yyyy-mm-dd hh24:mi:ss')\n                                  and v1=:v1 and v2=:v2 group by v2,cal_date  order by cal_date desc";
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':v1', $_REQUEST['type']);
         _ocibindbyname($stmt, ':v2', $_REQUEST['host']);
         _ocibindbyname($stmt, ':s1', $s1 . '00:00:00');
         _ocibindbyname($stmt, ':s2', $s2 . '23:59:59');
         $oci_error = _ociexecute($stmt);
         $_row = array();
         while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $this->fun_count_v2[$_row['CAL_DATE_F']] = $_row['FUN_COUNT'];
             $this->fun_count_3[$_row['CAL_DATE_D']] += $_row['FUN_COUNT'];
         }
     }
     //加载文件
     if (!isset($_COOKIE['cmp_base'])) {
         $_COOKIE['cmp_base'] = 10000;
         setcookie('cmp_base', 10000, time() + 3600 * 24 * 7);
     }
     if (!isset($_COOKIE['red_factor'])) {
         $_COOKIE['red_factor'] = 2;
         setcookie('red_factor', 2, time() + 3600 * 24 * 7);
     }
     include PHPAPM_PATH . "./project_tpl/report_monitor.html";
 }
Example #22
0
	/**
	* Get last inserted id after insert statement
	*/
	function nextid() {
		if ($this->result !== false && $this->last_query_text != '') {
			if (preg_match('#^INSERT[\t\n ]+INTO[\t\n ]+([a-z0-9\_\-]+)#is', $this->last_query_text, $tablename)) {
				$query = 'SELECT ' . $tablename[1] . '_seq.currval FROM DUAL';
				$stmt = @oci_parse($this->connect, $query);
				@oci_execute($stmt, OCI_DEFAULT);

				$temp_result = @ocifetchinto($stmt, $temp_array, OCI_ASSOC + OCI_RETURN_NULLS);
				@oci_free_statement($stmt);

				if ($temp_result) {
					return $temp_array['CURRVAL'];
				}
			}
		}

		return false;
	}
Example #23
0
 function FetchArray($rsMain, &$result)
 {
     return ocifetchinto($rsMain, $result, OCI_NUM);
 }
 function _initialize()
 {
     #每小时执行一次
     if (date('i') != 30) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     //1.汇总的生成
     $sql = "update {$this->report_monitor_config} t set COMPARE_GROUP='1.汇总' where (v1 like '%(BUG错误)%' and (v2 = 'PHP错误' or v2 = 'SQL错误' or v2 = '一秒内' or v2 = '超时')) or (v1 like '%(Couchbase)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(MySQL统计)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(SQL统计)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(Memcache)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(Sphinx)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(网址抓取)%' and (v2 = '超时' or v2 = '一秒内')) or (v1 like '%(WEB日志分析)%' and (v2 = 'QPS' or v2 = 'TCP连接' or v2 = '400' or v2 = '403' or v2 = '499' or v2 = '500' or v2 = '502'))";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //排查.BUG
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='排查.BUG' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(BUG错误)_PHP错误' or v2 like '%(BUG错误)_SQL错误')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //排查.机器
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='排查.机器' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(WEB日志分析)_QPS' or v2 like '%(WEB日志分析)_TCP连接')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //排查.BUG
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='排查.BUG' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(BUG错误)_PHP错误' or v2 like '%(BUG错误)_SQL错误')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.Couchbase
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.Couchbase' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(Couchbase)_超时' or v2 like '%(Couchbase)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.Memcache
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.Memcache' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(Memcache)_超时' or v2 like '%(Memcache)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.MySQL
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.MySQL' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(MySQL统计)_超时' or v2 like '%(MySQL统计)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.Oracle
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.Oracle' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(SQL统计)_超时' or v2 like '%(SQL统计)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.Sphinx
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.Sphinx' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(Sphinx)_超时' or v2 like '%(Sphinx)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //资源.接口网址
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='资源.接口网址' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(网址抓取)_超时' or v2 like '%(网址抓取)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //总PV
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='总PV' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(BUG错误)_超时' or v2 like '%(BUG错误)_一秒内')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     //总PV.错误
     $sql = "update {$this->report_monitor_config} t set AS_NAME=regexp_substr(V2, '[^_]+\$'), V2_GROUP='总PV.错误' where V1 = '1.汇总' and V2_GROUP is null and (v2 like '%(WEB日志分析)_400' or v2 like '%(WEB日志分析)_403' or v2 like '%(WEB日志分析)_499' or v2 like '%(WEB日志分析)_500' or v2 like '%(WEB日志分析)_502')";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='数据库',as_name=null  where  V1 like '%(SQL统计)%'\n                or v1 like '%(MySQL统计)'   ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='1.项目', GROUP_NAME='基本统计',as_name=null  where    V1 like '%(BUG错误)%'    or v1 like '%(断点耗时)' or  v1 like '%(WEB日志分析)%'";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='Memcache',as_name=null  where   v1 like '%(Memcache)%'  or v1 like '%(Memcache)%' or v1 like '%(Memcache状态)%' or v1 like '%(Memcahe连接)%' or v1 like '%(Couchbase)%'  ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='API接口',as_name=null  where v1 like '%(网址抓取)%'  or v1 like '%(FTP)%'  ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='邮件',as_name=null  where v1 like '%(邮件系统)%' ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1}  t set  GROUP_NAME_1='数据指标', GROUP_NAME_2='1.项目', GROUP_NAME='得分',as_name=null  where V1 like '%(项目满意分)%' or V1 like '%(项目文档满意分)%' ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1}  t set  GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='Redis',as_name=null  where V1 like '%(Redis)%' or V1 like '%(Redis连接)%' ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1}  t set  GROUP_NAME_1='数据指标', GROUP_NAME_2='2.资源', GROUP_NAME='Redis',as_name=null  where V1 like '%(Redis效率BUG)%' or V1 like '%(Redis连接效率)%' ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1} t set GROUP_NAME_1='数据指标', GROUP_NAME_2='3.作废', GROUP_NAME='作废',as_name=null  where   v1 like '%(Memcahe连接错误)%' or v1 like '%(Memcache)NEW%' or v1 like '%(Memcache使用错误)%' or v1 like '%(Memcahe错误)%'  or v1 like '%(Memcahe连接)%' or v1 like '%(Memcache移动)' or v1 like '%(Memcahe连接效率)%' or v1 like '%(Memcahe整体耗时)%' or v1 like '%(安全BUG)%' or v1 like '%(Memcahe效率BUG)%' or v1 like '%(程序效率BUG)%' or v1 like '%(数据库被连接)%' or v1 like '%(接口效率)%' or  v1 like '%SQL效率BUG)%' or v1 like '%(数据库连接%'  or  v1 like '%(SQL统计)[项目]%' or v1 like '%(数据库表大小)%'   or v1 like '%(数据库表空间)%' or v1 like '%(队列服务)%' or  v1 like '%(登录日志%' or v1 like '%(包含文件)[项目]%' or v1 like '%(Mysql使用错误)%'  or v1 like '%(包含文件)%' or v1 like '%(问题SQL)%' or v1 like '%(服务器)%' or v1 like '%(接口测试)%' or v1 like '%文件系统读写%' or v1 like '%(功能执行)%' or v1 like '%(服务器进程)%'  or v1 like '%(代码%'  or v1 like '%(FTP效率BUG)%'   or v1 like '%(服务器进程)%' or v1 like '%(队列信息)' or v1 like '%(账户日志)%' or v1 like '%(函数分布)%' or v1 like '%(文件系统%' or v1 = '1.汇总' or v1 like '%(PHPAPM)%'";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_v1}  t set  AS_NAME='" . VHOST . "(技术的满意分)' where V1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     foreach (array($this->report_monitor_v1, $this->report_monitor_config) as $table) {
         $sql = "update  {$table} t set   hour_count_type=4 ,day_count_type=1   where v1 like '%(Memcache状态)%'  ";
         $stmt = _ociparse($conn_db, $sql);
         $oci_error = _ociexecute($stmt);
         $sql = "update  {$table} t set day_count_type=5,hour_count_type=4  where V1 like '%(项目满意分)%' or V1 like '%(项目文档满意分)%'";
         $stmt = _ociparse($conn_db, $sql);
         $oci_error = _ociexecute($stmt);
     }
     //内置的系统环境都不需要验收
     $sql = "update  {$this->report_monitor_v1} t set is_duty=1  where  (t.GROUP_NAME_1 = '数据指标' or t.GROUP_NAME_1 = '数据指标')  ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     //v2分组
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='A.态度'  where  t.V2 = '扣:故障'  and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='B.责任考核'  where  (t.V2 = 'SQL回源率' or t.V2 = 'TCP连接数' or t.v2='项目验收') and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='C.编程能力'  where  (t.V2 = 'PHP+SQL错误率' or t.V2 = '扣分:问题sql') and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='D.安全'  where  t.V2 = '扣:安全'  and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='E.维护成本'  where  t.V2 = '扣分:包含文件' and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='F.基础考核'  where  (t.V2 = 'Memcache回源率' or t.V2 = '扣分:单小时SQL上限' or t.v2='扣分:执行超时') and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='G.运维考核'  where  (t.V2 = '扣分:5xx错误' or t.V2 = '扣分:CPU LOAD' or t.v2='扣分:机器重启') and v1 like '%(项目满意分)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     //别名换算
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:SQL上限' where v2='扣分:单小时SQL上限'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:负载' where v2='扣分:CPU LOAD'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:重启' where v2='扣分:机器重启'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='TCP' where v2='TCP连接数'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:文件数' where v2='扣分:包含文件'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='错误' where v2='PHP+SQL错误率'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:超时' where v2='扣分:执行超时'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='扣:sql' where v2='扣分:问题sql'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='天数' where v2='运行天数'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='ip前十' where v2='ip统计前十'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='已用磁盘比' where v2='磁盘' and v1 like '%(WEB日志分析)' ";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='内存' where v2='Mem内存剩余' and v1 like '%(WEB日志分析)' ";
     _ociexecute(_ociparse($conn_db, $sql));
     //所有v2 中有‘s到’的不计入统计;
     $sql = "update  {$this->report_monitor_config} t set V2_CONFIG_OTHER=:V2_CONFIG_OTHER where v2 ='超时' or v2 = '一秒内' ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':V2_CONFIG_OTHER', serialize(array("NO_COUNT" => true)));
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='数据库' where (v2='SQL错误' or v2 ='问题SQL' or v2='数据库连接错误') and v1 like '%(BUG错误)'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='技术错误' where v1 like '%(BUG错误)' and (v2='PHP错误' or v2='脚本错误'  or v2='致命错误' or v2='Memcache错误' ) ";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='验收责任' ,V2_GROUP='问题' where v2='验收责任未到位' and v1 like '%(BUG错误)'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set AS_NAME='木马',V2_GROUP='问题'  where v2='上传木马入侵' and v1 like '%(BUG错误)'";
     _ociexecute(_ociparse($conn_db, $sql));
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='项目'  where v2 like '%[项目]'  and v1 like '%(BUG错误)'";
     _ociexecute(_ociparse($conn_db, $sql));
     //定时更新不计入统计的项目
     $sql = "select * from {$this->report_monitor_config} where ( v1 like '%(WEB日志分析)' and (v2='文件' or v2 = 'QPS' or v2 = 'ip统计前十' or v2 = '独立ip') )\n           or  (v1 like '%(队列服务)' and v2='压缩比例' )";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $v2_config_other = unserialize($_row['V2_CONFIG_OTHER']);
         $v2_config_other['NO_COUNT'] = true;
         $v2_config_other = serialize($v2_config_other);
         $sql = "update {$this->report_monitor_config} set v2_config_other=:v2_config_other where v2=:v2";
         $stmt2 = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt2, ':v2_config_other', $v2_config_other);
         _ocibindbyname($stmt2, ':v2', $_row['V2']);
         $oci_error = _ociexecute($stmt2);
     }
     //修改CPU,load的计算方式
     $sql = "update  {$this->report_monitor_config} set day_count_type=6,hour_count_type=4  where V1 like '%(WEB日志分析)%' and (v2='CPU' OR  v2='Load') ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set  day_count_type=5,hour_count_type=4  where  t.V2 = '压缩比例'  and v1 like '%(队列服务)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set  day_count_type=5,hour_count_type=4  where  t.V2 = 'QPS'  and v1 like '%(WEB日志分析)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='功能执行'  where  (t.V2 = '其他功能' or t.V2 = '页面操作' or t.v2='内网接口' or t.V2 = '定时') and v1 like '%(BUG错误)'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='效率'  where  (t.V2 = '一秒内' or t.V2 = '超时') ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='A.正常'  where  (t.V2 like '2%' or t.V2 like '3%')  and v1 like '%(WEB日志分析)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='B.地址异常'  where  t.V2 like '4%' and v1 like '%(WEB日志分析)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='C.服务器异常'  where  t.V2 like '5%'  and v1 like '%(WEB日志分析)%'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $sql = "update  {$this->report_monitor_config} t set V2_GROUP='D.服务器'  where  ( t.V2 = '队列' or t.V2 ='Load' or t.V2 ='IO' or t.V2 ='磁盘' or t.V2 ='Mem内存剩余' or t.V2 ='TCP连接' or t.V2 ='CPU' or t.V2 ='运行天数')  and v1 like '%(WEB日志分析)%' ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     echo 'ok';
 }
 /**
  * Fetch a result row as an array
  * @param Mixed qHanle		The query handle
  * @param Number flags
  * @return Array
  */
 protected function myoci_fetch_array($qHanle, $flags)
 {
     if (function_exists("oci_fetch_array")) {
         return oci_fetch_array($qHanle, $flags);
     }
     $data = array();
     if (ocifetchinto($qHanle, $data, $flags)) {
         return $data;
     }
     return array();
 }
Example #26
0
 function &metaColumns($table, $normalize = true)
 {
     static $typeMap = array('VARCHAR' => 'C', 'VARCHAR2' => 'C', 'CHAR' => 'C', 'VARBINARY' => 'C', 'BINARY' => 'C', 'NCHAR' => 'C', 'NVARCHAR' => 'C', 'NVARCHAR2' => 'C', 'NCLOB' => 'X', 'LONG' => 'X', 'LONG VARCHAR' => 'X', 'CLOB' => 'X', 'LONG RAW' => 'B', 'LONG VARBINARY' => 'B', 'BLOB' => 'B', 'DATE' => 'D', 'TIMESTAMP' => 'T', 'INT' => 'I', 'SMALLINT' => 'I', 'INTEGER' => 'I');
     $arr = explode('.', $table);
     $table = $this->qstr(strtoupper($arr[count($arr) - 1]));
     $stmt = $this->execute(sprintf($this->META_COLUMNS_SQL, $table));
     if (!$stmt) {
         return false;
     }
     $retarr = array();
     $row = array();
     while (ocifetchinto($stmt, $row, OCI_NUM)) {
         $field = array();
         if ($this->RESULT_FIELD_NAME_LOWER) {
             $field['name'] = strtolower($row[0]);
         } else {
             $field['name'] = $row[0];
         }
         $field['type'] = preg_replace('/\\([0-9]+\\)/', '', $row[1]);
         $field['maxLength'] = $row[2];
         $field['scale'] = isset($row[3]) ? $row[3] : null;
         if ($field['type'] == 'NUMBER') {
             if ($field['scale'] == 0) {
                 $field['type'] = 'INT';
             }
             $field['maxLength'] = isset($row[4]) ? $row[4] : null;
         }
         $field['notNull'] = strncmp($row[5], 'NOT', 3) === 0;
         $field['binary'] = strpos($field['type'], 'BLOB') !== false;
         $field['hasDefault'] = isset($row[6]);
         $field['defaultValue'] = isset($row[6]) ? $row[6] : null;
         $t = strtoupper($field['type']);
         if (isset($typeMap[$t])) {
             $field['simpleType'] = $typeMap[$t];
         } else {
             $field['simpleType'] = 'N';
         }
         $field['autoIncrement'] = false;
         $field['primaryKey'] = false;
         if ($normalize) {
             $retarr[strtoupper($field['name'])] = $field;
         } else {
             $retarr[$field['name']] = $field;
         }
     }
     ocifreestatement($stmt);
     // 确定主键字段
     $ptab = 'USER_';
     $sql = "SELECT /*+ RULE */ distinct b.column_name FROM {$ptab}CONSTRAINTS a, {$ptab}CONS_COLUMNS b WHERE ( UPPER(b.table_name) = ({$table}))  AND (UPPER(a.table_name) = ({$table}) and a.constraint_type = 'P') AND (a.constraint_name = b.constraint_name)";
     $stmt = $this->execute($sql);
     if ($stmt) {
         $row = array();
         while (ocifetchinto($stmt, $row, OCI_NUM)) {
             $pkname = strtoupper($row[0]);
             if (isset($retarr[$pkname])) {
                 $retarr[$pkname]['primaryKey'] = true;
                 if ($retarr[$pkname]['type'] == 'INT') {
                     $retarr[$pkname]['simpleType'] = 'R';
                 }
             }
         }
         ocifreestatement($stmt);
     }
     return $retarr;
 }
 /**
  * Result - associative array
  *
  * Returns the result set as an array
  *
  * @access  private
  * @return  array
  */
 function _fetch_assoc(&$row)
 {
     $id = $this->curs_id ? $this->curs_id : $this->stmt_id;
     return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
 }
Example #28
0
 /**
  * Fetches all the rows for a select query. Returns FALSE if query failed and
  * DB_OK for all other queries
  *
  * @deprecated
  *
  * @param  resource $result
  * @return array    All rows in result set
  */
 private function setResult($result)
 {
     $GLOBALS['log']->info('call to DBManager::setResult() is deprecated');
     if (PEAR::isError($result) === true) {
         $GLOBALS['log']->error($msg);
         $result = FALSE;
     } elseif ($result != DB_OK) {
         // must be a result
         $GLOBALS['log']->fatal("setResult:" . print_r($result, true));
         $row = array();
         $rows = array();
         while (ocifetchinto($result, $row, OCI_ASSOC | OCI_RETURN_NULLS | OCI_RETURN_LOBS)) {
             $err = ocierror($result);
             if ($err == false) {
                 $rows[] = $row;
             } else {
                 print_r($err);
             }
         }
         $result = $rows;
     }
     $GLOBALS['log']->fatal("setResult: returning rows from setResult");
     return $result;
 }
 /**
  *	This function will execute the SQL statement and return the records as an associative array. Optionally, you
  *	can limit the number of records that are returned. Optionally, you can also specify which record to start
  *	from.
  *
  *	@param $sql	The SQL statement to use.
  *	@param $limit	(optional) How many records to return
  *	@param $offset	(optional) Where to start from
  *
  *	@returns	The records matching the SQL statement as an associative array.
  */
 function getRecords($sql, $limit = -1, $offset = -1)
 {
     $sql = $this->_prepareSqlForLimit($sql, $limit, $offset);
     $result = $this->_connectAndExec($sql);
     $type = YDConfig::get('YD_DB_FETCHTYPE') == YD_DB_FETCH_NUM ? OCI_NUM : OCI_ASSOC;
     $dataset = array();
     while (ocifetchinto($result, $line, $type)) {
         array_push($dataset, $this->_lowerKeyNames($line));
     }
     OCIFreeStatement($result);
     return $dataset;
 }
Example #30
0
 /**
  * Build db-specific report
  * @access: private
  */
 function _sql_report($mode, $query = '')
 {
     switch ($mode) {
         case 'start':
             break;
         case 'fromcache':
             $endtime = explode(' ', microtime());
             $endtime = $endtime[0] + $endtime[1];
             $result = @ociparse($this->db_connect_id, $query);
             $success = @ociexecute($result, OCI_DEFAULT);
             $row = array();
             while (@ocifetchinto($result, $row, OCI_ASSOC + OCI_RETURN_NULLS)) {
                 // Take the time spent on parsing rows into account
             }
             @ocifreestatement($result);
             $splittime = explode(' ', microtime());
             $splittime = $splittime[0] + $splittime[1];
             $this->sql_report('record_fromcache', $query, $endtime, $splittime);
             break;
     }
 }