diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-29 08:47:18 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-29 08:47:18 +0000 |
| commit | 0990cdce6c98be640a3c70bea413ac1f44865016 (patch) | |
| tree | 97a9c36f69226f682f7326b668ee99b07ca6c684 /frontends/php/srv_status.php | |
| parent | 3442ec61fa38eea4e68a3edea4ea3225ff78c8a0 (diff) | |
| download | zabbix-0990cdce6c98be640a3c70bea413ac1f44865016.tar.gz zabbix-0990cdce6c98be640a3c70bea413ac1f44865016.tar.xz zabbix-0990cdce6c98be640a3c70bea413ac1f44865016.zip | |
- changed IT Services interface (Artem)
- added class CTree
- added Javascript class for Cookies management
git-svn-id: svn://svn.zabbix.com/trunk@4188 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/srv_status.php')
| -rw-r--r-- | frontends/php/srv_status.php | 214 |
1 files changed, 101 insertions, 113 deletions
diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php index ed0ad110..9b84d1fc 100644 --- a/frontends/php/srv_status.php +++ b/frontends/php/srv_status.php @@ -34,8 +34,7 @@ include_once "include/page_header.php"; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields=array( "serviceid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, NULL), - "showgraph"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1")."isset({serviceid})",NULL), - "path"=> array(T_ZBX_STR, O_OPT, null, null, NULL) + "showgraph"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1")."isset({serviceid})",NULL) ); check_fields($fields); @@ -43,8 +42,7 @@ include_once "include/page_header.php"; <?php $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT); - if(isset($_REQUEST["serviceid"]) && $_REQUEST["serviceid"] > 0) - { + if(isset($_REQUEST["serviceid"]) && $_REQUEST["serviceid"] > 0){ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ". " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ". @@ -59,124 +57,74 @@ include_once "include/page_header.php"; unset($_REQUEST["serviceid"]); ?> <?php - $path = get_request('path', array()); - if(isset($service)) - { - $path[count($path)] = array('id'=>$service["serviceid"], 'name'=>$service["name"]); - } - array_unique($path); - - $menu_path = array(); - $new_path = array(); - foreach($path as $el) - { - if(count($new_path)==0) - { - $back_name = S_ROOT_SMALL; - $back_id = 0; - } - else - { - $back_name = $new_path[count($new_path)-1]['name']; - $back_id = $new_path[count($new_path)-1]['id']; - } - - if(isset($service) && $back_id == $service['serviceid']) break; - - array_push($menu_path, unpack_object(new CLink($back_name, '?serviceid='.$back_id.url_param($new_path,false,'path')))); - array_push($new_path, $el); - } - $_REQUEST['path'] = $path = $new_path; - - show_table_header(S_IT_SERVICES_BIG.": ".implode('/',$menu_path)); + show_table_header(S_IT_SERVICES_BIG); - unset($menu_path, $new_path, $el); - - if(isset($service)&&isset($_REQUEST["showgraph"])) - { + if(isset($service)&&isset($_REQUEST["showgraph"])){ $table = new CTable(null,'chart'); $table->AddRow(new CImg("chart5.php?serviceid=".$service["serviceid"].url_param('path'))); $table->Show(); - } - else - { + } else { + + $query = 'SELECT DISTINCT s.serviceid, sl.servicedownid, sl_p.serviceupid as serviceupid, s.triggerid, '. + ' s.name as caption, s.algorithm, t.description, s.sortorder, sl.linkid, s.showsla, s.goodsla, s.status '. + ' FROM services s '. + ' LEFT JOIN triggers t ON s.triggerid = t.triggerid '. + ' LEFT JOIN services_links sl ON s.serviceid = sl.serviceupid and NOT(sl.soft=0) '. + ' LEFT JOIN services_links sl_p ON s.serviceid = sl_p.servicedownid and sl_p.soft=0 '. + ' WHERE '.DBid2nodeid("s.serviceid").'='.$ZBX_CURNODEID. + ' ORDER BY s.sortorder, sl.serviceupid, s.serviceid'; + + $result=DBSelect($query); + + $services = array(); + $row = array( + '0' => 0,'serviceid' => 0, + '1' => 0,'serviceupid' => 0, + '2' => '','caption' => 'root', + '3' => '','status' => SPACE, + '4' => '','reason' => SPACE, + '5' => '','sla' => SPACE, + '6' => '','sla2' => SPACE, + '7' => '','graph' => SPACE, + '7' => '','linkid'=>'' + ); + + $services[0]=$row; $now=time(); - $table = new CTableInfo(); - $table->SetHeader(array(S_SERVICE,S_STATUS,S_REASON,S_SLA_LAST_7_DAYS,nbsp(S_PLANNED_CURRENT_SLA),S_GRAPH)); - - $result = DBselect("select distinct s.* from services s left join triggers t on s.triggerid=t.triggerid ". - " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ". - " left join services_links sl on s.serviceid=sl.servicedownid ". - " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ". - " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID. - " and (sl.serviceupid".(!isset($service) ? - " is NULL " : - "=".$service['serviceid']." or s.serviceid=".$service['serviceid'] ).") ". - " order by s.sortorder,s.name"); - - while($row=DBfetch($result)) - { - $description = array(); + while($row = DBFetch($result)){ + + (empty($row['serviceupid']))?($row['serviceupid']='0'):(''); + (empty($row['description']))?($row['description']='None'):(''); + $row['graph'] = new CLink(S_SHOW,"srv_status.php?serviceid=".$row["serviceid"]."&showgraph=1".url_param('path'),"action"); - if(isset($service)) - { - if($row['serviceid'] == $service['serviceid']) - { - $row['name'] = new CSpan($row['name'],'bold'); - } - else - { - array_push($description, " - "); - } - } - - $childs = get_num_of_service_childs($row["serviceid"]); + if(isset($row["triggerid"]) && !empty($row["triggerid"])){ + $url = new CLink(expand_trigger_description($row['triggerid']),'tr_events.php?triggerid='.$row['triggerid']); + $row['caption'] = $row['caption'].SPACE.'['.$url->ToString().']'; - if($childs && !(isset($service) && $service["serviceid"] == $row["serviceid"])) - { - array_push($description, new CLink($row['name'],"?serviceid=".$row["serviceid"].url_param('path'),'action')); - } - else - { - array_push($description, $row['name']); - } - - if(isset($row["triggerid"])) - { - array_push($description, SPACE, "[", new CLink( - expand_trigger_description($row["triggerid"]), - "tr_events.php?triggerid=".$row["triggerid"]), - "]"); } - if($row["status"]==0 || (isset($service) && $service["serviceid"] == $row["serviceid"])) - { - $reason="-"; - } - else - { - $reason = new CList(null,"itservices"); + if($row["status"]==0 || (isset($service) && $service["serviceid"] == $row["serviceid"])){ + $row['reason']="-"; + } else { + $row['reason'] = new CList(null,"itservices"); $result2=DBselect("select s.triggerid,s.serviceid from services s, triggers t ". " where s.status>0 and s.triggerid is not NULL and t.triggerid=s.triggerid ". " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID. " order by s.status desc,t.description"); - while($row2=DBfetch($result2)) - { - if(does_service_depend_on_the_service($row["serviceid"],$row2["serviceid"])) - { - $reason->AddItem(new CLink( + while($row2=DBfetch($result2)){ + if(does_service_depend_on_the_service($row["serviceid"],$row2["serviceid"])){ + $row['reason']->AddItem(new CLink( expand_trigger_description($row2["triggerid"]), "tr_events.php?triggerid=".$row2["triggerid"])); } } } - - if($row["showsla"]==1) - { - $sla = new CLink(new CImg("chart_sla.php?serviceid=".$row["serviceid"]), + + if($row["showsla"]==1){ + $row['sla'] = new CLink(new CImg("chart_sla.php?serviceid=".$row["serviceid"]), "report3.php?serviceid=".$row["serviceid"]."&year=".date("Y")); $now = time(NULL); @@ -185,23 +133,64 @@ include_once "include/page_header.php"; $stat = calculate_service_availability($row["serviceid"],$period_start,$period_end); - if($row["goodsla"] > $stat["ok"]) - { + if($row["goodsla"] > $stat["ok"]){ $color="AA0000"; - } - else - { + } else { $color="00AA00"; } - $sla2 = sprintf("<font color=\"00AA00\">%.2f%%</font><b>/</b><font color=\"%s\">%.2f%%</font>", + $row['sla2'] = sprintf("<font color=\"00AA00\">%.2f%%</font><b>/</b><font color=\"%s\">%.2f%%</font>", $row["goodsla"], $color,$stat["ok"]); + } else { + $row['sla']= "-"; + $row['sla2']= "-"; } - else - { - $sla = "-"; - $sla2 = "-"; + + if(isset($services[$row['serviceid']])){ + $services[$row['serviceid']] = array_merge($services[$row['serviceid']],$row); + } else { + + $services[$row['serviceid']] = $row; } + + if(isset($row['serviceupid'])) + $services[$row['serviceupid']]['childs'][] = array('id' => $row['serviceid'], 'soft' => 0, 'linkid' => 0); + + if(isset($row['servicedownid'])) + $services[$row['serviceid']]['childs'][] = array('id' => $row['servicedownid'], 'soft' => 1, 'linkid' => $row['linkid']); + } + + createShowServiceTree($services,0,$treeServ); + + echo '<script src="js/services.js" type="text/javascript"></script>'; + + $tree = new CTree($treeServ,array('caption' => '<b>'.S_SERVICE.'</b>', + 'status' => '<b>'.S_STATUS.'</b>', + 'reason' => '<b>'.S_REASON.'</b>', + 'sla' => '<b>'.S_SLA_LAST_7_DAYS.'</b>', + 'sla2' => '<b>'.nbsp(S_PLANNED_CURRENT_SLA).'</b>', + 'graph' => '<b>'.S_GRAPH.'</b>')); + + if($tree){ + echo $tree->CreateJS(); + echo $tree->SimpleHTML(); + } else { + error('Can\'t format Tree. Check logick structure in service links'); + } + + + + + /*$result = DBselect("select distinct s.* from services s left join triggers t on s.triggerid=t.triggerid ". + " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ". + " left join services_links sl on s.serviceid=sl.servicedownid ". + " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ". + " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID. + " and (sl.serviceupid".(!isset($service) ? + " is NULL " : + "=".$service['serviceid']." or s.serviceid=".$service['serviceid'] ).") ". + " order by s.sortorder,s.name"); + $table->AddRow(array( $description, @@ -211,8 +200,7 @@ include_once "include/page_header.php"; $sla2, new CLink(S_SHOW,"srv_status.php?serviceid=".$row["serviceid"]."&showgraph=1".url_param('path'),"action") )); - } - $table->Show(); + }*/ } ?> <?php |
