diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-09-24 15:02:12 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-09-24 15:02:12 +0000 |
| commit | 95965be1ed25c300e01e7376e25eb8b3ba13602f (patch) | |
| tree | 441129b5a45b7600f9ec7367b327374bc512a586 /frontends/php/latest.php | |
| parent | 32a7770affdc0d9c5e433d1ea096643403f84be7 (diff) | |
| download | zabbix-95965be1ed25c300e01e7376e25eb8b3ba13602f.tar.gz zabbix-95965be1ed25c300e01e7376e25eb8b3ba13602f.tar.xz zabbix-95965be1ed25c300e01e7376e25eb8b3ba13602f.zip | |
- [ZBX-71] merged rev. 4783:4786 of branches/1.4 (Artem) [added separation of "other" by node and host in "latest data"]
git-svn-id: svn://svn.zabbix.com/trunk@4787 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/latest.php')
| -rw-r--r-- | frontends/php/latest.php | 192 |
1 files changed, 107 insertions, 85 deletions
diff --git a/frontends/php/latest.php b/frontends/php/latest.php index 2fe3b066..b25c98cb 100644 --- a/frontends/php/latest.php +++ b/frontends/php/latest.php @@ -177,18 +177,15 @@ include_once "include/page_header.php"; S_LAST_CHECK,S_LAST_VALUE,S_CHANGE,S_HISTORY)); $table->ShowStart(); - if($_REQUEST["hostid"] > 0) - $compare_host = " and h.hostid=".$_REQUEST["hostid"]; - else - $compare_host = " and h.hostid in (".$availiable_hosts.") "; + $compare_host = ($_REQUEST["hostid"] > 0)?(' and h.hostid='.$_REQUEST['hostid']):''; $any_app_exist = false; - + $db_applications = DBselect("select distinct h.host,h.hostid,a.* from applications a,hosts h ". " where a.hostid=h.hostid".$compare_host.' and h.hostid in ('.$availiable_hosts.')'. " and h.status=".HOST_STATUS_MONITORED." order by a.name,a.applicationid,h.host"); while($db_app = DBfetch($db_applications)) - { + { $db_items = DBselect("select distinct i.* from items i,items_applications ia". " where ia.applicationid=".$db_app["applicationid"]." and i.itemid=ia.itemid". " and i.status=".ITEM_STATUS_ACTIVE. @@ -276,96 +273,121 @@ include_once "include/page_header.php"; $table->ShowRow($row); } } - $db_items = DBselect("select h.host,h.hostid,i.* from hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid". - " where ia.itemid is NULL and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE. - $compare_host.' and h.hostid in ('.$availiable_hosts.") order by i.description,h.host,i.itemid"); - - $app_rows = array(); - $item_cnt = 0; - while($db_item = DBfetch($db_items)) - { - $description = item_description($db_item["description"],$db_item["key_"]); - - if( '' != $_REQUEST["select"] && !stristr($description, $_REQUEST["select"]) ) continue; - - ++$item_cnt; - if(!in_array(0,$_REQUEST["applications"]) && $any_app_exist && !isset($show_all_apps)) continue; - - if(isset($db_item["lastclock"])) - $lastclock=zbx_date2str(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]); - else - $lastclock = new CCol('-', 'center'); - - $lastvalue=format_lastvalue($db_item); + - if( isset($db_item["lastvalue"]) && isset($db_item["prevvalue"]) && - ($db_item["value_type"] == ITEM_VALUE_TYPE_FLOAT || $db_item["value_type"] == ITEM_VALUE_TYPE_UINT64) && - ($db_item["lastvalue"]-$db_item["prevvalue"] != 0) ) + $sql = 'SELECT DISTINCT h.host,h.hostid '. + ' FROM hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid'. + ' WHERE ia.itemid is NULL '. + ' AND h.hostid=i.hostid '. + ' AND h.status='.HOST_STATUS_MONITORED. + ' AND i.status='.ITEM_STATUS_ACTIVE. + $compare_host. + ' AND h.hostid in ('.$availiable_hosts.') '. + ' ORDER BY h.host'; + + $db_appitems = DBselect($sql); + + while($db_appitem = DBfetch($db_appitems)){ + + $sql = 'SELECT h.host,h.hostid,i.* '. + ' FROM hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid'. + ' WHERE ia.itemid is NULL '. + ' AND h.hostid=i.hostid '. + ' AND h.status='.HOST_STATUS_MONITORED. + ' AND i.status='.ITEM_STATUS_ACTIVE. + $compare_host. + ' AND h.hostid='.$db_appitem['hostid']. + ' ORDER BY i.description,i.itemid'; + + $db_items = DBselect($sql); + + $app_rows = array(); + $item_cnt = 0; + + while($db_item = DBfetch($db_items)) { - if($db_item["lastvalue"]-$db_item["prevvalue"]<0) + $description = item_description($db_item["description"],$db_item["key_"]); + + if( '' != $_REQUEST["select"] && !stristr($description, $_REQUEST["select"]) ) continue; + + ++$item_cnt; + if(!in_array(0,$_REQUEST["applications"]) && $any_app_exist && !isset($show_all_apps)) continue; + + if(isset($db_item["lastclock"])) + $lastclock=zbx_date2str(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]); + else + $lastclock = new CCol('-', 'center'); + + $lastvalue=format_lastvalue($db_item); + + if( isset($db_item["lastvalue"]) && isset($db_item["prevvalue"]) && + ($db_item["value_type"] == ITEM_VALUE_TYPE_FLOAT || $db_item["value_type"] == ITEM_VALUE_TYPE_UINT64) && + ($db_item["lastvalue"]-$db_item["prevvalue"] != 0) ) { - $change=convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]); - $change=nbsp($change); + if($db_item["lastvalue"]-$db_item["prevvalue"]<0) + { + $change=convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]); + $change=nbsp($change); + } + else + { + $change="+".convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]); + $change=nbsp($change); + } } else { - $change="+".convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]); - $change=nbsp($change); + $change=new CCol("-","center"); } + if(($db_item["value_type"]==ITEM_VALUE_TYPE_FLOAT) ||($db_item["value_type"]==ITEM_VALUE_TYPE_UINT64)) + { + $actions=new CLink(S_GRAPH,"history.php?action=showgraph&itemid=".$db_item["itemid"],"action"); + } + else + { + $actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$db_item["itemid"],"action"); + } + array_push($app_rows, new CRow(array( + is_show_subnodes() ? SPACE : null,//get_node_name_by_elid($db_item['itemid']) : null, + $_REQUEST["hostid"] > 0 ? NULL : SPACE,//$db_item["host"], + str_repeat(SPACE, ($any_app_exist ? 6 : 0)).$description, + $lastclock, + new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), + $change, + $actions + ))); } - else - { - $change=new CCol("-","center"); - } - if(($db_item["value_type"]==ITEM_VALUE_TYPE_FLOAT) ||($db_item["value_type"]==ITEM_VALUE_TYPE_UINT64)) - { - $actions=new CLink(S_GRAPH,"history.php?action=showgraph&itemid=".$db_item["itemid"],"action"); - } - else - { - $actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$db_item["itemid"],"action"); - } - - array_push($app_rows, new CRow(array( - is_show_subnodes() ? SPACE : null, - $_REQUEST["hostid"] > 0 ? NULL : $db_item["host"], - str_repeat(SPACE, ($any_app_exist ? 6 : 0)).$description, - $lastclock, - new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), - $change, - $actions - ))); - } - - if($item_cnt > 0) - { - if($any_app_exist) + + if($item_cnt > 0) { - if(in_array(0,$_REQUEST["applications"]) || isset($show_all_apps)) - $link = new CLink(new CImg("images/general/opened.gif"), - "?close=1&applicationid=0". - url_param("groupid").url_param("hostid").url_param("applications"). - url_param("select")); - else - $link = new CLink(new CImg("images/general/closed.gif"), - "?open=1&applicationid=0". - url_param("groupid").url_param("hostid").url_param("applications"). - url_param("select")); - - $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS), - SPACE."(".$item_cnt.SPACE.S_ITEMS.")")); - $col->SetColSpan(5); - - $table->ShowRow(array( - is_show_subnodes() ? SPACE : null, - $_REQUEST["hostid"] > 0 ? NULL : SPACE, + if($any_app_exist) + { + if(in_array(0,$_REQUEST["applications"]) || isset($show_all_apps)) + $link = new CLink(new CImg("images/general/opened.gif"), + "?close=1&applicationid=0". + url_param("groupid").url_param("hostid").url_param("applications"). + url_param("select")); + else + $link = new CLink(new CImg("images/general/closed.gif"), + "?open=1&applicationid=0". + url_param("groupid").url_param("hostid").url_param("applications"). + url_param("select")); + + $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS), + SPACE."(".$item_cnt.SPACE.S_ITEMS.")")); + $col->SetColSpan(5); + + $table->ShowRow(array( + get_node_name_by_elid($db_appitem['hostid']), + $_REQUEST["hostid"] > 0 ? NULL : $db_appitem["host"], $col - )); - } - foreach($app_rows as $row) - $table->ShowRow($row); + )); + } + foreach($app_rows as $row) + $table->ShowRow($row); + } } - + $table->ShowEnd(); ?> <?php |
