summaryrefslogtreecommitdiffstats
path: root/frontends/php/latest.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-04-05 09:16:29 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-04-05 09:16:29 +0000
commit0c9653d6ab8fca3be69489943f1fcc4e9d797102 (patch)
tree4e3d0f7e328577428161b62d3872bbdeefacb70c /frontends/php/latest.php
parent07abfc5904f98fd5139b5ac6d92aaa34a7ccf9b7 (diff)
downloadzabbix-0c9653d6ab8fca3be69489943f1fcc4e9d797102.tar.gz
zabbix-0c9653d6ab8fca3be69489943f1fcc4e9d797102.tar.xz
zabbix-0c9653d6ab8fca3be69489943f1fcc4e9d797102.zip
- added latest values filtring/marking of log history (Eugene)
- developed multiple log history viewing (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2719 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/latest.php')
-rw-r--r--frontends/php/latest.php295
1 files changed, 123 insertions, 172 deletions
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index c7ce7670..3fd24cce 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -46,12 +46,6 @@
?>
<?php
- if(isset($_REQUEST["select"])&&($_REQUEST["select"]!=""))
- {
- unset($_REQUEST["groupid"]);
- unset($_REQUEST["hostid"]);
- }
-
if(isset($_REQUEST["hostid"])&&!check_right("Host","R",$_REQUEST["hostid"]))
{
show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
@@ -59,232 +53,189 @@
exit;
}
?>
-
<?php
- if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]==0))
+ $_REQUEST["groupid"] = get_request("groupid",0);
+ $_REQUEST["select"] = get_request("select","");
+ $_REQUEST["hostid"]=get_request("hostid",get_profile("web.latest.hostid",0));
+ update_profile("web.latest.hostid",$_REQUEST["hostid"]);
+ update_profile("web.menu.view.last",$page["file"]);
+
+ if($_REQUEST["hostid"] > 0)
{
- unset($_REQUEST["groupid"]);
+ $result=DBselect("select host from hosts where hostid=".$_REQUEST["hostid"]);
+ if(DBnum_rows($result)==0)
+ {
+ $_REQUEST["hostid"] = 0;
+ }
}
-?>
-<?php
- $_REQUEST["hostid"]=@iif(isset($_REQUEST["hostid"]),$_REQUEST["hostid"],get_profile("web.latest.hostid",0));
- update_profile("web.latest.hostid",$_REQUEST["hostid"]);
- update_profile("web.menu.view.last",$page["file"]);
?>
<?php
- $h1=SPACE.S_LATEST_DATA_BIG;
+ $r_form = new CForm();
+
+ $r_form->AddVar("select",$_REQUEST["select"]);
- $h2=S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
$result=DBselect("select groupid,name from groups order by name");
while($row=DBfetch($result))
{
// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
+ $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
+ " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid".
+ " and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host".
+ " order by h.host");
while($row2=DBfetch($result2))
{
if(!check_right("Host","R",$row2["hostid"]))
- {
continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
+ break;
}
}
- $h2=$h2."</select>";
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
- $h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
- if(isset($_REQUEST["groupid"]))
+ if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid group by h.hostid,h.host order by h.host";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid group by h.hostid,h.host order by h.host";
}
-
$result=DBselect($sql);
+ $first_hostid = -1;
+ $correct_hostid = 'no';
while($row=DBfetch($result))
{
if(!check_right("Host","R",$row["hostid"]))
- {
continue;
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
+
+ if($first_hostid == -1) $first_hostid = $row["hostid"];
+
+ if($_REQUEST["hostid"]!=0){
+ if($_REQUEST["hostid"] == $row["hostid"])
+ $correct_hostid = 'ok';
}
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
}
- $h2=$h2."</select>";
+ if($correct_hostid == 'no' && $_REQUEST["groupid"] > 0)
+ $_REQUEST["hostid"] = $first_hostid;
- $h2=$h2.nbsp(" ");
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+ show_header2(S_LATEST_DATA_BIG,$r_form);
- if(isset($_REQUEST["select"])&&($_REQUEST["select"]==""))
- {
- unset($_REQUEST["select"]);
- }
-// $h2=$h2.S_SELECT;
-// $h2=$h2.nbsp(" ");
- if(isset($_REQUEST["select"]))
- {
- $h2=$h2."<input class=\"biginput\" type=\"text\" name=\"select\" value=\"".$_REQUEST["select"]."\">";
- }
- else
- {
- $h2=$h2."<input class=\"biginput\" type=\"text\" name=\"select\" value=\"\">";
- }
- $h2=$h2.nbsp(" ");
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"do\" value=\"select\">";
+ $r_form = new CForm();
+
+ $r_form->AddVar("hostid",$_REQUEST["hostid"]);
+ $r_form->AddVar("groupid",$_REQUEST["groupid"]);
+
+ $r_form->AddItem(array("Show items with description like ", new CTextBox("select",$_REQUEST["select"],20)));
+ $r_form->AddItem(array(SPACE, new CButton("show",S_SHOW)));
- show_header2($h1, $h2, "<form name=\"form2\" method=\"get\" action=\"latest.php\">", "</form>");
+ show_header2(NULL, $r_form);
?>
<?php
- if(isset($_REQUEST["hostid"]))
- {
- $result=DBselect("select host from hosts where hostid=".$_REQUEST["hostid"]);
- if(DBnum_rows($result)==0)
- {
- unset($_REQUEST["hostid"]);
- }
- }
+ $table=new CTableInfo();
+ $header=array(
+ $_REQUEST["hostid"] ==0 ? S_HOST : NULL,
+ S_DESCRIPTION,S_LAST_CHECK,S_LAST_VALUE,S_CHANGE,S_HISTORY);
+ $table->SetHeader($header);
+
+ if($_REQUEST["select"] != "")
+ $compare_description = " and i.description like ".zbx_dbstr("%".$_REQUEST["select"]."%");
+ else
+ $compare_description = "";
- if(isset($_REQUEST["hostid"])||isset($_REQUEST["select"]))
- {
+ if($_REQUEST["hostid"] != 0)
+ $compare_host = " and h.hostid=".$_REQUEST["hostid"];
+ else
+ $compare_host = "";
-// echo "<br>";
- if(!isset($_REQUEST["select"])||($_REQUEST["select"] == ""))
- {
- $result=get_host_by_hostid($_REQUEST["hostid"]);
- $host=$result["host"];
-// show_table_header("<a href=\"latest.php?hostid=".$_REQUEST["hostid"]."\">$host</a>");
- }
- else
+ $sql="select h.host,i.*,h.hostid from items i,hosts h".
+ " where h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED.
+ " and i.status=0".$compare_description.$compare_host.
+ " order by i.description";
+
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ if(!check_right("Item","R",$row["itemid"]))
{
-// show_table_header("Description is like *".$_REQUEST["select"]."*");
+ continue;
}
-# show_table_header_begin();
-# echo "<a href=\"latest.php?hostid=".$_REQUEST["hostid"]."\">$host</a>";
-# show_table3_v_delimiter();
-
-// table_begin();
- $header=array();
- if(isset($_REQUEST["select"]))
+ if(!check_right("Host","R",$row["hostid"]))
{
- $header=array_merge($header,array(S_HOST));
+ continue;
}
- $header=array_merge($header,array(S_DESCRIPTION, S_LAST_CHECK, S_LAST_VALUE,S_CHANGE,S_HISTORY));
- $table=new CTableInfo();
- $table->setHeader($header);
-
-// table_header($header);
-
- $col=0;
- if(isset($_REQUEST["select"]))
- $sql="select h.host,i.*,h.hostid from items i,hosts h".
- " where h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED.
- " and i.status=0 and i.description like ".zbx_dbstr("%",$_REQUEST["select"]."%").
- " order by i.description";
+ if(isset($row["lastclock"]))
+ $lastclock=date(S_DATE_FORMAT_YMDHMS,$row["lastclock"]);
else
- $sql="select h.host,i.*,h.hostid from items i,hosts h".
- " where h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED.
- " and i.status=0 and h.hostid=".$_REQUEST["hostid"]." order by i.description";
+ $lastclock="-";
- $result=DBselect($sql);
- while($row=DBfetch($result))
+ if(isset($row["lastvalue"]))
{
- if(!check_right("Item","R",$row["itemid"]))
- {
- continue;
- }
- if(!check_right("Host","R",$row["hostid"]))
+ if(($row["value_type"] == ITEM_VALUE_TYPE_FLOAT) ||
+ ($row["value_type"] == ITEM_VALUE_TYPE_UINT64))
{
- continue;
- }
-
-// iif_echo($col++%2 == 1,
-// "<tr bgcolor=#DDDDDD>",
-// "<tr bgcolor=#EEEEEE>");
-
- $host=NULL;
- if(isset($_REQUEST["select"]))
- {
- $host=$row["host"];
- }
- $description = item_description($row["description"],$row["key_"]);
-
- if(isset($row["lastclock"]))
- {
- $lastclock=date(S_DATE_FORMAT_YMDHMS,$row["lastclock"]);
+ $lastvalue=convert_units($row["lastvalue"],$row["units"]);
}
else
{
- $lastclock="-";
+ $lastvalue=nbsp(htmlspecialchars(substr($row["lastvalue"],0,20)." ..."));
}
-
- if(isset($row["lastvalue"]))
- {
- if(($row["value_type"] == ITEM_VALUE_TYPE_FLOAT) ||
- ($row["value_type"] == ITEM_VALUE_TYPE_UINT64))
- {
- $lastvalue=convert_units($row["lastvalue"],$row["units"]);
- }
- else
- {
- $lastvalue=nbsp(htmlspecialchars(substr($row["lastvalue"],0,20)." ..."));
- }
- $lastvalue = replace_value_by_map($lastvalue, $row["valuemapid"]);
- }
- else
- {
- $lastvalue=new CCol("-","center");
- }
- if( isset($row["lastvalue"]) && isset($row["prevvalue"]) &&
- ($row["value_type"] == 0) && ($row["lastvalue"]-$row["prevvalue"] != 0) )
- {
- if($row["lastvalue"]-$row["prevvalue"]<0)
- {
- $change=convert_units($row["lastvalue"]-$row["prevvalue"],$row["units"]);
- $change=nbsp($change);
- }
- else
- {
- $change="+".convert_units($row["lastvalue"]-$row["prevvalue"],$row["units"]);
- $change=nbsp($change);
- }
- }
- else
- {
- $change=new CCol("-","center");
- }
- if(($row["value_type"]==ITEM_VALUE_TYPE_FLOAT) ||($row["value_type"]==ITEM_VALUE_TYPE_UINT64))
+ $lastvalue = replace_value_by_map($lastvalue, $row["valuemapid"]);
+ }
+ else
+ {
+ $lastvalue=new CCol("-","center");
+ }
+ if( isset($row["lastvalue"]) && isset($row["prevvalue"]) &&
+ ($row["value_type"] == 0) && ($row["lastvalue"]-$row["prevvalue"] != 0) )
+ {
+ if($row["lastvalue"]-$row["prevvalue"]<0)
{
- $actions=new CLink(S_GRAPH,"history.php?action=showhistory&itemid=".$row["itemid"],"action");
+ $change=convert_units($row["lastvalue"]-$row["prevvalue"],$row["units"]);
+ $change=nbsp($change);
}
else
{
- $actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$row["itemid"],"action");
+ $change="+".convert_units($row["lastvalue"]-$row["prevvalue"],$row["units"]);
+ $change=nbsp($change);
}
-
- $table->addRow(array(
- $host,
- $description,
- $lastclock,
- $lastvalue,
- $change,
- $actions
- ));
}
- $table->show();
+ else
+ {
+ $change=new CCol("-","center");
+ }
+ if(($row["value_type"]==ITEM_VALUE_TYPE_FLOAT) ||($row["value_type"]==ITEM_VALUE_TYPE_UINT64))
+ {
+ $actions=new CLink(S_GRAPH,"history.php?action=showgraph&itemid=".$row["itemid"],"action");
+ }
+ else
+ {
+ $actions=new CLink(S_HISTORY,"history.php?action=showvalues&period=3600&itemid=".$row["itemid"],"action");
+ }
+
+ $table->addRow(array(
+ $_REQUEST["hostid"] ==0 ? $row["host"] : NULL,
+ item_description($row["description"],$row["key_"]),
+ $lastclock,
+ $lastvalue,
+ $change,
+ $actions
+ ));
}
+ $table->show();
?>
<?php