private function check_instance_knowing_chart($instance_id, $host, $port, $service_name) { $sql = "select * from knowing_charts where target_type='instance' and target_id='{$instance_id}'"; $charts = pdo_fetch_all($this->link, $sql); if (!$charts) { $this->add_instance_knowing_chart($instance_id, $host, $port, $service_name); } }
<?php $base = dirname(__FILE__); $solr_root = substr($base, 0, strrpos($base, 'scripts')); $script_root = $solr_root . "/scripts"; include_once $script_root . "/common.php"; $strSQL = 'show tables like "status_log\\_%"'; $tables = pdo_fetch_all($link_log, $strSQL, array()); foreach ($tables as $table) { $table = array_pop($table); $strSQL = "select id from {$table} where log_time<? limit 10000"; $arrArc = pdo_fetch_all($link_log, $strSQL, array(date('Y-m-d H:i:00', time() - 345600))); if (!empty($arrArc)) { $arrAllIDs = array(); foreach ($arrArc as $arrData) { $arrAllIDs[] = $arrData['id']; } $strPattern = join(',', array_fill(0, count($arrAllIDs), '?')); $strSQL = 'insert into status_logs_arc select * from ' . $table . ' where id in (' . $strPattern . ')'; $sth = $link_log->prepare($strSQL); $sth->execute($arrAllIDs); $strSQL = 'delete from ' . $table . ' where id in (' . $strPattern . ')'; $sth = $link_log->prepare($strSQL); $sth->execute($arrAllIDs); } }
$arrLastLoad = pdo_fetch($link_log, $strSQL, array($arrHost['host_id'], 'host', 'loadaverage')); $arrHost['memoryused'] = $arrLastMem['log_value']; $arrHost['loadaverage'] = $arrLastLoad['log_value']; $strSQL = 'replace into report set r_type=?,target_id=?,r_data=?'; $sth = $link_log->prepare($strSQL); $arrHost['lastupd'] = date('Y-m-d H:i:s'); $sth->execute(array('host', $arrHost['host_id'], json_encode($arrHost))); } $strSQL = 'select service_id from service'; $arrServices = pdo_fetch_all($link, $strSQL); foreach ($arrServices as $arrService) { $strSQL = 'select log_value from status_logs where target_id=? and log_type=? and log_name=? order by id desc limit 20'; $arrLastDocNumber = pdo_fetch_all($link_log, $strSQL, array($arrService['service_id'], 'service', 'docnumber')); $arrLastSelCnt = pdo_fetch_all($link_log, $strSQL, array($arrService['service_id'], 'service', 'select')); $arrLastUpdCnt = pdo_fetch_all($link_log, $strSQL, array($arrService['service_id'], 'service', 'update')); $arrMilliSecond = pdo_fetch_all($link_log, $strSQL, array($arrService['service_id'], 'service', 'millisecond_90')); if (false === $arrLastDocNumber) { $arrService['docnumber'] = '-'; } else { $intTotal = $intTime = 0; foreach ($arrLastDocNumber as $arrTmp) { $intTotal = $intTotal + $arrTmp['log_value']; ++$intTime; } $arrService['docnumber'] = round($intTotal / $intTime); } if (false === $arrLastSelCnt) { $arrService['selcnt'] = '-'; } else { $intTotal = $intTime = 0; foreach ($arrLastSelCnt as $arrTmp) {
function select_frequentquery($pdo_log, $datetime, $service = false) { if (!empty($service)) { $service = " and service='{$service}' "; } else { $service = ''; } $sql = "select * from frequentquery where log_time=?" . $service . " order by count desc limit 20"; return pdo_fetch_all($pdo_log, $sql, array($datetime)); }