diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-06-04 10:37:48 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-06-04 10:37:48 +0000 |
| commit | c3cb3f34ea615de16fa507271ca61cf5f426b5c1 (patch) | |
| tree | c375c800742bac451b7049f447082cbd604a3277 /frontends/php | |
| parent | dee7748ce3a458856713e608569c47c6d5ea65d4 (diff) | |
| download | zabbix-c3cb3f34ea615de16fa507271ca61cf5f426b5c1.tar.gz zabbix-c3cb3f34ea615de16fa507271ca61cf5f426b5c1.tar.xz zabbix-c3cb3f34ea615de16fa507271ca61cf5f426b5c1.zip | |
Improvements for escalation management.
git-svn-id: svn://svn.zabbix.com/trunk@1813 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/config.php | 32 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/escalations.inc.php | 196 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 51 | ||||
| -rw-r--r-- | frontends/php/include/local_en.inc.php | 10 |
7 files changed, 112 insertions, 183 deletions
diff --git a/frontends/php/config.php b/frontends/php/config.php index 6c71bb1e..f4cc7821 100644 --- a/frontends/php/config.php +++ b/frontends/php/config.php @@ -20,6 +20,7 @@ ?> <?php include "include/config.inc.php"; + include "include/forms.inc.php"; $page["title"] = S_CONFIGURATION_OF_ZABBIX; $page["file"] = "config.php"; @@ -76,6 +77,26 @@ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,"Alarm history [".$_GET["alarm_history"]."] alert history [".$_GET["alert_history"]."]"); } } + if($_GET["register"]=="add escalation") + { + $dflt=iif(isset($_GET["dflt"])&&($_GET["dflt"]=="on"),1,0); + $result=add_escalation($_GET["name"],$dflt); + if($result) + { + add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ESCALATION,"Escalation [".addslashes($_GET["name"])."]"); + } + show_messages($result, S_ESCALATION_ADDED, S_ESCALATION_WAS_NOT_ADDED); + } + if($_GET["register"]=="delete escalation") + { + $result=delete_escalation($_GET["escalationid"]); + if($result) + { + add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_ESCALATION,"Escalation ID [".addslashes($_GET["$escalationid"])."]"); + } + unset($_GET["escalationid"]); + show_messages($result, S_ESCALATION_DELETED, S_ESCALATION_WAS_NOT_DELETED); + } if($_GET["register"]=="add") { $result=add_mediatype($_GET["type"],$_GET["description"],$_GET["smtp_server"],$_GET["smtp_helo"],$_GET["smtp_email"],$_GET["exec_path"]); @@ -413,28 +434,31 @@ table_begin(); table_header(array(S_ID,S_DESCRIPTION_SMALL,S_DEFAULT,S_ACTIONS)); - $result=DBselect("select escalationid, name from escalations order by name"); + $result=DBselect("select * from escalations order by name"); $col=0; while($row=DBfetch($result)) { + $yes=iif($row["dflt"]==1,array("value"=>S_YES,"class"=>"on"),array("value"=>S_NO,"class"=>"off")); + $actions="<a href=\"config.php?config=2®ister=change&escalationid=".$row["escalationid"]."\">".S_CHANGE."</a>"; table_row(array( $row["escalationid"], $row["name"], - array("value"=>S_YES,"class"=>"on"), + $yes, $actions),$col++); } if(DBnum_rows($result)==0) { echo "<TR BGCOLOR=#EEEEEE>"; - echo "<TD COLSPAN=3 ALIGN=CENTER>".S_NO_ESCALATION_RULES_DEFINED."</TD>"; + echo "<TD COLSPAN=4 ALIGN=CENTER>".S_NO_ESCALATION_RULES_DEFINED."</TD>"; echo "<TR>"; } table_end(); + insert_escalation_form($_GET["escalationid"]); echo "<br>"; - show_table_header(S_ESCALATION_DETAILS_BIG); + show_table_header(S_ESCALATION_RULES); table_begin(); table_header(array(S_LEVEL,S_TIME,S_DELAY_BEFORE_ACTION,S_ACTIONS)); diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 321f0058..d3972a1f 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -31,6 +31,7 @@ include_once "include/html.inc.php"; include_once "include/audit.inc.php"; + include_once "include/escalations.inc.php"; include_once "include/hosts.inc.php"; include_once "include/users.inc.php"; include_once "include/graphs.inc.php"; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 2a9dd3da..64f07f63 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -78,15 +78,13 @@ { global $DB,$DB_TYPE; -# echo $query,"<br>"; - if($DB_TYPE == "MYSQL") { $result=mysql_query($query,$DB); if(!$result) { - echo "ERROR EXECUTING: $query<br>"; + error("SQL error: ".mysql_error()); } return $result; } diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index de3895d1..c179dbd1 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -38,6 +38,7 @@ define("AUDIT_RESOURCE_ACTION", 5); define("AUDIT_RESOURCE_GRAPH", 6); define("AUDIT_RESOURCE_GRAPH_ELEMENT", 7); + define("AUDIT_RESOURCE_ESCALATION", 8); diff --git a/frontends/php/include/escalations.inc.php b/frontends/php/include/escalations.inc.php index 67a1bd8a..e118ddc2 100644 --- a/frontends/php/include/escalations.inc.php +++ b/frontends/php/include/escalations.inc.php @@ -19,210 +19,58 @@ **/ ?> <?php - # Add Host definition + # Add escalation definition - function add_host($host,$port,$status,$useip,$ip,$host_templateid,$newgroup,$groups) + function add_escalation($name,$dflt) { - if(!check_right("Host","A",0)) + if(!check_right("Configuration of Zabbix","U",0)) { error("Insufficient permissions"); - return 0; + return 0; } - if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, &$arr)) - { - error("Hostname should contain 0-9a-zA-Z_.- characters only"); - return 0; - } - - $sql="select * from hosts where host='$host'"; - $result=DBexecute($sql); - if(DBnum_rows($result)>0) - { - error("Host '$host' already exists"); - return 0; - } - - if( isset($useip) && ($useip=="on") ) - { - $useip=1; - } - else - { - $useip=0; - } - - - $sql="insert into hosts (host,port,status,useip,ip,disable_until,available) values ('$host',$port,$status,$useip,'$ip',0,".HOST_AVAILABLE_UNKNOWN.")"; + $sql="insert into escalations (name,dflt) values ('$name',$dflt)"; $result=DBexecute($sql); if(!$result) { return $result; } - - $hostid=DBinsert_id($result,"hosts","hostid"); + $escalationid=DBinsert_id($result,"escalation","escalationid"); - if($host_templateid != 0) + if($dflt==1) { - add_templates_to_host($hostid,$host_templateid); -// $result=add_using_host_template($hostid,$host_templateid); - sync_host_with_templates($hostid); + $sql="update escalations set dflt=0 where escalationid<>$escalationid"; + $result=DBexecute($sql); + info("Default escalation is set to '$name'"); } - update_host_groups($hostid,$groups); - if($newgroup != "") - { - add_group_to_host($hostid,$newgroup); - } - - update_profile("HOST_PORT",$port); return $result; } - function update_host($hostid,$host,$port,$status,$useip,$ip,$newgroup,$groups) + # Delete escalation definition + + function delete_escalation($escalationid) { - if(!check_right("Host","U",$hostid)) + if(!check_right("Configuration of Zabbix","U",0)) { error("Insufficient permissions"); - return 0; + return 0; } - if (!eregi('^([0-9a-zA-Z\_\.-]+)$', $host, &$arr)) - { - error("Hostname should contain 0-9a-zA-Z_.- characters only"); - return 0; - } - - $sql="select * from hosts where host='$host' and hostid<>$hostid"; + $sql="delete from escalation_rules where escalationid=$escalationid"; $result=DBexecute($sql); - if(DBnum_rows($result)>0) + if(!$result) { - error("Host '$host' already exists"); - return 0; + return $result; } - - if($useip=="on") - { - $useip=1; - } - else - { - $useip=0; - } - $sql="update hosts set host='$host',port=$port,useip=$useip,ip='$ip' where hostid=$hostid"; + $sql="delete from escalations where escalationid=$escalationid"; $result=DBexecute($sql); - - - update_host_status($hostid, $status); - update_host_groups($hostid,$groups); - if($newgroup != "") - { - add_group_to_host($hostid,$newgroup); - } - return $result; - } - - # Add templates linked to template host to the host - - function add_templates_to_host($hostid,$host_templateid) - { - $sql="select * from hosts_templates where hostid=$host_templateid"; - $result=DBselect($sql); - while($row=DBfetch($result)) - { - add_template_linkage($hostid,$row["templateid"],$row["items"],$row["triggers"],$row["actions"], - $row["graphs"],$row["screens"]); - } - } - - function delete_groups_by_hostid($hostid) - { - $sql="select groupid from hosts_groups where hostid=$hostid"; - $result=DBselect($sql); - while($row=DBfetch($result)) - { - $sql="delete from hosts_groups where hostid=$hostid and groupid=".$row["groupid"]; - DBexecute($sql); - $sql="select count(*) as count from hosts_groups where groupid=".$row["groupid"]; - $result2=DBselect($sql); - $row2=DBfetch($result2); - if($row2["count"]==0) - { - $sql="delete from groups where groupid=".$row["groupid"]; - DBexecute($sql); - } - } - } - - # Delete Host - - function delete_host($hostid) - { - global $DB_TYPE; - - if($DB_TYPE=="MYSQL") - { - $sql="update hosts set status=".HOST_STATUS_DELETED.",host=concat(host,\" [DELETED]\") where hostid=$hostid"; - } - else - { - $sql="update hosts set status=".HOST_STATUS_DELETED.",host=host||' [DELETED]' where hostid=$hostid"; - } - return DBexecute($sql); - } - - function delete_host_group($groupid) - { - $sql="delete from hosts_groups where groupid=$groupid"; - DBexecute($sql); - $sql="delete from groups where groupid=$groupid"; - return DBexecute($sql); - } - - function get_host_by_hostid($hostid) - { - $sql="select hostid,host,useip,ip,port,status from hosts where hostid=$hostid"; - $result=DBselect($sql); - if(DBnum_rows($result) == 1) - { - $host["hostid"]=DBget_field($result,0,0); - $host["host"]=DBget_field($result,0,1); - $host["useip"]=DBget_field($result,0,2); - $host["ip"]=DBget_field($result,0,3); - $host["port"]=DBget_field($result,0,4); - $host["status"]=DBget_field($result,0,5); - } - else + if(!$result) { - error("No host with hostid=[$hostid]"); + return $result; } - return $host; - } - - # Update Host status - function update_host_status($hostid,$status) - { - if(!check_right("Host","U",0)) - { - error("Insufficient permissions"); - return 0; - } - - $sql="select status,host from hosts where hostid=$hostid"; - $result=DBselect($sql); - $old_status=DBget_field($result,0,0); - if($status != $old_status) - { - update_trigger_value_to_unknown_by_hostid($hostid); - $sql="update hosts set status=$status where hostid=$hostid and status!=".HOST_STATUS_DELETED; - info("Updated status of host ".DBget_field($result,0,1)); - return DBexecute($sql); - } - else - { - return 1; - } + return $result; } ?> diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index b904f867..f25fd897 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1059,4 +1059,55 @@ show_table2_header_end(); } + + # Insert escalation form + function insert_escalation_form($escalationid) + { + if(isset($escalationid)) + { + $result=DBselect("select * from escalations where escalationid=$escalationid"); + + $row=DBfetch($result); + + $name=$row["name"]; + $dflt=$row["dflt"]; + } + else + { + $name=""; + $dflt=0; + } + + $col=0; + + show_form_begin("escalations"); + echo S_ESCALATION; + + show_table2_v_delimiter($col++); + echo "<form method=\"get\" action=\"config.php\">"; + echo "<input class=\"biginput\" name=\"config\" type=\"hidden\" value=\"".$_GET["config"]."\" size=8>"; + if(isset($escalationid)) + { + echo "<input class=\"biginput\" name=\"escalationid\" type=\"hidden\" value=\"$escalationid\" size=8>"; + } + + echo S_NAME; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"name\" size=32 value=\"$name\">"; + + show_table2_v_delimiter($col++); + echo S_IS_DEFAULT; + show_table2_h_delimiter(); + echo "<input type=checkbox ".iif($dflt==1,"checked","")." name=\"dflt\">"; + + show_table2_v_delimiter2($col++); + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add escalation\">"; + if(isset($escalationid)) + { + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update escalation\">"; + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete escalation\" onClick=\"return Confirm('Delete selected escalation?');\">"; + } + + show_table2_header_end(); + } ?> diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php index dc0b2c5f..aadeb6ca 100644 --- a/frontends/php/include/local_en.inc.php +++ b/frontends/php/include/local_en.inc.php @@ -25,7 +25,7 @@ // about.php define("S_ABOUT_ZABBIX", "About ZABBIX"); - define("S_INFORMATION_ABOUT_ZABBIX", "Information about ZABBIX (v1.1alpha10)"); + define("S_INFORMATION_ABOUT_ZABBIX", "Information about ZABBIX (v1.1alpha11)"); define("S_HOMEPAGE_OF_ZABBIX", "Homepage of ZABBIX"); define("S_HOMEPAGE_OF_ZABBIX_DETAILS", "This is home page of ZABBIX."); define("S_LATEST_ZABBIX_MANUAL", "Latest ZABBIX Manual"); @@ -164,11 +164,17 @@ define("S_HOUSEKEEPER", "Housekeeper"); define("S_MEDIA_TYPES", "Media types"); define("S_ESCALATION_RULES", "Escalation rules"); + define("S_ESCALATION", "Escalation"); define("S_ESCALATION_RULES_BIG", "ESCALATION RULES"); define("S_NO_ESCALATION_RULES_DEFINED", "No escalation rules defined"); define("S_NO_ESCALATION_DETAILS", "No escalation details"); define("S_ESCALATION_DETAILS_BIG", "ESCALATION DETAILS"); + define("S_ESCALATION_ADDED", "Escalation added"); + define("S_ESCALATION_WAS_NOT_ADDED", "Escalation was not added"); + define("S_ESCALATION_DELETED", "Escalation deleted"); + define("S_ESCALATION_WAS_NOT_DELETED", "Escalation was not deleted"); define("S_DEFAULT", "Default"); + define("S_IS_DEFAULT", "Is default"); define("S_LEVEL", "Level"); define("S_DELAY_BEFORE_ACTION", "Delay before action"); define("S_IMAGES", "Images"); @@ -194,7 +200,7 @@ define("S_COMPARE", "Compare"); // Footer - define("S_ZABBIX_VER", "ZABBIX 1.1alpha10"); + define("S_ZABBIX_VER", "ZABBIX 1.1alpha11"); define("S_COPYRIGHT_BY", "Copyright 2001-2005 by "); define("S_CONNECTED_AS", "Connected as"); define("S_SIA_ZABBIX", "SIA Zabbix"); |
