From: Florian G. <re...@us...> - 2007-06-06 13:08:32
|
Update of /cvsroot/perfparse/_perfparse-phpgui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3527/phpgui Modified Files: perfparse.php utils.php Log Message: continue work on DB conversion and php gui. Index: utils.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/utils.php,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** utils.php 5 Jun 2007 22:46:59 -0000 1.36 --- utils.php 6 Jun 2007 13:08:31 -0000 1.37 *************** *** 390,394 **** } ! if($normal==false || $warning==false || $critical==false || $unknown==false) { $query.=' AND nagios_status in ('; $interieur=array(); --- 390,398 ---- } ! if($normal==false && $warning==false && $critical==false && $unknown==false) { ! return(array()); ! } ! ! if($normal==false || $warning==false || $critical==false || $unknown==false) { $query.=' AND nagios_status in ('; $interieur=array(); *************** *** 601,607 **** } ! function get_servicename_from_id(&$db,$serviceid) { ! $query='select service_description from perfdata_service where service_id=?'; ! $ret=$db->GetOne($query,array($serviceid)); return($ret); } --- 605,612 ---- } ! function get_info_from_service_id(&$db,$serviceid) { ! $query= 'select s.service_description, s.host_id, s.is_deleted, h.host_name '; ! $query.='from perfdata_service s, perfdata_host h where s.service_id=? and h.host_id=s.host_id'; ! $ret=$db->GetRow($query,array($serviceid)); return($ret); } *************** *** 613,617 **** } ! function get_raw_history($db,$host_name,$service,$from,$to,$type=0,$sort='ctime.asc') { // type: value="0" All events value="1" Change in Events value="2" Summary Only $statearray=array('OK','WARNING','CRITICAL','UNKNOWN'); --- 618,622 ---- } ! function get_raw_history($db,$service_id,$from,$to,$type=0,$sort='ctime.asc') { // type: value="0" All events value="1" Change in Events value="2" Summary Only $statearray=array('OK','WARNING','CRITICAL','UNKNOWN'); *************** *** 626,636 **** ! $query='SELECT ctime, txt_data, nagios_status FROM perfdata_service_raw WHERE host_name=?'; ! $query.=' AND service_description = ?'; ! $query.=' AND ctime BETWEEN ? AND ?'; $queryc=$query.' order by ctime asc'; $query.=' order by '.$sorts[0].' '.$sorts[1]; ! $res=$db->Execute($query,array($host_name,$service,$from,$to)); $ret=array(); $ret['count']=0; --- 631,646 ---- ! $query='SELECT r.ctime, r.txt_data, r.nagios_status, s.service_description, h.host_name FROM '; ! $query.='perfdata_service_raw r, perfdata_service s, perfdata_host h '; ! $query.='WHERE r.service_id=? '; ! $query.='AND r.service_id=s.service_id '; ! $query.='AND s.host_id=h.host_id '; ! $query.='AND r.ctime BETWEEN ? AND ?'; $queryc=$query.' order by ctime asc'; $query.=' order by '.$sorts[0].' '.$sorts[1]; ! if(!$res=$db->Execute($query,array($service_id,$from,$to))) { ! echo "SQL-Error in query $query : ".$db->ErrorMsg(); ! } $ret=array(); $ret['count']=0; *************** *** 667,671 **** $ret['statesummtime']=array(0,0,0,0); ! $res=$db->Execute($queryc,array($host_name,$service,$from,$to)); while($r=$res->FetchRow()) { $utime=mktime_YmdHM($r['ctime']); --- 677,681 ---- $ret['statesummtime']=array(0,0,0,0); ! $res=$db->Execute($queryc,array($service_id,$from,$to)); while($r=$res->FetchRow()) { $utime=mktime_YmdHM($r['ctime']); Index: perfparse.php =================================================================== RCS file: /cvsroot/perfparse/_perfparse-phpgui/perfparse.php,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** perfparse.php 5 Jun 2007 22:46:59 -0000 1.47 --- perfparse.php 6 Jun 2007 13:08:31 -0000 1.48 *************** *** 383,387 **** case 'raw_history_summary': get_request_var('type','int',0); - get_request_var('host_name','string',''); get_request_var('service_id','string',''); get_request_var('timerange','char','r'); --- 383,386 ---- *************** *** 390,404 **** get_request_var('from','string',strftime('%Y-%m-%d %H:%M',time()-7*86400)); get_request_var('to','string',strftime('%Y-%m-%d %H:%M',time())); ! $service=get_servicename_from_id($db,$service_id); $smarty->assign('service',$service); if($timerange=='r') { ! $from=rel_to_abs_timerange($relativedays,$relativetime); $to=strftime('%Y-%m-%d %H:%M',time()); ! $smarty->assign('from',$from); ! $smarty->assign('to',$to); } // get data to display in table ! $raw_hist=get_raw_history($db,$host_name,$service,$from,$to,$type); // echo "<pre>";print_r($raw_hist);echo "</pre>"; $smarty->assign_by_ref('raw_hist',$raw_hist); --- 389,406 ---- get_request_var('from','string',strftime('%Y-%m-%d %H:%M',time()-7*86400)); get_request_var('to','string',strftime('%Y-%m-%d %H:%M',time())); ! $service_info=get_info_from_service_id($db,$service_id); ! $service=$service_info['service_description']; ! $host_name=$service_info['host_name']; $smarty->assign('service',$service); + $smarty->assign('host_name',$host_name); if($timerange=='r') { ! $from=rel_to_abs_timerange($relativedays,$relativetime); $to=strftime('%Y-%m-%d %H:%M',time()); ! $smarty->assign('from',$from); ! $smarty->assign('to',$to); } // get data to display in table ! $raw_hist=get_raw_history($db,$service_id,$from,$to,$type); // echo "<pre>";print_r($raw_hist);echo "</pre>"; $smarty->assign_by_ref('raw_hist',$raw_hist); |