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);
     }
 }
 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);
 }
 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";
 }
Beispiel #7
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);
     if (!$_REQUEST['orderby']) {
         $this->report_monitor_order();
     }
     //上面的减下来
     $sql = "update  {$this->report_monitor_config} set orderby=orderby+1 where  v1=:v1 and orderby<:orderby";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['v1']);
     _ocibindbyname($stmt, ':orderby', $_REQUEST['orderby']);
     $oci_error = _ociexecute($stmt);
     //本身上升
     $sql = "update  {$this->report_monitor_config} set orderby=1 where  v1=:v1 and v2=:v2";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_REQUEST['v1']);
     _ocibindbyname($stmt, ':v2', $_REQUEST['v2']);
     $oci_error = _ociexecute($stmt);
     header("location: {$_SERVER['HTTP_REFERER']}");
 }
 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);
 }
Beispiel #10
0
 function _initialize()
 {
     //暂时关闭
     exit;
     #每小时执行一次
     if (date('i') != 30) {
         exit;
     }
     if (is_writable('/dev/shm/')) {
         $change = false;
         $basefile = '/dev/shm/sql_' . VHOST;
         $sqls = unserialize(file_get_contents($basefile));
         if (empty($sqls)) {
             echo "empty sqls\n";
             $change = true;
         }
         echo "sql_count:" . count($sqls) . "\n";
         foreach ($sqls as $k => $v) {
             if ($v['type'] != 'oci' || $v['paser_txt'] || $v['vhost'] != VHOST) {
                 continue;
             }
             if (strpos($v['sql'], 'alter session') !== false) {
                 continue;
             }
             $conn_db = _ocilogon($v['db']);
             $sql = "EXPLAIN PLAN SET STATEMENT_ID='pps' FOR " . $v['sql'];
             $stmt = _ociparse($conn_db, $sql);
             _ociexecute($stmt);
             $sql = "SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY('PLAN_TABLE','pps','BASIC'))";
             $stmt = _ociparse($conn_db, $sql);
             _ociexecute($stmt);
             $_row = array();
             $row_text = NULL;
             while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
                 echo "change:explain\n";
                 $change = true;
                 $row_text .= "\n" . $_row['PLAN_TABLE_OUTPUT'];
             }
             _ocilogoff($conn_db);
             $sqls[$k]['paser_txt'] = $row_text;
             $sql_type = NULL;
             $vv = _sql_table_txt($v['sql'], $sql_type);
             //
             $type = NULL;
             if (strpos($v['act'], 'project') !== false) {
                 $type = "(项目)";
             }
             if (strpos($row_text, 'TABLE ACCESS FULL') !== false) {
                 _status(1, VHOST . "(BUG错误)", "问题SQL", "全表扫描{$type}", "{$v['db']}.{$vv}@{$v['act']}", $v['sql'] . "\n" . $row_text);
             }
             if (strpos($row_text, ' JOIN ') !== false) {
                 _status(1, VHOST . "(BUG错误)", "问题SQL", "多表查询{$type}", "{$v['db']}.{$vv}@{$v['act']}", $v['sql'] . "\n" . $row_text);
             }
         }
         foreach ($sqls as $k => $v) {
             if (time() > strtotime($v['add_time']) + 3600) {
                 echo "change:time\n";
                 $change = true;
                 unset($sqls[$k]);
             }
         }
         if ($change) {
             echo "write file.\n";
             file_put_contents($basefile, serialize($sqls));
         }
         die("OK\n");
     }
 }
 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';
 }
Beispiel #12
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";
 }
