summaryrefslogtreecommitdiffstats
path: root/frontends/php/latest.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
commit4182bc6afb20b00fa27a54c67056bb98a58a49bb (patch)
tree5cab17d23e387cc3b6e8c92e4c928ac5e1111b76 /frontends/php/latest.php
parent6a6ac0772b8215bffc5fe8b02fc1033dbf273f41 (diff)
downloadzabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.gz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.xz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.zip
- speed improvement for Overview screens (Eugene)
- developed 'net.if.total[*]' parameter (Eugene) - fixed new map link adding (Eugene) - fixed host group adding (Eugene) - fixed map displaying (Eugene) - fixed 'No permissions' for 'Latest data','Triggers','Alarms' screens (Eugene) - fixed permision deletion (Eugene) - fixed 'get_map_by_sysmapid' function calls(Eugene) - improved php code execution speed (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2825 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/latest.php')
-rw-r--r--frontends/php/latest.php132
1 files changed, 69 insertions, 63 deletions
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 68e01142..39735fb5 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -56,7 +56,7 @@
?>
<?php
- if(!check_right("Host","R",$_REQUEST["hostid"]))
+ if($_REQUEST["hostid"] > 0 && !check_right("Host","R",$_REQUEST["hostid"]))
{
show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
show_page_footer();
@@ -165,10 +165,11 @@
<?php
$table=new CTableInfo();
- $header=array(
+ $table->SetHeader(array(
$_REQUEST["hostid"] ==0 ? S_HOST : NULL,
- S_DESCRIPTION,S_LAST_CHECK,S_LAST_VALUE,S_CHANGE,S_HISTORY);
- $table->SetHeader($header);
+ S_DESCRIPTION,S_LAST_CHECK,S_LAST_VALUE,S_CHANGE,S_HISTORY));
+ $table->ShowStart();
+ $table->ShowBody();
if($_REQUEST["select"] != "")
$compare_description = " and i.description like ".zbx_dbstr("%".$_REQUEST["select"]."%");
@@ -180,6 +181,8 @@
else
$compare_host = "";
+ $any_app_exist = false;
+
$db_applications = DBselect("select h.host,h.hostid,a.* from applications a,hosts h where a.hostid=h.hostid".$compare_host.
" order by a.name,a.applicationid,h.host");
while($db_app = DBfetch($db_applications))
@@ -193,8 +196,8 @@
" order by i.description";
$db_items = DBselect($sql);
-
- $currAppID = -1;
+ $app_rows = array();
+ $item_cnt = 0;
while($db_item = DBfetch($db_items))
{
if(!check_right("Item","R",$db_item["itemid"]))
@@ -205,30 +208,9 @@
{
continue;
}
-
- if($currAppID != $db_app["applicationid"])
- {
- $currAppID = $db_app["applicationid"];
-
- if(in_array($db_app["applicationid"],$_REQUEST["applications"]))
- $link = new CLink(new CImg("images/general/opened.gif"),
- "latest.php?close=1&applicationid=".$db_app["applicationid"].
- url_param("groupid").url_param("hostid").url_param("applications").
- url_param("select"));
- else
- $link = new CLink(new CImg("images/general/closed.gif"),
- "latest.php?open=1&applicationid=".$db_app["applicationid"].
- url_param("groupid").url_param("hostid").url_param("applications").
- url_param("select"));
-
- $col = new CCol(array($link,SPACE,bold($db_app["name"]),
- SPACE."(".DBnum_rows($db_items).SPACE.S_ITEMS.")"));
- $col->SetColSpan(5);
- $table->AddRow(array($_REQUEST["hostid"] > 0 ? NULL : $db_app["host"], $col));
-
- if(!in_array($db_app["applicationid"],$_REQUEST["applications"])) break;
- }
+ ++$item_cnt;
+ if(!in_array($db_app["applicationid"],$_REQUEST["applications"])) continue;
if(isset($db_item["lastclock"]))
$lastclock=date(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]);
@@ -279,30 +261,48 @@
$actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$db_item["itemid"],"action");
}
- $table->AddRow(array(
+ array_push($app_rows, new CRow(array(
$_REQUEST["hostid"] > 0 ? NULL : SPACE,
str_repeat(SPACE,6).item_description($db_item["description"],$db_item["key_"]),
$lastclock,
$lastvalue,
$change,
$actions
- ));
+ )));
}
+ if($item_cnt > 0)
+ {
+ if(in_array($db_app["applicationid"],$_REQUEST["applications"]))
+ $link = new CLink(new CImg("images/general/opened.gif"),
+ "latest.php?close=1&applicationid=".$db_app["applicationid"].
+ url_param("groupid").url_param("hostid").url_param("applications").
+ url_param("select"));
+ else
+ $link = new CLink(new CImg("images/general/closed.gif"),
+ "latest.php?open=1&applicationid=".$db_app["applicationid"].
+ url_param("groupid").url_param("hostid").url_param("applications").
+ url_param("select"));
- }
+ $col = new CCol(array($link,SPACE,bold($db_app["name"]),
+ SPACE."(".$item_cnt.SPACE.S_ITEMS.")"));
+ $col->SetColSpan(5);
- $show_group_other = $table->GetNumRows() > 0 ? TRUE : FALSE;
- $space = "";
+ $table->ShowRow(array($_REQUEST["hostid"] > 0 ? NULL : $db_app["host"], $col));
+ $any_app_exist = true;
+
+ foreach($app_rows as $row)
+ $table->ShowRow($row);
+ }
+ }
$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_description.$compare_host.
" order by i.description,h.host";
-
$db_items = DBselect($sql);
- $currAppID = -1;
- $appID = 0;
+ $app_rows = array();
+ $item_cnt = 0;
while($db_item = DBfetch($db_items))
{
if(!check_right("Host","R",$db_item["hostid"]))
@@ -313,30 +313,10 @@
{
continue;
}
- if($currAppID != $appID && $show_group_other)
- {
- $currAppID = $appID;
-
- if(in_array($appID,$_REQUEST["applications"]))
- $link = new CLink(new CImg("images/general/opened.gif"),
- "latest.php?close=1&applicationid=".$appID.
- url_param("groupid").url_param("hostid").url_param("applications").
- url_param("select"));
- else
- $link = new CLink(new CImg("images/general/closed.gif"),
- "latest.php?open=1&applicationid=".$appID.
- url_param("groupid").url_param("hostid").url_param("applications").
- url_param("select"));
- $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS),
- SPACE."(".DBnum_rows($db_items).SPACE.S_ITEMS.")"));
- $col->SetColSpan(5);
-
- $table->AddRow(array($_REQUEST["hostid"] > 0 ? NULL : SPACE, $col));
+ ++$item_cnt;
+ if(!in_array(0,$_REQUEST["applications"]) && $any_app_exist) continue;
- if(!in_array($appID,$_REQUEST["applications"])) break;
- $space = str_repeat(SPACE,6);
- }
if(isset($db_item["lastclock"]))
$lastclock=date(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]);
@@ -387,16 +367,42 @@
$actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$db_item["itemid"],"action");
}
- $table->AddRow(array(
+ array_push($app_rows, new CRow(array(
$_REQUEST["hostid"] > 0 ? NULL : $db_item["host"],
- $space.item_description($db_item["description"],$db_item["key_"]),
+ str_repeat(SPACE, ($any_app_exist ? 6 : 0)).item_description($db_item["description"],$db_item["key_"]),
$lastclock,
$lastvalue,
$change,
$actions
- ));
+ )));
+ }
+
+ if($item_cnt > 0)
+ {
+ if($any_app_exist)
+ {
+ if(in_array(0,$_REQUEST["applications"]))
+ $link = new CLink(new CImg("images/general/opened.gif"),
+ "latest.php?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"),
+ "latest.php?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($_REQUEST["hostid"] > 0 ? NULL : SPACE, $col));
+ }
+ foreach($app_rows as $row)
+ $table->ShowRow($row);
}
- $table->show();
+
+ $table->ShowEnd();
?>
<?php