diff options
Diffstat (limited to 'frontends/php')
-rw-r--r-- | frontends/php/httpdetails.php | 115 | ||||
-rw-r--r-- | frontends/php/httpmon.php | 40 | ||||
-rw-r--r-- | frontends/php/include/classes/graph.inc.php | 19 | ||||
-rw-r--r-- | frontends/php/include/httptest.inc.php | 16 | ||||
-rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 4 | ||||
-rw-r--r-- | frontends/php/include/page_header.php | 3 |
6 files changed, 167 insertions, 30 deletions
diff --git a/frontends/php/httpdetails.php b/frontends/php/httpdetails.php index cc324eba..5617ffef 100644 --- a/frontends/php/httpdetails.php +++ b/frontends/php/httpdetails.php @@ -26,6 +26,7 @@ $page["title"] = "S_DETAILS_OF_SCENARIO"; $page["file"] = "httpdetails.php"; + define('ZBX_PAGE_DO_REFRESH', 1); include_once "include/page_header.php"; @@ -45,7 +46,7 @@ include_once "include/page_header.php"; $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,$ZBX_CURNODEID); - if(!($httptest_data = DBfetch(DBselect('select ht.httptestid from httptest ht, applications a '. + if(!($httptest_data = DBfetch(DBselect('select ht.* from httptest ht, applications a '. ' where a.hostid in ('.$accessible_hosts.') and a.applicationid=ht.applicationid '. ' and ht.httptestid='.$_REQUEST['httptestid'])))) { @@ -55,39 +56,125 @@ include_once "include/page_header.php"; ?> <?php $lnkCancel = new CLink(S_CANCEL,'httpmon.php'.url_param('groupid').url_param('hostid')); - show_table_header(S_DETAILS_OF_SCENARIO_BIG.' "'.bold($accessible_hosts['name']).'"',$lnkCancel); + show_table_header(S_DETAILS_OF_SCENARIO_BIG.' "'.bold($httptest_data['name']).'" - '. + date(S_DATE_FORMAT_YMDHMS,$httptest_data['lastcheck']),$lnkCancel); // TABLE $table = new CTableInfo(); - $table->SetHeader(array(S_STEP, 'Lastcheck', 'Speed', 'Time', 'Response code', 'Status')); + $table->SetHeader(array(S_STEP, S_SPEED_PER_SECONDS, S_RESPONSE_TIME, S_RESPONSE_CODE, S_STATUS)); + + $items = array(); + $total_data = array( HTTPSTEP_ITEM_TYPE_IN => null, HTTPSTEP_ITEM_TYPE_TIME => null ); + + $color = array( + 'current' => 1, + 1 => array('color' => 'Red', 'next' => '2'), + 2 => array('color' => 'Green', 'next' => '3'), + 3 => array('color' => 'Blue', 'next' => '4'), + 4 => array('color' => 'Yellow', 'next' => '5'), + 5 => array('color' => 'Cyan', 'next' => '6'), + 6 => array('color' => 'Gray', 'next' => '7'), + 7 => array('color' => 'Dark Red', 'next' => '8'), + 8 => array('color' => 'Dark Green', 'next' => '9'), + 9 => array('color' => 'Dark Blue', 'next' => '10'), + 10 => array('color' => 'Dark Yellow', 'next' => '11'), + 11 => array('color' => 'Black', 'next' => '1') + ); $db_httpsteps = DBselect('select * from httpstep where httptestid='.$httptest_data['httptestid'].' order by no'); while($httpstep_data = DBfetch($db_httpsteps)) { - $information = array( - bold($httpstep_data['name']) - ); + $db_items = DBselect('select i.*, hi.type as httpitem_type from items i, httpstepitem hi '. + ' where hi.itemid=i.itemid and hi.httpstepid='.$httpstep_data['httpstepid']); + while($item_data = DBfetch($db_items)) + { + $httpstep_data['item_data'][$item_data['httpitem_type']] = $item_data; + + if (!in_array($item_data['httpitem_type'], array(HTTPSTEP_ITEM_TYPE_IN, HTTPSTEP_ITEM_TYPE_TIME))) continue; + + if(isset($total_data[$item_data['httpitem_type']])) + { + $total_data[$item_data['httpitem_type']]['lastvalue'] += $item_data['lastvalue']; + } + else + { + $total_data[$item_data['httpitem_type']] = $item_data; + } + $items[$item_data['httpitem_type']][] = array( + 'itemid' => $item_data['itemid'], + 'color' => $color[$color['current'] = $color[$color['current']]['next']]['color'], + 'sortorder' => 'no'); + } + + $status['msg'] = S_OK; + $status['style'] = 'enabled'; + + if($httptest_data['lastfailedstep'] > 0) + { + if($httptest_data['lastfailedstep'] == ($httpstep_data['no'] + 1)) + { + $status['msg'] = S_FAIL; + $status['style'] = 'disabled'; + } + else if($httptest_data['lastfailedstep'] < ($httpstep_data['no'] + 1)) + { + $status['msg'] = S_UNKNOWN; + $status['style'] = 'unknown'; + } + } + + $table->AddRow(array( + $httpstep_data['name'], + format_lastvalue($httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_IN]), + format_lastvalue($httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_TIME]), + format_lastvalue($httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_RSPCODE]), + new CSpan($status['msg'], $status['style']) + )); + } - $chart1 = $chart2 = $chart3 = '123.9 KBps'; + $status['msg'] = S_OK; + $status['style'] = 'enabled'; - $table->AddRow(array($information, '10/12/07 12:30', $chart1, $chart2, $chart3, new CSpan('Failed','disabled'))); + if($httptest_data['lastfailedstep'] > 0) + { + $status['msg'] = S_FAIL; + $status['style'] = 'disabled'; } - $table->AddRow(array(bold('CONCLUSION'), 'Unknown', $chart1, $chart2, $chart3, new CSpan('Faild on step X fom Z', 'enabled'))); - $table->Show(); + $table->AddRow(array( + new CCol(S_TOTAL_BIG, 'bold'), + format_lastvalue($total_data[HTTPSTEP_ITEM_TYPE_IN]), + format_lastvalue($total_data[HTTPSTEP_ITEM_TYPE_TIME]), + SPACE, + new CSpan($status['msg'], $status['style']) + )); - $chart1 = $chart2 = $chart3 = new CImg('chart3.php?period=3600&from=0&name=KEY_NAME&height=150'); + $table->Show(); echo BR; show_table_header('History'.' "'.bold($accessible_hosts['name']).'"'); $form = new CTableInfo(); - $form->AddRow(array(bold('Speed per seconds') , new CCol($chart1, 'center'))); - $form->AddRow(array(bold('Response time') , new CCol($chart1,'center'))); + $form->AddRow(array(bold(S_SPEED_PER_SECONDS) , new CCol( + new CImg('chart3.php?period=3600&from=0'. + url_param($httptest_data['name'], false,'name'). + url_param(150, false,'height'). + url_param($items[HTTPSTEP_ITEM_TYPE_IN], false, 'items'). + url_param(GRAPH_TYPE_STACKED, false, 'graphtype') + ) + , 'center'))); + + $form->AddRow(array(bold(S_RESPONSE_TIME) , new CCol( + new CImg('chart3.php?period=3600&from=0'. + url_param($httptest_data['name'], false,'name'). + url_param(150, false,'height'). + url_param($items[HTTPSTEP_ITEM_TYPE_TIME], false, 'items'). + url_param(GRAPH_TYPE_STACKED, false, 'graphtype')) + ,'center'))); $form->Show(); - navigation_bar("#",$to_save_request); + navigation_bar("#", array('httptestid')); ?> <?php diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php index 809aa9c6..8819b47b 100644 --- a/frontends/php/httpmon.php +++ b/frontends/php/httpmon.php @@ -26,6 +26,7 @@ $page["title"] = "S_STATUS_OF_WEB_MONITORING"; $page["file"] = "httpmon.php"; + define('ZBX_PAGE_DO_REFRESH', 1); include_once "include/page_header.php"; @@ -189,24 +190,45 @@ include_once "include/page_header.php"; $name = array(); array_push($name, new CLink($httptest_data["name"],"httpdetails.php?httptestid=".$httptest_data['httptestid'],'action')); - - $status=new CCol(new CLink(httptest_status2str($httptest_data["status"]), - "?group_httptestid%5B%5D=".$httptest_data["httptestid"]. - "&hostid=".$_REQUEST["hostid"]. - "&group_task=".($httptest_data["status"] ? "Activate+selected" : "Disable+selected"), - httptest_status2style($httptest_data["status"]))); $step_cout = DBfetch(DBselect('select count(*) from httpstep where httptestid='.$httptest_data["httptestid"])); $step_cout = $step_cout[0]; + if(isset($httptest_data["lastcheck"])) + $lastcheck = date(S_DATE_FORMAT_YMDHMS,$httptest_data["lastcheck"]); + else + $lastcheck = new CCol('-', 'center'); + + if($httptest_data['curstate'] > 0) + { + $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['curstate'] - 1); + $state = 'In check "'.$step_data['name'].'"'; + } + else + { + $state = "Idle till ".date(S_DATE_FORMAT_YMDHMS,$httptest_data['nextcheck']); + } + + if($httptest_data['lastfailedstep'] > 0) + { + $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['lastfailedstep'] - 1); + $status['msg'] = 'Failed on "'.$step_data['name'].'"'; + $status['style'] = 'disabled'; + } + else + { + $status['msg'] = 'OK'; + $status['style'] = 'enabled'; + } + array_push($app_rows, new CRow(array( $_REQUEST["hostid"] > 0 ? NULL : SPACE, array(str_repeat(SPACE,6), $name), $step_cout, - "TODO: Idle till TT || In check (X of Z)", // TODO!!! - "TODO: TT", // TODO!!! - "TODO: failed on step X of Z || OK" // TODO!!! + $state, + $lastcheck, + new CSpan($status['msg'], $status['style']) ))); } if($httptest_cnt > 0) diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index 35e5dcd6..6ae5ba44 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -242,8 +242,12 @@ $this->m_showTriggers = $value == 1 ? 1 : 0;; } - function AddItem($itemid, $axis, $calc_fnc = CALC_FNC_AVG, $color=null, $drawtype=null, $type=null, $periods_cnt=null) + function AddItem($itemid, $axis=GRAPH_YAXIS_SIDE_RIGHT, $calc_fnc=CALC_FNC_AVG, + $color=null, $drawtype=null, $type=null, $periods_cnt=null) { + if($this->type == GRAPH_TYPE_STACKED /* stacked graph */) + $drawtype = GRAPH_DRAW_TYPE_FILL; + $this->items[$this->num] = get_item_by_itemid($itemid); $this->items[$this->num]["description"]=item_description($this->items[$this->num]["description"],$this->items[$this->num]["key_"]); $host=get_host_by_hostid($this->items[$this->num]["hostid"]); @@ -251,15 +255,17 @@ $this->items[$this->num]["host"] = $host["host"]; $this->items[$this->num]["color"] = is_null($color) ? "Dark Green" : $color; $this->items[$this->num]["drawtype"] = is_null($drawtype) ? GRAPH_DRAW_TYPE_LINE : $drawtype; - $this->items[$this->num]["axisside"] = $axis; - $this->items[$this->num]["calc_fnc"] = $calc_fnc; + $this->items[$this->num]["axisside"] = is_null($axis) ? GRAPH_YAXIS_SIDE_RIGHT : $axis; + $this->items[$this->num]["calc_fnc"] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc; $this->items[$this->num]["calc_type"] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type; $this->items[$this->num]["periods_cnt"] = is_null($periods_cnt) ? 0 : $periods_cnt; - if($axis==GRAPH_YAXIS_SIDE_LEFT) + if($this->items[$this->num]["calc_fnc"] == GRAPH_YAXIS_SIDE_LEFT) $this->yaxisleft=1; - if($axis==GRAPH_YAXIS_SIDE_RIGHT) + + if($this->items[$this->num]["calc_fnc"] == GRAPH_YAXIS_SIDE_RIGHT) $this->yaxisright=1; + $this->num++; } @@ -1128,6 +1134,7 @@ } } } + /* end calculation of stacked graphs */ } @@ -1276,7 +1283,6 @@ if($draw) { - $this->drawElement( $data, $i, $j, @@ -1290,6 +1296,7 @@ $calc_fnc ); } + $j = $i; } } diff --git a/frontends/php/include/httptest.inc.php b/frontends/php/include/httptest.inc.php index bc91c798..1cd20aca 100644 --- a/frontends/php/include/httptest.inc.php +++ b/frontends/php/include/httptest.inc.php @@ -375,8 +375,24 @@ } return true; } + function get_httptest_by_httptestid($httptestid) { return DBfetch(DBselect('select * from httptest where httptestid='.$httptestid)); } + + function get_httpsteps_by_httptestid($httptestid) + { + return DBselect('select * from httpstep where httptestid='.$httptestid); + } + + function get_httpstep_by_httpstepid($httpstepid) + { + return DBfetch(DBselect('select * from httpstep where httpstepid='.$httpstepid)); + } + + function get_httpstep_by_no($httptestid, $no) + { + return DBfetch(DBselect('select * from httpstep where httptestid='.$httptestid.' and no='.$no)); + } ?> diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index e629475f..1bced24b 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -35,6 +35,10 @@ // httpdetails.php "S_DETAILS_OF_SCENARIO"=> "Details of scenario", "S_DETAILS_OF_SCENARIO_BIG"=> "DETAILS OF SCENARIO", + "S_SPEED_PER_SECONDS"=> "Speed per seconds", + "S_RESPONSE_CODE"=> "Response code", + "S_TOTAL_BIG"=> "TOTAL", + "S_RESPONSE_TIME"=> "Response time", // httpmon.php "S_STATUS_OF_WEB_MONITORING"=> "Status of Web monitoring", diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 297223cc..7de0c349 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -137,6 +137,7 @@ COpt::profiling_start("page"); "sub_pages"=>array("report3.php","chart_sla.php","chart5.php") ), array("url"=>"vtext.php"), + array("url"=>"chart3.php") ) ), "cm"=>array( @@ -175,7 +176,7 @@ COpt::profiling_start("page"); "sub_pages"=>array("sysmap.php") ), array("url"=>"graphs.php" ,"label"=>S_GRAPHS , - "sub_pages"=>array("popup_gitem.php","chart3.php") + "sub_pages"=>array("popup_gitem.php") ), array("url"=>"screenconf.php" ,"label"=>S_SCREENS , "sub_pages"=>array("screenedit.php") |