Beispiel #13
0
 function _initialize()
 {
     set_time_limit(0);
     ini_set("display_errors", true);
     echo "<pre>";
     $conn_db = _ocilogon($this->db);
     if (!$conn_db) {
         return;
     }
     //每小时汇总[上小时+当前小时]
     $hourtime = strtotime(date('Y-m-d H:0:0') . " -1 hour");
     $endtime = time();
     if ($_GET['hour']) {
         $hourtime = strtotime($_GET['hour']);
         $endtime = strtotime("{$_GET['hour']} +1 day");
     }
     //所有配置信息 包含虚列
     $sql = "select * from  {$this->report_monitor_config} t  where id>0";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $this->all_config = $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $this->all_config[$_row['V1'] . $_row['V2']] = $_row;
     }
     $addwhere = null;
     if ($_GET['v1']) {
         $addwhere .= " and v1=:v1 ";
     }
     if ($_GET['v2']) {
         $addwhere .= " and v2=:v2 ";
     }
     for ($it = $hourtime; $it <= $endtime; $it += 3600) {
         $hour = date('Y-m-d H:00:00', $it);
         echo "hour:{$hour}\n";
         //每小时数据汇总memory_max,memory_total, cpu_user_time_max,cpu_user_time_total,cpu_sys_time_max,cpu_sys_time_total
         $sql = "select to_char(t.cal_date, 'yyyy-mm-dd hh24') cal_date, t.v1, decode(t.v2,null,'null',v2) v2,\n                    decode(t.v3,null,'null',v3) v3, sum(fun_count) fun_count,avg(fun_count) fun_count_avg,max(abs(nvl(v6,0))) DIFF_TIME, sum(abs(t.total_diff_time)) total_diff_time,\n                    max(memory_max) memory_max, sum(memory_total) memory_total, max(cpu_user_time_max) cpu_user_time_max,sum(cpu_user_time_total) cpu_user_time_total, max(cpu_sys_time_max) cpu_sys_time_max, sum(cpu_sys_time_total) cpu_sys_time_total\n                    from {$this->report_monitor} t\n                    where cal_date >= to_date(:hour,'yyyy-mm-dd hh24:mi:ss') and cal_date <to_date(:hour,'yyyy-mm-dd hh24:mi:ss')+1/24\n                    {$addwhere}\n                    group by t.v1, t.v2,t.v3, to_char(t.cal_date, 'yyyy-mm-dd hh24')  ";
         $stmt_list = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt_list, ':hour', $hour);
         if ($_GET['v1']) {
             _ocibindbyname($stmt_list, ':v1', $_GET['v1']);
         }
         if ($_GET['v2']) {
             _ocibindbyname($stmt_list, ':v2', $_GET['v2']);
         }
         $oci_error = _ociexecute($stmt_list);
         print_r($oci_error);
         $_row = array();
         while (ocifetchinto($stmt_list, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
             $_row2 = $this->all_config[$_row['V1'] . $_row['V2']];
             //正常情况下从原始表读取数据.如果是按照最后一分钟计算.走min表
             //虚列数据不进行计算
             if ($_row2['VIRTUAL_COLUMNS'] == 0) {
                 if ($_row2['HOUR_COUNT_TYPE'] == 4) {
                     $_row['FUN_COUNT'] = $_row['FUN_COUNT_AVG'];
                 }
                 $sql = "update {$this->report_monitor_hour} set fun_count=:fun_count,diff_time=:diff_time, total_diff_time=:total_diff_time,\n                memory_max=:memory_max, memory_total=:memory_total, cpu_user_time_max=:cpu_user_time_max, cpu_user_time_total=:cpu_user_time_total, cpu_sys_time_max=:cpu_sys_time_max, cpu_sys_time_total=:cpu_sys_time_total\n                where v1=:v1 and v2=:v2 and v3=:v3  and  cal_date=to_date(:cal_date,'yyyy-mm-dd hh24') ";
                 $stmt = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt, ':v1', $_row['V1']);
                 _ocibindbyname($stmt, ':v2', $_row['V2']);
                 _ocibindbyname($stmt, ':v3', $_row['V3']);
                 _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                 _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
                 _ocibindbyname($stmt, ':diff_time', abs($_row['DIFF_TIME']));
                 _ocibindbyname($stmt, ':total_diff_time', abs($_row['TOTAL_DIFF_TIME']));
                 _ocibindbyname($stmt, ':memory_max', $_row['MEMORY_MAX']);
                 _ocibindbyname($stmt, ':memory_total', $_row['MEMORY_TOTAL']);
                 _ocibindbyname($stmt, ':cpu_user_time_max', $_row['CPU_USER_TIME_MAX']);
                 _ocibindbyname($stmt, ':cpu_user_time_total', $_row['CPU_USER_TIME_TOTAL']);
                 _ocibindbyname($stmt, ':cpu_sys_time_max', $_row['CPU_SYS_TIME_MAX']);
                 _ocibindbyname($stmt, ':cpu_sys_time_total', $_row['CPU_SYS_TIME_TOTAL']);
                 $oci_error = _ociexecute($stmt);
                 print_r($oci_error);
                 _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'monitor_hour(update)', VIP);
                 $ocirowcount = ocirowcount($stmt);
                 if ($ocirowcount < 1) {
                     $sql = "insert into {$this->report_monitor_hour} (cal_date,v1,v2,v3,fun_count,diff_time, total_diff_time,memory_max,memory_total, cpu_user_time_max,cpu_user_time_total,cpu_sys_time_max,cpu_sys_time_total)\n                    values (to_date(:cal_date,'yyyy-mm-dd hh24'),:v1,:v2,:v3,:fun_count,:diff_time, :total_diff_time, :memory_max,:memory_total, :cpu_user_time_max,:cpu_user_time_total,:cpu_sys_time_max,:cpu_sys_time_total) ";
                     $stmt = _ociparse($conn_db, $sql);
                     _ocibindbyname($stmt, ':v1', $_row['V1']);
                     _ocibindbyname($stmt, ':v2', $_row['V2']);
                     _ocibindbyname($stmt, ':v3', $_row['V3']);
                     _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                     _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
                     _ocibindbyname($stmt, ':diff_time', abs($_row['DIFF_TIME']));
                     _ocibindbyname($stmt, ':total_diff_time', abs($_row['TOTAL_DIFF_TIME']));
                     _ocibindbyname($stmt, ':memory_max', $_row['MEMORY_MAX']);
                     _ocibindbyname($stmt, ':memory_total', $_row['MEMORY_TOTAL']);
                     _ocibindbyname($stmt, ':cpu_user_time_max', $_row['CPU_USER_TIME_MAX']);
                     _ocibindbyname($stmt, ':cpu_user_time_total', $_row['CPU_USER_TIME_TOTAL']);
                     _ocibindbyname($stmt, ':cpu_sys_time_max', $_row['CPU_SYS_TIME_MAX']);
                     _ocibindbyname($stmt, ':cpu_sys_time_total', $_row['CPU_SYS_TIME_TOTAL']);
                     $oci_error = _ociexecute($stmt);
                     print_r($oci_error);
                     if ($oci_error) {
                         $get_included_files = basename(array_shift(get_included_files()));
                         _status(1, VHOST . "(BUG错误)", 'SQL错误', $get_included_files . '/' . $_GET['act'], var_export($oci_error, true) . "|" . var_export($_row, true));
                     } else {
                         _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'hour', VIP);
                     }
                 }
                 //虚数列数据
                 $compare_group = array_filter(explode('|', '|' . $_row2['COMPARE_GROUP']));
                 if (count($compare_group) > 0) {
                     foreach ($compare_group as $v) {
                         $sql = "update {$this->report_monitor_hour} set fun_count=:fun_count,diff_time=:diff_time,total_diff_time=:total_diff_time,\n                                        memory_max=:memory_max, memory_total=:memory_total, cpu_user_time_max=:cpu_user_time_max, cpu_user_time_total=:cpu_user_time_total, cpu_sys_time_max=:cpu_sys_time_max, cpu_sys_time_total=:cpu_sys_time_total\n                                        where v1=:v1 and v2=:v2 and v3=:v3  and  cal_date=to_date(:cal_date,'yyyy-mm-dd hh24') ";
                         $stmt = _ociparse($conn_db, $sql);
                         _ocibindbyname($stmt, ':v1', $v);
                         _ocibindbyname($stmt, ':v2', $_row['V1'] . '_' . $_row['V2']);
                         _ocibindbyname($stmt, ':v3', $_row['V3']);
                         _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                         _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
                         _ocibindbyname($stmt, ':diff_time', abs($_row['DIFF_TIME']));
                         _ocibindbyname($stmt, ':total_diff_time', abs($_row['TOTAL_DIFF_TIME']));
                         _ocibindbyname($stmt, ':memory_max', $_row['MEMORY_MAX']);
                         _ocibindbyname($stmt, ':memory_total', $_row['MEMORY_TOTAL']);
                         _ocibindbyname($stmt, ':cpu_user_time_max', $_row['CPU_USER_TIME_MAX']);
                         _ocibindbyname($stmt, ':cpu_user_time_total', $_row['CPU_USER_TIME_TOTAL']);
                         _ocibindbyname($stmt, ':cpu_sys_time_max', $_row['CPU_SYS_TIME_MAX']);
                         _ocibindbyname($stmt, ':cpu_sys_time_total', $_row['CPU_SYS_TIME_TOTAL']);
                         $oci_error = _ociexecute($stmt);
                         print_r($oci_error);
                         _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'monitor_hour(update)', VIP);
                         $ocirowcount = ocirowcount($stmt);
                         if ($ocirowcount < 1) {
                             $sql = "insert into {$this->report_monitor_hour} (cal_date,v1,v2,v3,fun_count,diff_time,total_diff_time,memory_max,memory_total, cpu_user_time_max,cpu_user_time_total,cpu_sys_time_max,cpu_sys_time_total)\n                                            values (to_date(:cal_date,'yyyy-mm-dd hh24'),:v1,:v2,:v3,:fun_count,:diff_time,:total_diff_time, :memory_max,:memory_total, :cpu_user_time_max,:cpu_user_time_total,:cpu_sys_time_max,:cpu_sys_time_total) ";
                             $stmt = _ociparse($conn_db, $sql);
                             _ocibindbyname($stmt, ':v1', $v);
                             _ocibindbyname($stmt, ':v2', $_row['V1'] . '_' . $_row['V2']);
                             _ocibindbyname($stmt, ':v3', $_row['V3']);
                             _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                             _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
                             _ocibindbyname($stmt, ':diff_time', abs($_row['DIFF_TIME']));
                             _ocibindbyname($stmt, ':total_diff_time', abs($_row['TOTAL_DIFF_TIME']));
                             _ocibindbyname($stmt, ':memory_max', $_row['MEMORY_MAX']);
                             _ocibindbyname($stmt, ':memory_total', $_row['MEMORY_TOTAL']);
                             _ocibindbyname($stmt, ':cpu_user_time_max', $_row['CPU_USER_TIME_MAX']);
                             _ocibindbyname($stmt, ':cpu_user_time_total', $_row['CPU_USER_TIME_TOTAL']);
                             _ocibindbyname($stmt, ':cpu_sys_time_max', $_row['CPU_SYS_TIME_MAX']);
                             _ocibindbyname($stmt, ':cpu_sys_time_total', $_row['CPU_SYS_TIME_TOTAL']);
                             $oci_error = _ociexecute($stmt);
                             print_r($oci_error);
                             if ($oci_error) {
                                 $get_included_files = basename(array_shift(get_included_files()));
                                 _status(1, VHOST . "(BUG错误)", 'SQL错误', $get_included_files . '/' . $_GET['act'], var_export($oci_error, true) . "|" . var_export($_row, true));
                             } else {
                                 _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'hour', VIP);
                             }
                         }
                     }
                 }
             }
         }
     }
     //刷新一天的数据
     $sql = "select to_char(t.cal_date, 'yyyy-mm-dd') cal_date, t.v1, decode(t.v2,null,'null',v2) v2,\n                  sum(fun_count) fun_count,avg(fun_count) fun_count_avg from {$this->report_monitor_hour} t\n                  where cal_date >= to_date(:m_date,'yyyy-mm-dd') and cal_date<to_date(:m_date,'yyyy-mm-dd')+1 {$addwhere}\n                  group by t.v1, t.v2, to_char(t.cal_date, 'yyyy-mm-dd')";
     $stmt_list = _ociparse($conn_db, $sql);
     echo htmlspecialchars($sql);
     var_dump(date("Y-m-d", $hourtime));
     //print_r($_GET);
     _ocibindbyname($stmt_list, ':m_date', date("Y-m-d", $hourtime));
     if ($_GET['v1']) {
         _ocibindbyname($stmt_list, ':v1', $_GET['v1']);
     }
     if ($_GET['v2']) {
         _ocibindbyname($stmt_list, ':v2', $_GET['v2']);
     }
     $oci_error = _ociexecute($stmt_list);
     print_r($oci_error);
     $_row = array();
     while (ocifetchinto($stmt_list, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         //补全v1的信息
         $sql = "select * from {$this->report_monitor_v1} where v1=:v1  ";
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':v1', $_row['V1']);
         $oci_error = _ociexecute($stmt);
         print_r($oci_error);
         $_row_config = array();
         ocifetchinto($stmt, $_row_config, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
         if (!$_row_config) {
             $sql = "insert into {$this->report_monitor_v1} (v1,id) values (:v1,seq_{$this->report_monitor}.nextval) ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'v1_config', VIP);
         }
         $_row_config = $this->all_config[$_row['V1'] . $_row['V2']];
         //如果是不累计的,重置总量为上个小时的总量
         if ($_row_config['DAY_COUNT_TYPE'] == 1 || $_row_config['DAY_COUNT_TYPE'] == 2 || $_row_config['DAY_COUNT_TYPE'] == 5 || $_row_config['DAY_COUNT_TYPE'] == 7) {
             //echo "只计算最后一小时\n";
             $sql2 = "select to_char(max(cal_date),'yyyy-mm-dd hh24:mi:ss') cal_date from\n                {$this->report_monitor_hour} where cal_date>=to_date(:cal_date,'yyyy-mm-dd')\n                and  cal_date<to_date(:cal_date,'yyyy-mm-dd')+1 and v1=:v1 and v2=:v2 ";
             $stmt2 = _ociparse($conn_db, $sql2);
             _ocibindbyname($stmt2, ':v1', $_row['V1']);
             _ocibindbyname($stmt2, ':v2', $_row['V2']);
             _ocibindbyname($stmt2, ':cal_date', $_row['CAL_DATE']);
             $oci_error2 = _ociexecute($stmt2);
             print_r($oci_error2);
             $_row2 = array();
             ocifetchinto($stmt2, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
             //print_r($_row2);
             $sql = "select  t.v1, t.v2,  sum(fun_count) fun_count,avg(fun_count) fun_count_avg\n \t\t\tfrom  {$this->report_monitor_hour} t where cal_date=to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss')\n                    and v1=:v1 and v2=:v2  group by t.v1, t.v2";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             _ocibindbyname($stmt, ':v2', $_row['V2']);
             _ocibindbyname($stmt, ':cal_date', $_row2['CAL_DATE']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             $_row2 = array();
             ocifetchinto($stmt, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
             $_row['FUN_COUNT'] = $_row2['FUN_COUNT'];
             //v3个数
             if ($_row_config['DAY_COUNT_TYPE'] == 7) {
                 //echo "计算V3个数\n";
                 $sql = "select  count(distinct(t.v3)) num\n \t\t\tfrom  {$this->report_monitor_hour} t where cal_date>=to_date(:cal_date,'yyyy-mm-dd')\n                    and v1=:v1 and v2=:v2";
                 $stmt = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt, ':v1', $_row['V1']);
                 _ocibindbyname($stmt, ':v2', $_row['V2']);
                 _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                 $oci_error = _ociexecute($stmt);
                 print_r($oci_error);
                 ocifetchinto($stmt, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
                 $_row['FUN_COUNT'] = $_row2['NUM'];
                 //echo " num:{$_row['FUN_COUNT']} \n";
             }
             //最后一小时的平均值
             if ($_row_config['DAY_COUNT_TYPE'] == 5) {
                 $_row['FUN_COUNT'] = $_row2['FUN_COUNT_AVG'];
             }
         }
         //当天的平均数
         if ($_row_config['DAY_COUNT_TYPE'] == 6) {
             $_row['FUN_COUNT'] = $_row['FUN_COUNT_AVG'];
         }
         //print_r($_row);
         //echo " num:{$_row['FUN_COUNT']} \n";
         $sql = "update {$this->report_monitor_date} set fun_count=:fun_count\n              where v1=:v1 and v2=:v2 and cal_date=to_date(:cal_date,'yyyy-mm-dd') ";
         $stmt2 = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt2, ':v1', $_row['V1']);
         _ocibindbyname($stmt2, ':v2', $_row['V2']);
         _ocibindbyname($stmt2, ':cal_date', $_row['CAL_DATE']);
         _ocibindbyname($stmt2, ':fun_count', $_row['FUN_COUNT']);
         $oci_error = _ociexecute($stmt2);
         print_r($oci_error);
         _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'monitor_date(update)', VIP);
         $_row_count = ocirowcount($stmt2);
         if (!$_row_count) {
             $sql = "insert into {$this->report_monitor_date} (cal_date,v1,v2,fun_count) values\n                    (to_date(:cal_date,'yyyy-mm-dd'),:v1,:v2,:fun_count) ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             _ocibindbyname($stmt, ':v2', $_row['V2']);
             _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
             _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'date', VIP);
         }
         $compare_group = array_filter(explode('|', '|' . $_row_config['COMPARE_GROUP']));
         if (count($compare_group) > 0) {
             foreach ($compare_group as $v) {
                 $sql = "update {$this->report_monitor_date} set fun_count=:fun_count\n                                  where v1=:v1 and v2=:v2 and cal_date=to_date(:cal_date,'yyyy-mm-dd') ";
                 $stmt2 = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt2, ':v1', $v);
                 _ocibindbyname($stmt2, ':v2', $_row['V1'] . '_' . $_row['V2']);
                 _ocibindbyname($stmt2, ':cal_date', $_row['CAL_DATE']);
                 _ocibindbyname($stmt2, ':fun_count', $_row['FUN_COUNT']);
                 $oci_error = _ociexecute($stmt2);
                 print_r($oci_error);
                 _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'monitor_date(update)', VIP);
                 $_row_count = ocirowcount($stmt2);
                 if (!$_row_count) {
                     $sql = "insert into {$this->report_monitor_date} (cal_date,v1,v2,fun_count) values\n                    (to_date(:cal_date,'yyyy-mm-dd'),:v1,:v2,:fun_count) ";
                     $stmt = _ociparse($conn_db, $sql);
                     _ocibindbyname($stmt, ':v1', $v);
                     _ocibindbyname($stmt, ':v2', $_row['V1'] . '_' . $_row['V2']);
                     _ocibindbyname($stmt, ':cal_date', $_row['CAL_DATE']);
                     _ocibindbyname($stmt, ':fun_count', $_row['FUN_COUNT']);
                     $oci_error = _ociexecute($stmt);
                     print_r($oci_error);
                     _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'date', VIP);
                 }
             }
         }
         if (!$_row_config) {
             $sql = "select count(*) c from {$this->report_monitor_config} where v1=:v1 ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             $_row2 = array();
             ocifetchinto($stmt, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
             $sql = "select * from {$this->report_monitor_v1} where  v1=:v1 ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             $_row3 = array();
             ocifetchinto($stmt, $_row3, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
             $sql = "insert into  {$this->report_monitor_config} (v1,v2,orderby,id,day_count_type,hour_count_type,percent_count_type)\n                values (:v1,:v2,:orderby,seq_{$this->report_monitor}.nextval,:day_count_type,:hour_count_type,:percent_count_type) ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $_row['V1']);
             _ocibindbyname($stmt, ':v2', $_row['V2']);
             _ocibindbyname($stmt, ':day_count_type', intval($_row3['DAY_COUNT_TYPE']));
             _ocibindbyname($stmt, ':hour_count_type', intval($_row3['HOUR_COUNT_TYPE']));
             _ocibindbyname($stmt, ':percent_count_type', intval($_row3['PERCENT_COUNT_TYPE']));
             if ($_row['V2'] == '汇总') {
                 _ocibindbyname($stmt, ':orderby', intval(0));
             } else {
                 _ocibindbyname($stmt, ':orderby', max(1, $_row2['C'] + 1));
             }
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
             _status(1, VHOST . "(PHPAPM)", "统计消耗", $_row['V1'], 'config', VIP);
         }
     }
     //清除过期数据
     if ($_GET['del'] && rand(1, 10) == 1) {
         $sql = "delete from  {$this->report_monitor} where cal_date<=sysdate-10 ";
         $stmt_list = _ociparse($conn_db, $sql);
         $oci_error = _ociexecute($stmt_list);
         print_r($oci_error);
     }
 }
