From d76992f73658df06227395e4a79c4366294efebe Mon Sep 17 00:00:00 2001 From: osmiy Date: Thu, 16 Mar 2006 15:26:21 +0000 Subject: - added trigger selecton from popup (Eugene) - improved popup selection (Eugene) - improved "IT services" configuration (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2702 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/popup.php | 290 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 195 insertions(+), 95 deletions(-) (limited to 'frontends/php/popup.php') diff --git a/frontends/php/popup.php b/frontends/php/popup.php index 9e3e4f8d..56385c79 100644 --- a/frontends/php/popup.php +++ b/frontends/php/popup.php @@ -21,138 +21,238 @@ ".S_NO_PERMISSIONS.""); show_page_footer(); exit; } ?> - "; - - - $h2=S_GROUP.SPACE; - $h2=$h2.""; - $h2=$h2.""; - $h2=$h2.""; - $h2=$h2.""; - show_header2($h1, $h2, "
", "
"); -?> + $btnEmpty = new CButton("empty",S_EMPTY,"window.opener.document.forms[\"$dstfrm\"].$dstfld1.value=\"0\";". + " window.opener.document.forms[\"$dstfrm\"].$dstfld2.value=\"\";". + " window.close();"); -setHeader(array(S_HOST,S_IP,S_PORT,S_STATUS,S_AVAILABILITY)); + $frmTitle->AddItem(array(SPACE,$btnEmpty)); - if(isset($_REQUEST["groupid"])&&($_REQUEST["groupid"]!=0)) - { - $sql="select h.hostid,h.host,h.port,h.status,h.useip,h.ip,h.error,h.available from hosts h,hosts_groups hg where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED." order by h.host"; - } - else - { - $sql="select h.hostid,h.host,h.port,h.status,h.useip,h.ip,h.error,h.available from hosts h where h.status<>".HOST_STATUS_DELETED." order by h.host"; - } - $result=DBselect($sql); + show_header2($page["title"], $frmTitle); +?> - while($row=DBfetch($result)) +SetHeader(array(S_HOST,S_IP,S_PORT,S_STATUS,S_AVAILABILITY)); - $host ="".$row["host"].""; + $sql = "select * from hosts h"; + if(isset($groupid)) + $sql .= ",hosts_groups hg where h.hostid=hg.hostid and hg.groupid=$groupid"; - if($row["useip"]==1) - { - $ip=$row["ip"]; - } - else - { - $ip="-"; - } - if(check_right("Host","U",$row["hostid"])) + $db_hosts = DBselect($sql); + while($host = DBfetch($db_hosts)) { - if($row["status"] == HOST_STATUS_MONITORED) + if(!check_right("Host","R",$host["hostid"])) continue; + $name = new CLink($host["host"],"#","action"); + $name->SetAction( + "window.opener.document.forms[\"$dstfrm\"].$dstfld1.value=\"".$host[$srcfld1]."\";". + " window.opener.document.forms[\"$dstfrm\"].$dstfld2.value=\"".$host[$srcfld2]."\";". + " window.close();"); + + if($host["status"] == HOST_STATUS_MONITORED) $status=new CSpan(S_MONITORED,"off"); - else if($row["status"] == HOST_STATUS_NOT_MONITORED) + else if($host["status"] == HOST_STATUS_NOT_MONITORED) $status=new CSpan(S_NOT_MONITORED,"on"); - else if($row["status"] == HOST_STATUS_TEMPLATE) + else if($host["status"] == HOST_STATUS_TEMPLATE) $status=new CSpan(S_TEMPLATE,"unknown"); - else if($row["status"] == HOST_STATUS_DELETED) + else if($host["status"] == HOST_STATUS_DELETED) $status=new CSpan(S_DELETED,"unknown"); else $status=S_UNKNOWN; + + if($host["available"] == HOST_AVAILABLE_TRUE) + $available=new CSpan(S_AVAILABLE,"off"); + else if($host["available"] == HOST_AVAILABLE_FALSE) + $available=new CSpan(S_NOT_AVAILABLE,"on"); + else if($host["available"] == HOST_AVAILABLE_UNKNOWN) + $available=new CSpan(S_UNKNOWN,"unknown"); + + $table->addRow(array( + $name, + $host["useip"]==1 ? $host["ip"] : "-", + $host["port"], + $status, + $available + )); } - else + $table->show(); + } + if($srctbl == "triggers") + { + $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); + $table->setHeader(array( + S_NAME, +// S_EXPRESSION, + S_SEVERITY, + S_STATUS)); + + + $sql = "select distinct t.*". + " from triggers t,hosts h,items i,functions f". + " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid"; + + if(isset($hostid)) + $sql .= " and h.hostid=$hostid"; + + $sql .= " order by h.host,t.description"; + + $result=DBselect($sql); + while($row=DBfetch($result)) { - if($row["status"] == HOST_STATUS_MONITORED) - $status=new CSpan(S_MONITORED,"off"); - else if($row["status"] == HOST_STATUS_NOT_MONITORED) - $status=new CSpan(S_NOT_MONITORED,"on"); -// else if($row["status"] == 2) -// $status=array("value"=>S_UNREACHABLE,"class"=>"unknown"); - else if($row["status"] == HOST_STATUS_TEMPLATE) - $status=new CSpan(S_TEMPLATE,"unknown"); - else if($row["status"] == HOST_STATUS_DELETED) - $status=new CSpan(S_DELETED,"unknown"); - else - $status=S_UNKNOWN; - } + if(check_right_on_trigger("R",$row["triggerid"]) == 0) + { + continue; + } - if($row["available"] == HOST_AVAILABLE_TRUE) - $available=new CSpan(S_AVAILABLE,"off"); - else if($row["available"] == HOST_AVAILABLE_FALSE) - $available=new CSpan(S_NOT_AVAILABLE,"on"); - else if($row["available"] == HOST_AVAILABLE_UNKNOWN) - $available=new CSpan(S_UNKNOWN,"unknown"); - - $table->addRow(array( - $host, - $ip, - $row["port"], - $status, - $available + $exp_desc = expand_trigger_description($row["triggerid"]); + $description = new CLink($exp_desc,"#","action"); + $description->SetAction( + "window.opener.document.forms[\"$dstfrm\"].$dstfld1.value=\"".$row[$srcfld1]."\";". + " window.opener.document.forms[\"$dstfrm\"].$dstfld2.value=\"$exp_desc\";". + " window.close();"); + + //add dependences + $result1=DBselect("select t.triggerid,t.description from triggers t,trigger_depends d". + " where t.triggerid=d.triggerid_up and d.triggerid_down=".$row["triggerid"]); + if(DBnum_rows($result1)>0) + { + array_push($description,BR.BR."".S_DEPENDS_ON."".SPACE.BR); + while($row1=DBfetch($result1)) + { + array_push($description,expand_trigger_description($row1["triggerid"]).BR); + } + array_push($description,BR); + } + + if($row["priority"]==0) $priority=S_NOT_CLASSIFIED; + elseif($row["priority"]==1) $priority=S_INFORMATION; + elseif($row["priority"]==2) $priority=S_WARNING; + elseif($row["priority"]==3) $priority=new CCol(S_AVERAGE,"average"); + elseif($row["priority"]==4) $priority=new CCol(S_HIGH,"high"); + elseif($row["priority"]==5) $priority=new CCol(S_DISASTER,"disaster"); + else $priority=$row["priority"]; + + if($row["status"] == TRIGGER_STATUS_DISABLED) + { + $status= new CSpan(S_DISABLED, 'disabled'); + } + else if($row["status"] == TRIGGER_STATUS_UNKNOWN) + { + $status= new CSpan(S_UNCNOWN, 'uncnown'); + } + else if($row["status"] == TRIGGER_STATUS_ENABLED) + { + $status= new CSpan(S_ENABLED, 'enabled'); + } + + if($row["status"] != TRIGGER_STATUS_UNKNOWN) $row["error"]=SPACE; + + if($row["error"]=="") $row["error"]=SPACE; + + $table->addRow(array( + $description, +// explode_exp($row["expression"],0), + $priority, + $status, )); + } + $table->show(); } - $table->show(); ?> -- cgit