Beispiel #14
0
 function _initialize()
 {
     header("Expires: " . date('r', strtotime('+ 30 min')));
     $conn_db = _ocilogon($this->db);
     //剩下没解决的
     $sql = "select sum(t.fun_count) c from {$this->report_monitor_date} t where t.v1 like '%(项目满意分)'  and t.cal_date = trunc(sysdate)";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row['C'] = sprintf('%02d', $_row['C']);
     $sql = "select sum(t.fun_count) c from {$this->report_monitor_date} t where t.v1 like '%(项目文档满意分)'  and t.cal_date = trunc(sysdate)";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row2 = array();
     ocifetchinto($stmt, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row2['C'] = sprintf('%02d', $_row2['C']);
     if ($_row['C']) {
         echo "\$('#nbi_num_xm').html('文档:{$_row2['C']}分');\$('#nbi_num_1').html('技术:{$_row['C']}分');";
     }
     //显示其他定制的分数
     $sql = "select *  from {$this->report_monitor_v1} t where t.PINFEN_RULE_NAME is not null ";
     $stmt_list = _ociparse($conn_db, $sql);
     _ociexecute($stmt_list);
     $_row = $_row2 = array();
     $ki = 1;
     while (ocifetchinto($stmt_list, $_row2, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $_row = unserialize($_row2['PINFEN_RULE']);
         if ($_row2['PINFEN_RULE_NAME'] && $_row['pinfen_name'] && $_row['koufen_name'] && $_row['base_num'] && $_row['just_rule'] && $_row['pinfen_step'] && $_row['rule_num']) {
             $ki++;
             $sql = "select sum(t.fun_count) c from {$this->report_monitor_date} t where t.v1 =:v1  and t.cal_date = trunc(sysdate)";
             $stmt = _ociparse($conn_db, $sql);
             ocibindbyname($stmt, ':v1', $_row['pinfen_name']);
             _ociexecute($stmt);
             $_row3 = array();
             ocifetchinto($stmt, $_row3, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
             $_row3['C'] = sprintf('%02d', $_row3['C']);
             echo "try{\$('#nbi_num_{$ki}').html('{$_row2['PINFEN_RULE_NAME']}:{$_row3['C']}分');}catch(e){}";
         }
     }
     //总pv量
     $all_num = 0;
     $sql = "select *  from {$this->report_monitor_config} t where v1 like '%(WEB日志分析)' and v2<>'汇总'";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $this->host = $_row = array();
     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;
     }
     $s1 = date('Y-m-d');
     $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 v1 like '%(WEB日志分析)' and v2<>'汇总' ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':s1', $s1);
     $oci_error = _ociexecute($stmt);
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         if (!$this->host[$_row['V2']]['V2_CONFIG_OTHER']['NO_COUNT']) {
             $all_num += $_row['FUN_COUNT'];
         }
     }
     if ($all_num > 10000 * 10000) {
         $all_num = round($all_num / 10000 / 10000, 1) . '亿';
     } elseif ($all_num > 10000) {
         $all_num = round($all_num / 10000, 1) . '万';
     }
     echo "\$('#nbi_num_pv').html('pv:{$all_num}');";
 }
Beispiel #15
0
 function _initialize()
 {
     #每小时执行一次
     if (date('i') != 30) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     _ociexecute(_ociparse($conn_db, "alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'"));
     $sql = "select * from {$this->report_monitor_v1}  where IS_DUTY=1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $v1_all = $_row_all = array();
     while (ocifetchinto($stmt, $_row_all, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $v1_all[$_row_all['V1']] = $_row_all['V1'];
     }
     $sql = "select t.lookup, trunc(t.cal_date) cal_date, v1\n               from {$this->report_monitor_date} t\n               where t.cal_date >= trunc(sysdate - 7)\n               and t.cal_date < trunc(sysdate - 6) and t.lookup is null\n               group by trunc(t.cal_date), t.lookup, v1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         if ($v1_all[$_row['V1']]) {
             continue;
         }
         _status(1, VHOST . "(BUG错误)", "验收责任未到位", $_row['V1'], "", VIP);
     }
     if ($_GET['no_manyi']) {
         return;
     }
     //技术基础分
     _status(100, VHOST . "(项目满意分)", "基础分", "基础分", "基础分", VIP, 0, 'replace');
     //错误率占10%
     $sql = "select (select nvl(sum(fun_count), 0)\n             from {$this->report_monitor_date} t\n            where v1 like '%(BUG错误)'\n              and v2 = 'SQL错误'\n              and t.cal_date = trunc(sysdate)) php_num,\n           (select nvl(sum(fun_count), 0)\n             from {$this->report_monitor_date} t\n            where v1 like '%(BUG错误)'\n              and v2 = 'PHP错误'\n              and t.cal_date = trunc(sysdate)) sql_num,\n           (select sum(t.fun_count)\n             from {$this->report_monitor_date} t\n            where v1 like '%(WEB日志分析)'\n              and t.cal_date = trunc(sysdate)) web_num  from dual ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row['SQLERR'] = round(($_row['PHP_NUM'] + $_row['SQL_NUM']) / $_row['WEB_NUM'] * 100, 2);
     $manyi = 0;
     if ($_row['SQLERR'] > 1) {
         $manyi = -10;
     } elseif ($_row['SQLERR'] < 0.1) {
         $manyi = 0;
     } else {
         $manyi = -($_row['SQLERR'] * 10);
     }
     _status($manyi, VHOST . "(项目满意分)", "PHP+SQL错误率", "PHP+SQL错误率", "PHP_NUM:{$_row['PHP_NUM']},SQL_NUM:{$_row['SQL_NUM']},WEB_NUM:{$_row['WEB_NUM']}@{$_row['SQLERR']}%", VIP, 0, 'replace');
     //sql量40%
     $sql = "select (select nvl(sum(fun_count), 0)\n             from {$this->report_monitor_date} t\n            where v1 like '%(SQL统计)'\n            and t.cal_date = trunc(sysdate - 2/24)) sql_num,\n           (select sum(t.fun_count)\n             from {$this->report_monitor_date} t\n            where v1 like '%(WEB日志分析)'\n              and t.cal_date = trunc(sysdate - 2/24)) web_num,\n            (select sum(t.fun_count)\n             from {$this->report_monitor_date} t\n            where v1 like '%(WEB日志分析)'\n              and t.cal_date = trunc(sysdate - 1)) y_web_num\n           from dual  ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row['SQLERR'] = round($_row['SQL_NUM'] / $_row['WEB_NUM'] * 100, 2);
     $manyi = 0;
     //按照前一天web量 判断
     if ($_row['Y_WEB_NUM'] >= 2000000) {
         if ($_row['SQLERR'] > 1 * 100) {
             $manyi = -40;
         } elseif ($_row['SQLERR'] < 6 / 10 * 100) {
             $manyi = 0;
         } else {
             $manyi = -(100 - ($_row['SQLERR'] - 6 / 10 * 100) / (1 * 100 - 6 / 10 * 100) * 100) * 40 / 100;
         }
     }
     if ($_row['Y_WEB_NUM'] < 2000000 && $_row['Y_WEB_NUM'] >= 300000) {
         if ($_row['SQLERR'] > 2 * 100) {
             $manyi = -40;
         } elseif ($_row['SQLERR'] < 1.2 * 100) {
             $manyi = 0;
         } else {
             $manyi = -(100 - ($_row['SQLERR'] - 1.2 * 100) / (2 * 100 - 1.2 * 100) * 100) * 40 / 100;
         }
     }
     if ($_row['Y_WEB_NUM'] < 300000) {
         if ($_row['SQLERR'] > 50 * 100) {
             $manyi = -40;
         } elseif ($_row['SQLERR'] < 30 * 100) {
             $manyi = 0;
         } else {
             $manyi = -(100 - ($_row['SQLERR'] - 30 * 100) / (50 * 100 - 30 * 100) * 100) * 40 / 100;
         }
     }
     _status($manyi, VHOST . "(项目满意分)", "SQL回源率", "SQL回源率", "SQL_NUM:{$_row['SQL_NUM']},WEB_NUM:{$_row['WEB_NUM']}@{$_row['SQLERR']}%", VIP, 0, 'replace');
     //单小时sql上限
     $sql = "select nvl(sum(fun_count), 0) sql_num\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(SQL统计)'\n                              and t.cal_date = trunc(sysdate)";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     //扣分单小时SQL上限
     $hour = date('H');
     $manyi = 0;
     $sql_error = round($_row['SQL_NUM'] / $hour);
     if ($sql_error >= 300000) {
         $num = 5 * intval(($sql_error - 300000) / 10000);
         $manyi = $manyi - $num;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:单小时SQL上限", "扣分:单小时SQL上限", "SQL_NUM:{$_row['SQL_NUM']},H:{$hour},平均sql量:{$sql_error}", VIP, 0, 'replace');
     //memcache 20%
     $sql = "select (select nvl(sum(fun_count), 0)\n             from {$this->report_monitor_date} t\n            where v1 like '%(Memcache)'\n              and t.cal_date = trunc(sysdate)) mem_num,\n           (select sum(t.fun_count)\n             from {$this->report_monitor_date} t\n            where v1 like '%(WEB日志分析)'\n              and t.cal_date = trunc(sysdate)) web_num from dual ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row['SQLERR'] = round($_row['MEM_NUM'] / $_row['WEB_NUM']);
     $manyi = 0;
     if ($_row['SQLERR'] > 6) {
         $manyi = -20;
     } elseif ($_row['SQLERR'] < 3) {
         $manyi = 0;
     } else {
         $manyi = -(100 - $_row['SQLERR'] / (6 - 3) * 100) * 20 / 100;
     }
     _status($manyi, VHOST . "(项目满意分)", "Memcache回源率", "Memcache回源率", "MEM_NUM:{$_row['MEM_NUM']},WEB_NUM:{$_row['WEB_NUM']}@" . $_row['SQLERR'] * 100 . "%", VIP, 0, 'replace');
     $sql = "select sum(t.fun_count) sqlerr\n               from {$this->report_monitor_hour} t\n              where v1 like '%(BUG错误)'\n                and v2 = '验收责任未到位'\n                and t.cal_date = trunc(sysdate-1/24,'hh24') ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = 10;
     if ($_row['SQLERR'] > 0) {
         $manyi = -10;
     }
     _status($manyi, VHOST . "(项目满意分)", "项目验收", "项目验收", $_row['SQLERR'], VIP, 0, 'replace');
     //tcp满意度 30%
     $sql = "select nvl(sum(fun_count), 0) TCP\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(WEB日志分析)' and V2='TCP连接'\n                              and t.cal_date = trunc(sysdate-1/24)";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = 0;
     if ($_row['TCP'] > 120) {
         //tcp超120 每增加10扣100 无上限
         $manyi = -(floor(($_row['TCP'] - 120) / 10) * 100);
     } elseif ($_row['TCP'] < 70) {
         $manyi = 0;
     } else {
         $manyi = 0 - (70 - ($_row['TCP'] - 70) / 100 * 100) * 30 / 100;
     }
     _status($manyi, VHOST . "(项目满意分)", "TCP连接数", "TCP连接数", 'TCP连接数:' . $_row['TCP'], VIP, 0, 'replace');
     //扣分项
     //机器重启当天,每小时扣200分
     $sql = "select fun_count from {$this->report_monitor_date} t where v1 like'%(WEB日志分析)' and v2='运行天数' and t.cal_date = trunc(sysdate - 1/24 )";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     $manyi = 0;
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     if ($_row['FUN_COUNT'] == '') {
         $manyi = -200;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:机器重启", "机器重启", NULL, VIP, 0, 'replace');
     //非定时任务扣分(非定时任务代码执行超过1秒占总量的0.1%以上,扣20分)
     $sql = "select (select nvl(sum(fun_count), 0)\n                     from {$this->report_monitor_date} t\n                    where v1 like '%(BUG错误)' and (v2 ='超时')\n                      and t.cal_date = trunc(sysdate)) sql_num,\n                  (select sum(t.fun_count)\n                     from {$this->report_monitor_date} t\n                    where v1 like '%(BUG错误)'\n                      and t.cal_date = trunc(sysdate)) web_num\n             from dual ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $_row['SQLERR'] = $_row['SQL_NUM'] / $_row['WEB_NUM'];
     $manyi = 0;
     if ($_row['SQL_NUM'] >= 1000) {
         $num = 5 * intval($_row['SQL_NUM'] / 1000);
         $manyi = $manyi - $num;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:执行超时", "执行超时", "OVER_NUM:{$_row['SQL_NUM']}", VIP, 0, 'replace');
     //问题sql扫描
     $sql = "select fun_count from {$this->report_monitor_date} t where v1 like'%(问题SQL)' and v2='全表扫描' and t.cal_date = trunc(sysdate-1/24)";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     $manyi = 0;
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     if ($_row['FUN_COUNT'] > 5) {
         $manyi = -10;
     } else {
         $manyi = -($_row['FUN_COUNT'] * 2.5);
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:问题sql", "全表扫描", '问题SQL' . $_row['FUN_COUNT'], VIP, 0, 'replace');
     // CPU>8 或者 LOAD>8 扣10分
     $sql = "select nvl(avg(fun_count), 0) CPU\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(WEB日志分析)' and V2='CPU'\n                              and t.cal_date = trunc(sysdate-1/24)";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $sql = "select nvl(avg(fun_count), 0) LOAD\n                                     from {$this->report_monitor_date} t\n                                    where v1 like '%(WEB日志分析)' and V2='Load'\n                                      and t.cal_date = trunc(sysdate-1/24)";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row_load = array();
     ocifetchinto($stmt, $_row_load, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = 0;
     if ($_row['CPU'] > 8 || $_row_load['LOAD'] > 8) {
         $manyi = -10;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:CPU LOAD", "CPU或LOAD过高", "CPU:{$_row['CPU']};LOAD:{$_row_load['LOAD']}", VIP, 0, 'replace');
     //web 500扣分 WEB日志出现5xx错误 [占0.05% 扣1分,没加一个万分点,扣1分,无上限]
     $sql = "select (select nvl(sum(fun_count), 0)\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(WEB日志分析)' and v2 like '5%'\n                              and t.cal_date = trunc(sysdate)) err_num,\n                           (select sum(t.fun_count)\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(WEB日志分析)'\n                              and t.cal_date = trunc(sysdate)) web_num from dual ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = 0;
     $sql = "select nvl(sum(fun_count), 0) err_t_num\n                                     from {$this->report_monitor_date} t\n                                    where v1 like '%(WEB日志分析)' and v2 = '499'\n                                      and t.cal_date = trunc(sysdate)";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row_t = array();
     ocifetchinto($stmt, $_row_t, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     if ($_row_t['ERR_T_NUM'] > 500) {
         $_row['ERR_NUM'] = $_row['ERR_NUM'] + $_row_t['ERR_T_NUM'];
     }
     $_row['SQLERR'] = round($_row['ERR_NUM'] / $_row['WEB_NUM'], 4);
     if ($_row['SQLERR'] >= 0.0005) {
         $manyi = ($manyi - ($_row['SQLERR'] - 0.0005)) * 10000;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:5xx错误", "5xx错误", "ERR_NUM:{$_row['ERR_NUM']},WEB_NUM:{$_row['WEB_NUM']}@" . $_row['SQLERR'] * 10000 . "万分", VIP, 0, 'replace');
     //[扣分:包含文件] "10个到∞个"每个扣除5分
     $sql = "select nvl(sum(fun_count), 0) fun_count\n                             from {$this->report_monitor_date} t\n                            where v1 like '%(包含文件)' and V2='10s到∞个'\n                              and t.cal_date = trunc(sysdate) ";
     $stmt = _ociparse($conn_db, $sql);
     $oci_error = _ociexecute($stmt);
     $_row = array();
     ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = 0;
     if ($_row['FUN_COUNT']) {
         $manyi = $manyi - $_row['FUN_COUNT'] * 5;
     }
     _status($manyi, VHOST . "(项目满意分)", "扣分:包含文件", "包含文件", "包含文件个数:{$_row['FUN_COUNT']}", VIP, 0, 'replace');
     $manyi = 0;
     //扣分:安全事故
     $sql = "select nvl(sum(fun_count), 0) C**K\n                                     from {$this->report_monitor_hour} t\n                                    where v1 like '%(BUG错误)' and V2='上传木马入侵'\n                                      and t.cal_date= trunc(sysdate-1/24,'hh24')";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row_cock = array();
     ocifetchinto($stmt, $_row_cock, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $manyi = $manyi - $_row_cock['C**K'] * 50;
     _status($manyi, VHOST . "(项目满意分)", "扣:安全", "安全事故", "入侵个数:{$_row_cock['C**K']}", VIP, 0, 'replace');
     //扣分:故障事故
     $sql = "select fun_count,v3,to_char(cal_date,'yyyy-mm-dd hh24') cal_date\n                                     from {$this->report_monitor_hour} t\n                                    where v1 like '%(BUG错误)' and V2='PHP错误'\n                                      and t.cal_date>= trunc(sysdate-1,'hh24') order by cal_date desc";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row_php = array();
     $manyi = 0;
     $data = $arr = array();
     $time = date('Y-m-d H', time() - 3600);
     while (ocifetchinto($stmt, $_row_php, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $data[$_row_php['V3']][$_row_php['CAL_DATE']]['count'] = $_row_php['FUN_COUNT'];
     }
     foreach ($data as $k => $v) {
         if (!isset($v[$time]['count']) || $v[$time]['count'] <= 0) {
             unset($data[$k]);
         } else {
             for ($i = time() - 3600; $i >= time() - 3600 * 24; $i--) {
                 $i_time = date('Y-m-d H', $i);
                 if (!isset($v[$time]) || $v[$i_time]['count'] <= 0) {
                     break;
                 } else {
                     $arr[$k][$i_time] = $v[$i_time]['count'];
                 }
             }
         }
     }
     foreach ($arr as $k => $v) {
         if (count($v) >= 6) {
             $manyi = $manyi - (count($v) - 5) * 100;
         }
     }
     _status($manyi, VHOST . "(项目满意分)", "扣:故障", "故障事故", NULL, VIP, 0, 'replace');
 }
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     //删除v1
     if ($_POST['delete_v1']) {
         $this->_report_monitor_delete($conn_db);
     } else {
         $sql = "select * from {$this->report_monitor_v1} t where v1=:v1 ";
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':v1', $_GET['v1']);
         $oci_error = _ociexecute($stmt);
         $_row = array();
         ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
         $sql = "update {$this->report_monitor_v1} set as_name=:as_name,count_type=:count_type,char_type=:char_type,\n        group_name=:group_name,group_name_1=:group_name_1,group_name_2=:group_name_2,start_clock=:start_clock,show_template=:show_template,show_all=1,\n        percent_count_type=:percent_count_type,day_count_type=:day_count_type,hour_count_type=:hour_count_type,\n        duibi_name=:duibi_name,is_duty=:is_duty,pinfen_rule_name=:pinfen_rule_name\n        where v1=:v1 ";
         $stmt = _ociparse($conn_db, $sql);
         _ocibindbyname($stmt, ':v1', $_GET['v1']);
         _ocibindbyname($stmt, ':as_name', $_POST['as_name']);
         _ocibindbyname($stmt, ':count_type', $_POST['count_type']);
         _ocibindbyname($stmt, ':char_type', $_POST['char_type']);
         _ocibindbyname($stmt, ':group_name', $_POST['group_name']);
         _ocibindbyname($stmt, ':group_name_1', $_POST['group_name_1']);
         _ocibindbyname($stmt, ':group_name_2', $_POST['group_name_2']);
         _ocibindbyname($stmt, ':start_clock', $_POST['start_clock']);
         _ocibindbyname($stmt, ':show_template', $_POST['show_template']);
         _ocibindbyname($stmt, ':percent_count_type', $_POST['percent_count_type']);
         _ocibindbyname($stmt, ':day_count_type', $_POST['day_count_type']);
         _ocibindbyname($stmt, ':hour_count_type', $_POST['hour_count_type']);
         _ocibindbyname($stmt, ':duibi_name', $_POST['duibi_name']);
         _ocibindbyname($stmt, ':is_duty', intval($_POST['is_duty']));
         _ocibindbyname($stmt, ':pinfen_rule_name', $_POST['pinfen_rule_name']);
         $oci_error = _ociexecute($stmt);
         print_r($oci_error);
         //排版统一
         if ($_POST['show_template_checkbox'] == 1) {
             $sql = "update {$this->report_monitor_v1} set show_template=:show_template  where group_name=:group_name ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':show_template', $_POST['show_template']);
             _ocibindbyname($stmt, ':group_name', $_POST['group_name']);
             $oci_error = _ociexecute($stmt);
         }
         foreach (array('percent_count_type', 'day_count_type', 'hour_count_type') as $k => $v) {
             //统一同类型配置
             if ($_POST[$v] != 'NULL') {
                 $sql = "update {$this->report_monitor_config} set {$v}=:{$v}  where v1=:v1 ";
                 $stmt = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt, ':v1', $_GET['v1']);
                 _ocibindbyname($stmt, ":{$v}", $_POST[$v]);
                 $oci_error = _ociexecute($stmt);
                 print_r($oci_error);
             }
         }
         //直接联动修改分组名称
         if ($_POST['show_group'] && $_POST['group_name_1'] != $_row['GROUP_NAME_1']) {
             $sql = "update {$this->report_monitor_v1} t set group_name_1=:group_name_1\n            where group_name=:group_name_old and  group_name_1=:group_name_1_old ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':group_name', $_POST['group_name']);
             _ocibindbyname($stmt, ':group_name_old', $_row['GROUP_NAME']);
             _ocibindbyname($stmt, ':group_name_1', $_POST['group_name_1']);
             _ocibindbyname($stmt, ':group_name_1_old', $_row['GROUP_NAME_1']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
         }
         //直接联动修改分组名称
         if ($_POST['show_group_2'] && $_POST['group_name_2'] != $_row['GROUP_NAME_2']) {
             $sql = "update {$this->report_monitor_v1} t set  group_name_2=:group_name_2\n            where group_name=:group_name_old and group_name_1=:group_name_1_old  and group_name_2=:group_name_2_old ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':group_name', $_POST['group_name']);
             _ocibindbyname($stmt, ':group_name_old', $_row['GROUP_NAME']);
             _ocibindbyname($stmt, ':group_name_1', $_POST['group_name_1']);
             _ocibindbyname($stmt, ':group_name_1_old', $_row['GROUP_NAME_1']);
             _ocibindbyname($stmt, ':group_name_2', $_POST['group_name_2']);
             _ocibindbyname($stmt, ':group_name_2_old', $_row['GROUP_NAME_2']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
         }
         //直接联动修改分组名称
         if ($_POST['show_group_3'] && $_POST['group_name'] != $_row['GROUP_NAME']) {
             $sql = "update {$this->report_monitor_v1} t set group_name=:group_name\n            where group_name=:group_name_old and group_name_1=:group_name_1_old  and group_name_2=:group_name_2_old ";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':group_name', $_POST['group_name']);
             _ocibindbyname($stmt, ':group_name_old', $_row['GROUP_NAME']);
             _ocibindbyname($stmt, ':group_name_1', $_POST['group_name_1']);
             _ocibindbyname($stmt, ':group_name_1_old', $_row['GROUP_NAME_1']);
             _ocibindbyname($stmt, ':group_name_2', $_POST['group_name_2']);
             _ocibindbyname($stmt, ':group_name_2_old', $_row['GROUP_NAME_2']);
             $oci_error = _ociexecute($stmt);
             print_r($oci_error);
         }
     }
     header("location: {$_SERVER['HTTP_REFERER']}");
 }
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     //config表
     $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);
     //v1表
     $sql = "select * from {$this->report_monitor_v1} where v1=:v1 ";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':v1', $_row['V1']);
     $oci_error = _ociexecute($stmt);
     $_row_v1 = array();
     ocifetchinto($stmt, $_row_v1, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
     $sql = "update {$this->report_monitor_config} set COMPARE_GROUP=:compare_group where v2=:v2  and v1=:v1";
     $stmt = _ociparse($conn_db, $sql);
     _ocibindbyname($stmt, ':compare_group', $_POST['compare_group']);
     _ocibindbyname($stmt, ':v2', $_row['V2']);
     _ocibindbyname($stmt, ':v1', $_row['V1']);
     $oci_error = _ociexecute($stmt);
     //比较分类拆分 比较原先数据 插入或者删除虚列
     $arr_com = explode('|', $_row['COMPARE_GROUP']);
     $arr = explode('|', $_POST['compare_group']);
     $arr_add = array_diff($arr, $arr_com);
     $arr_del = array_diff($arr_com, $arr);
     //新增
     foreach ($arr_add as $v) {
         if ($v != '') {
             $sql = "insert into {$this->report_monitor_config}\n                            (V1,V2,COUNT_TYPE,V3_LINK,V4_LINK,ORDERBY,PHONE,PHONE_ORDER,PHONE_ORDER_LESS,\n                           ID,AS_NAME,DAY_COUNT_TYPE,HOUR_COUNT_TYPE,PERCENT_COUNT_TYPE,V2_GROUP,VIRTUAL_COLUMNS) values(:V1,:V2,:COUNT_TYPE,:V3_LINK,\n                           :V4_LINK,:ORDERBY,:PHONE,:PHONE_ORDER,:PHONE_ORDER_LESS,\n                           seq_{$this->report_monitor}.nextval,:AS_NAME,:DAY_COUNT_TYPE,:HOUR_COUNT_TYPE,:PERCENT_COUNT_TYPE,:V2_GROUP,1)";
             $stmt = _ociparse($conn_db, $sql);
             $as_name = $_row['AS_NAME'] ? $_row['AS_NAME'] : $_row['V2'];
             _ocibindbyname($stmt, ':V1', $v);
             _ocibindbyname($stmt, ':V2', $_row['V1'] . '_' . $_row['V2']);
             _ocibindbyname($stmt, ':COUNT_TYPE', $_row['id']);
             _ocibindbyname($stmt, ':V3_LINK', $_row['V3_LINK']);
             _ocibindbyname($stmt, ':V4_LINK', $_row['V4_LINK']);
             _ocibindbyname($stmt, ':ORDERBY', $_row['ORDERBY']);
             _ocibindbyname($stmt, ':PHONE', $_row['PHONE']);
             _ocibindbyname($stmt, ':PHONE_ORDER', $_row['PHONE_ORDER']);
             _ocibindbyname($stmt, ':PHONE_ORDER_LESS', $_row['PHONE_ORDER_LESS']);
             _ocibindbyname($stmt, ':AS_NAME', $as_name);
             _ocibindbyname($stmt, ':DAY_COUNT_TYPE', $_row['DAY_COUNT_TYPE']);
             _ocibindbyname($stmt, ':HOUR_COUNT_TYPE', $_row['HOUR_COUNT_TYPE']);
             _ocibindbyname($stmt, ':PERCENT_COUNT_TYPE', $_row['PERCENT_COUNT_TYPE']);
             _ocibindbyname($stmt, ':V2_GROUP', $_row['V1']);
             $oci_error = _ociexecute($stmt);
             //插入v1表
             $sql = "insert into {$this->report_monitor_v1}\n                            (V1,COUNT_TYPE,CHAR_TYPE,START_CLOCK,SHOW_TEMPLATE,SHOW_ALL,ID,DAY_COUNT_TYPE,HOUR_COUNT_TYPE,PERCENT_COUNT_TYPE,SHOW_AVG,IS_DUTY)\n                      values(:V1,:COUNT_TYPE,:CHAR_TYPE,:START_CLOCK,:SHOW_TEMPLATE,:SHOW_ALL,\n                           seq_{$this->report_monitor}.nextval,:DAY_COUNT_TYPE,:HOUR_COUNT_TYPE,:PERCENT_COUNT_TYPE,:SHOW_AVG,1)";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':V1', $v);
             _ocibindbyname($stmt, ':COUNT_TYPE', $_row_v1['COUNT_TYPE']);
             _ocibindbyname($stmt, ':CHAR_TYPE', $_row_v1['CHAR_TYPE']);
             _ocibindbyname($stmt, ':START_CLOCK', $_row_v1['START_CLOCK']);
             _ocibindbyname($stmt, ':SHOW_TEMPLATE', $_row_v1['SHOW_TEMPLATE']);
             _ocibindbyname($stmt, ':SHOW_ALL', $_row_v1['SHOW_ALL']);
             _ocibindbyname($stmt, ':DAY_COUNT_TYPE', $_row_v1['DAY_COUNT_TYPE']);
             _ocibindbyname($stmt, ':HOUR_COUNT_TYPE', $_row_v1['HOUR_COUNT_TYPE']);
             _ocibindbyname($stmt, ':PERCENT_COUNT_TYPE', $_row_v1['PERCENT_COUNT_TYPE']);
             _ocibindbyname($stmt, ':SHOW_AVG', $_row_v1['SHOW_AVG']);
             $oci_error = _ociexecute($stmt);
             var_dump($oci_error);
         }
     }
     //删除
     foreach ($arr_del as $v) {
         if ($v != '') {
             $sql = "delete from {$this->report_monitor_config} where v1=:v1 and v2=:v2";
             $stmt = _ociparse($conn_db, $sql);
             _ocibindbyname($stmt, ':v1', $v);
             _ocibindbyname($stmt, ':v2', $_row['V1'] . '_' . $_row['V2']);
             $oci_error = _ociexecute($stmt);
         }
     }
 }
Beispiel #18
0
 function _initialize()
 {
     ini_set("display_errors", true);
     $xxi = 0;
     $conn_db = _ocilogon($this->db);
     if (!$conn_db) {
         exit('no db');
     }
     $get_included_files = basename(array_shift(get_included_files()));
     $tt1 = microtime(true);
     echo "<pre> 准备压缩数据:\n";
     $monitor_count = $files = $monitor = $monitor_min = array();
     $ic = 0;
     $config_data = array();
     $sql = "select * from {$this->report_monitor_queue} order by id desc LIMIT 0, 2000";
     $stmt = _ociparse($conn_db, $sql);
     _ociexecute($stmt);
     $_row = array();
     while (ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS)) {
         $msg_array = unserialize($_row['QUEUE']);
         if ($msg_array['v5'] == null) {
             $msg_array['v5'] = VIP;
         }
         //专门对付SQL不规范的写法
         if (strpos($msg_array['v1'], 'SQL') !== false) {
             $out = array();
             preg_match('# in(\\s+)?\\(#is', $msg_array['v4'], $out);
             if ($out) {
                 $msg_array['v4'] = substr($msg_array['v4'], 0, strpos($msg_array['v4'], ' in')) . ' in....';
             }
         }
         if (strpos($msg_array['v1'], 'SQL') !== false) {
             preg_match('# in(\\s+)?\\(#is', $msg_array['v3'], $out);
             if ($out) {
                 $msg_array['v3'] = substr($msg_array['v3'], 0, strpos($msg_array['v3'], ' in')) . ' in....';
             }
         }
         foreach ((array) $msg_array['includes'] as $file) {
             $files[$msg_array['vhost']][$file] = $file;
         }
         //查看命中了哪些监控
         $config_data[$msg_array['v1']][$msg_array['v2']]++;
         //日志数据,不会被删除
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['uptype'] = $msg_array['uptype'];
         if ($msg_array['uptype'] == 'replace') {
             $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['count'] = $msg_array['num'];
         } else {
             $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['count'] += $msg_array['num'];
         }
         //最大耗时
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['diff_time'] = max($monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['diff_time'], abs($msg_array['diff_time']));
         //总耗时
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['total_diff_time'] += abs($msg_array['diff_time']);
         //内存单次最大消耗
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['memory_max'] = max($monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['memory_max'], abs($msg_array['memory']));
         //内存消耗.总
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['memory_total'] += abs($msg_array['memory']);
         // 用户消耗CPU,单次最大
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_user_time_max'] = max($monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_user_time_max'], abs($msg_array['user_cpu']));
         //用户消耗CPU,总
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_user_time_total'] += abs($msg_array['user_cpu']);
         //系统消耗CPU,单次最大
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_sys_time_max'] = max($monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_sys_time_max'], abs($msg_array['sys_cpu']));
         //系统消耗CPU,总
         $monitor[date('Y-m-d H', strtotime($msg_array['time']))][$msg_array['v1']][$msg_array['v2']][$msg_array['v3']][$msg_array['v4']][$msg_array['v5']]['cpu_sys_time_total'] += abs($msg_array['sys_cpu']);
         $monitor_count[md5(date('Y-m-d H', strtotime($msg_array['time'])) . $msg_array['v1'] . $msg_array['v2'] . $msg_array['v3'] . $msg_array['v4'] . $msg_array['v5'])] = 1;
         if ($ic++ > 10 * 10000) {
             break;
         }
     }
     //clear queue start
     $sql_d = "TRUNCATE {$this->report_monitor_queue}";
     $stmt_d = _ociparse($conn_db, $sql_d);
     _ociexecute($stmt_d);
     //clear queue end
     $diff_time = sprintf('%.5f', microtime(true) - $tt1);
     echo "\n从{$ic}个压缩到" . count($monitor_count) . "(耗时:{$diff_time})\n";
     echo "命中的类型:\n";
     print_r($config_data);
     echo "\n\n";
     $conn_db = _ocilogon($this->db);
     foreach ($monitor as $time => $vtype) {
         foreach ($vtype as $type => $vhost) {
             foreach ($vhost as $host => $vact) {
                 foreach ($vact as $act => $vkey) {
                     foreach ($vkey as $key => $vhostip) {
                         foreach ($vhostip as $hostip => $v) {
                             if (!$host) {
                                 $host = 'null';
                             }
                             //截取4000字节
                             if (strlen($key) > 4000) {
                                 $key = substr($key, 0, 4000);
                             }
                             if (strlen($hostip) > 200) {
                                 $hostip = substr($hostip, 0, 200);
                             }
                             if (strlen($act) > 200) {
                                 $act = substr($act, 0, 200);
                             }
                             //去掉回车
                             $act = strtr($act, array("\n" => null, "\r" => null));
                             if ($v['uptype'] == 'replace') {
                                 //memory_max=,memory_total, cpu_user_time_max,cpu_user_time_total,cpu_sys_time_max,cpu_sys_time_total
                                 $sql = "update {$this->report_monitor} set fun_count=:fun_count,v6=:v6, total_diff_time=:total_diff_time,\n\t\t\t\t\t\t\t\t\tmemory_max=:memory_max, memory_total=:memory_total, cpu_user_time_max=:cpu_user_time_max, cpu_user_time_total=:cpu_user_time_total, cpu_sys_time_max=:cpu_sys_time_max, cpu_sys_time_total=:cpu_sys_time_total where md5=:md5 ";
                             } else {
                                 $sql = "update {$this->report_monitor} set fun_count=fun_count+:fun_count,v6=:v6, total_diff_time=:total_diff_time,\n\t\t\t\t\t\t\t\t    memory_max=:memory_max, memory_total=:memory_total, cpu_user_time_max=:cpu_user_time_max, cpu_user_time_total=:cpu_user_time_total, cpu_sys_time_max=:cpu_sys_time_max, cpu_sys_time_total=:cpu_sys_time_total where md5=:md5 ";
                             }
                             $stmt = _ociparse($conn_db, $sql);
                             _ocibindbyname($stmt, ':md5', md5($time . $type . $host . $act . $key . $hostip));
                             _ocibindbyname($stmt, ':fun_count', $v['count']);
                             _ocibindbyname($stmt, ':v6', abs($v['diff_time']));
                             _ocibindbyname($stmt, ':total_diff_time', $v['total_diff_time']);
                             _ocibindbyname($stmt, ':memory_max', $v['memory_max']);
                             _ocibindbyname($stmt, ':memory_total', $v['memory_total']);
                             _ocibindbyname($stmt, ':cpu_user_time_max', $v['cpu_user_time_max']);
                             _ocibindbyname($stmt, ':cpu_user_time_total', $v['cpu_user_time_total']);
                             _ocibindbyname($stmt, ':cpu_sys_time_max', $v['cpu_sys_time_max']);
                             _ocibindbyname($stmt, ':cpu_sys_time_total', $v['cpu_sys_time_total']);
                             $oci_error = _ociexecute($stmt);
                             print_r($oci_error);
                             if ($oci_error) {
                                 _status(1, VHOST . "(BUG错误)", 'SQL错误', "{$get_included_files}/{$_GET['act']}", var_export(array('cal_date' => $time, 'v1' => $type, 'v2' => $host, 'v3' => $act, 'v4' => $key, 'v5' => $hostip, 'fun_count' => $v['count'], 'v6' => abs($v['diff_time']), 'total_diff_time' => $v['total_diff_time'], 'memory_max' => $v['memory_max'], 'memory_total' => $v['memory_total'], 'cpu_user_time_max' => $v['cpu_user_time_max'], 'cpu_user_time_total' => $v['cpu_user_time_total'], 'cpu_sys_time_max' => $v['cpu_sys_time_max'], 'cpu_sys_time_total' => $v['cpu_sys_time_total']), true) . "|" . var_export($oci_error, true), VIP);
                             } else {
                                 _status(1, VHOST . "(PHPAPM)", "统计消耗", $type, 'monitor(update)', VIP);
                             }
                             $_row_count = ocirowcount($stmt);
                             if (!$_row_count) {
                                 $xxi++;
                                 echo "{$xxi}:[{$time} . {$type} . {$host} . {$act} . {$key} . {$hostip}]\n";
                                 $sql = "insert into {$this->report_monitor} (id,v1,v2,v3,v4,v5,fun_count,cal_date,v6,total_diff_time,memory_max,memory_total, cpu_user_time_max,cpu_user_time_total,cpu_sys_time_max,cpu_sys_time_total,md5)\n                                    values(seq_{$this->report_monitor}.nextval,:v1,:v2,:v3,:v4,:v5,:fun_count,to_date(:cal_date,'yyyy-mm-dd hh24:mi:ss'),:v6,:total_diff_time,:memory_max,:memory_total, :cpu_user_time_max,:cpu_user_time_total,:cpu_sys_time_max,:cpu_sys_time_total,:md5)";
                                 $stmt = _ociparse($conn_db, $sql);
                                 _ocibindbyname($stmt, ':md5', md5($time . $type . $host . $act . $key . $hostip));
                                 _ocibindbyname($stmt, ':cal_date', $time);
                                 _ocibindbyname($stmt, ':v1', $type);
                                 _ocibindbyname($stmt, ':v2', $host);
                                 _ocibindbyname($stmt, ':v3', $act);
                                 _ocibindbyname($stmt, ':v4', $key);
                                 _ocibindbyname($stmt, ':v5', $hostip);
                                 _ocibindbyname($stmt, ':fun_count', $v['count']);
                                 _ocibindbyname($stmt, ':v6', abs($v['diff_time']));
                                 _ocibindbyname($stmt, ':total_diff_time', $v['total_diff_time']);
                                 _ocibindbyname($stmt, ':memory_max', $v['memory_max']);
                                 _ocibindbyname($stmt, ':memory_total', $v['memory_total']);
                                 _ocibindbyname($stmt, ':cpu_user_time_max', $v['cpu_user_time_max']);
                                 _ocibindbyname($stmt, ':cpu_user_time_total', $v['cpu_user_time_total']);
                                 _ocibindbyname($stmt, ':cpu_sys_time_max', $v['cpu_sys_time_max']);
                                 _ocibindbyname($stmt, ':cpu_sys_time_total', $v['cpu_sys_time_total']);
                                 $oci_error = _ociexecute($stmt);
                                 print_r($oci_error);
                                 if ($oci_error) {
                                     _status(1, VHOST . "(BUG错误)", 'SQL错误', "{$get_included_files}/{$_GET['act']}", var_export(array('cal_date' => $time, 'time' => date('Y-m-d H:i:s'), 'md5' => md5($time . $type . $host . $act . $key . $hostip), 'v1' => $type, 'v2' => $host, 'v3' => $act, 'v4' => $key, 'v5' => $hostip, 'fun_count' => $v['count'], 'v6' => abs($v['diff_time']), 'memory_max' => $v['memory_max'], 'memory_total' => $v['memory_total'], 'cpu_user_time_max' => $v['cpu_user_time_max'], 'cpu_user_time_total' => $v['cpu_user_time_total'], 'cpu_sys_time_max' => $v['cpu_sys_time_max'], 'cpu_sys_time_total' => $v['cpu_sys_time_total']), true) . "|" . var_export($oci_error, true), VIP);
                                 } else {
                                     _status(1, VHOST . "(PHPAPM)", "统计消耗", $type, 'monitor', VIP);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     _ocilogoff($conn_db);
     if (!is_writable('/dev/shm')) {
         exit('no writable shm');
     }
     if (!file_exists($dir = '/dev/shm/' . VHOST . '/')) {
         mkdir($dir);
     }
     if (!file_exists($dir1 = '/dev/shm/xss_' . VHOST . '/')) {
         mkdir($dir1);
     }
     include PHPAPM_PATH . "./lib/project_function.php";
     $project_function = new project_function();
     $check_files = array();
     if (date('H') > 8 && date('H') <= 19) {
         $time_area = '白天';
     } else {
         $time_area = '晚上';
     }
     //文件记录
     foreach ($files as $module_name => $_files) {
         foreach (array_unique($_files) as $file) {
             if (!is_file($file)) {
                 continue;
             }
             //文件修改时间
             $new_file = $dir . md5($file);
             //
             if (is_file($new_file) && filectime($new_file) < filectime($file)) {
                 echo "代码改动\n";
                 _status(1, $module_name . "(代码改动)", "文件改动-{$time_area}", $file, "", VIP, 0);
                 touch($new_file, filectime($file));
             } elseif (!is_file($new_file)) {
                 _status(1, $module_name . "(代码改动)", "新增文件-{$time_area}", $file, "", VIP, 0);
                 touch($new_file, filectime($file));
             }
             //安全校验
             $new_file = $dir1 . md5($file);
             if (is_file($new_file) && filectime($new_file) < filectime($file)) {
                 $check_files[$file] = $module_name;
             } elseif (!is_file($new_file)) {
                 $check_files[$file] = $module_name;
             }
         }
     }
     foreach ($check_files as $file => $module_name) {
         $token = token_get_all(file_get_contents($file));
         //代码所有人统计
         if (strpos($file, '/phpCas/') === false || strpos($file, '/PHPMailer/') === false) {
             $project_function->_function_author($token, $module_name, $file);
             $project_function->_function_count($token, $module_name, $file);
             $project_function->_xss($token, $module_name, $file);
             $project_function->_sign($token, $module_name, $file);
             $project_function->_disable_function($token, $module_name, $file);
         }
         touch($dir1 . md5($file), filectime($file));
     }
     die("\n" . date("Y-m-d H:i:s") . ',file:' . __FILE__ . ',line:' . __LINE__ . "\n");
 }
 function _initialize()
 {
     if (empty($_COOKIE['admin_user']) || $_COOKIE['admin_user'] != md5(serialize($this->admin_user))) {
         exit;
     }
     $conn_db = _ocilogon($this->db);
     foreach ($_POST['uncount'] as $k => $v) {
         list($v1, $v2) = explode('#@', $v);
         $_REQUEST['v1'] = $v1;
         $_REQUEST['v2'] = $v2;
         if ($_POST['all_delete']) {
             $this->_report_monitor_delete($conn_db);
         } else {
             $min_count_type_1 = 0;
             $where = array();
             if ($_POST['percent_count_type_1'] != 'NULL') {
                 $where[] = " percent_count_type=:percent_count_type ";
             }
             if ($_POST['day_count_type_1'] != 'NULL') {
                 $where[] = " day_count_type=:day_count_type ";
             }
             if ($_POST['hour_count_type_1'] != 'NULL') {
                 $where[] = " hour_count_type=:hour_count_type ";
             }
             if ($_POST['v2_compare'] != 'NULL') {
                 $where[] = " v2_compare=:v2_compare";
             }
             if (!empty($where)) {
                 $where = join(',', $where);
                 $sql = "update {$this->report_monitor_config} set {$where} where v1=:v1 and v2=:v2 ";
                 $stmt = _ociparse($conn_db, $sql);
                 if ($_POST['percent_count_type_1'] != 'NULL') {
                     _ocibindbyname($stmt, ':percent_count_type', $_POST['percent_count_type_1']);
                 }
                 if ($_POST['day_count_type_1'] != 'NULL') {
                     _ocibindbyname($stmt, ':day_count_type', $_POST['day_count_type_1']);
                 }
                 if ($_POST['hour_count_type_1'] != 'NULL') {
                     _ocibindbyname($stmt, ':hour_count_type', $_POST['hour_count_type_1']);
                 }
                 if ($_POST['v2_compare'] != 'NULL') {
                     _ocibindbyname($stmt, ':v2_compare', $_POST['v2_compare']);
                 }
                 _ocibindbyname($stmt, ':v1', $v1);
                 _ocibindbyname($stmt, ':v2', $v2);
                 $oci_error = _ociexecute($stmt);
                 print_r($oci_error);
             }
             //联动同名不同v1下面的v2
             if ($_POST['group_all']) {
                 $sql = "select * from  {$this->report_monitor_config}  where v1=:v1 and v2=:v2 ";
                 $stmt = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt, ':v1', $v1);
                 _ocibindbyname($stmt, ':v2', $v2);
                 $oci_error = _ociexecute($stmt);
                 $_row = array();
                 ocifetchinto($stmt, $_row, OCI_ASSOC + OCI_RETURN_LOBS + OCI_RETURN_NULLS);
                 $sql = "update {$this->report_monitor_config} t set percent_count_type=:percent_count_type,day_count_type=:day_count_type,\n                    hour_count_type=:hour_count_type,orderby=:orderby,as_name=:as_name\n                    where  v2=:v2";
                 $stmt = _ociparse($conn_db, $sql);
                 _ocibindbyname($stmt, ':percent_count_type', $_row['PERCENT_COUNT_TYPE']);
                 _ocibindbyname($stmt, ':day_count_type', $_row['DAY_COUNT_TYPE']);
                 _ocibindbyname($stmt, ':hour_count_type', $_row['HOUR_COUNT_TYPE']);
                 _ocibindbyname($stmt, ':as_name', $_row['AS_NAME']);
                 _ocibindbyname($stmt, ':orderby', $_row['ORDERBY']);
                 _ocibindbyname($stmt, ':v2', $v2);
                 $oci_error = _ociexecute($stmt);
                 print_r($oci_error);
             }
         }
     }
     header("location: {$_SERVER['HTTP_REFERER']}");
 }