summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-04 12:45:23 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-06-04 12:45:23 +0000
commit546e672bbc33aae643ff0ed08275db89da9bde31 (patch)
tree642923d9ac4467debb0dd2b3c2ad5bb3043bddb8
parent4aa6a1f2f879f2564386c713e3e601e3012db512 (diff)
downloadzabbix-546e672bbc33aae643ff0ed08275db89da9bde31.tar.gz
zabbix-546e672bbc33aae643ff0ed08275db89da9bde31.tar.xz
zabbix-546e672bbc33aae643ff0ed08275db89da9bde31.zip
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@1815 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--create/mysql/schema.sql7
-rw-r--r--create/postgresql/schema.sql7
-rw-r--r--frontends/php/config.php90
-rw-r--r--frontends/php/include/db.inc.php1
-rw-r--r--frontends/php/include/defines.inc.php1
-rw-r--r--frontends/php/include/escalations.inc.php21
-rw-r--r--frontends/php/include/forms.inc.php72
-rw-r--r--frontends/php/include/local_en.inc.php2
-rw-r--r--upgrades/dbpatches/1.1alpha10_to_1.1alpha11/mysql/patch.sql7
-rw-r--r--upgrades/dbpatches/1.1alpha10_to_1.1alpha11/postgresql/patch.sql7
10 files changed, 150 insertions, 65 deletions
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index d8bda31e..c7a76dc7 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -631,12 +631,13 @@ CREATE TABLE escalations (
--
CREATE TABLE escalation_rules (
- ruleid int(4) NOT NULL auto_increment,
+ escalationruleid int(4) NOT NULL auto_increment,
escalationid int(4) DEFAULT '0' NOT NULL,
- period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
level int(4) DEFAULT '0' NOT NULL,
+ period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
+ delay int(4) DEFAULT '0' NOT NULL,
actiontype int(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (ruleid),
+ PRIMARY KEY (escalationruleid),
KEY (escalationid)
) type=InnoDB;
diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql
index b02ab2c3..1c3d1952 100644
--- a/create/postgresql/schema.sql
+++ b/create/postgresql/schema.sql
@@ -636,12 +636,13 @@ CREATE UNIQUE INDEX escalations_name on escalations (name);
--
CREATE TABLE escalation_rules (
- ruleid serial,
+ escalationruleid serial,
escalationid int4 DEFAULT '0' NOT NULL,
- period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
level int4 DEFAULT '0' NOT NULL,
+ period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
+ delay int4 DEFAULT '0' NOT NULL,
actiontype int4 DEFAULT '0' NOT NULL,
- PRIMARY KEY (ruleid),
+ PRIMARY KEY (escalationruleid),
FOREIGN KEY (escalationid) REFERENCES escalations
);
diff --git a/frontends/php/config.php b/frontends/php/config.php
index 3c1935da..a5423a9b 100644
--- a/frontends/php/config.php
+++ b/frontends/php/config.php
@@ -80,6 +80,15 @@
add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,"Alarm history [".$_GET["alarm_history"]."] alert history [".$_GET["alert_history"]."]");
}
}
+ if($_GET["register"]=="add rule")
+ {
+ $result=add_escalation_rule($_GET["escalationid"],$_GET["level"],$_GET["period"],$_GET["delay"],$_GET["actiontype"]);
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_ADD,AUDIT_RESOURCE_ESCALATION_RULE,"Escalation ID [".addslashes($_GET["escalationid"])."]");
+ }
+ show_messages($result, S_ESCALATION_RULE_ADDED, S_ESCALATION_RULE_WAS_NOT_ADDED);
+ }
if($_GET["register"]=="add escalation")
{
$dflt=iif(isset($_GET["dflt"])&&($_GET["dflt"]=="on"),1,0);
@@ -466,61 +475,36 @@
insert_escalation_form($_GET["escalationid"]);
- echo "<br>";
- show_table_header(S_ESCALATION_RULES);
-
- table_begin();
- table_header(array(S_LEVEL,S_TIME,S_DELAY_BEFORE_ACTION,S_ACTIONS));
-
- table_row(array(
- 0,
- "1-5,09:00-18:00",
- "300",
- "Do nothing"),$col++);
- table_row(array(
- 1,
- "1-5,09:00-18:00",
- "30",
- "Execute action"),$col++);
- table_row(array(
- 2,
- "2-7,00:00-23:59",
- "30",
- "Execute action"),$col++);
- table_row(array(
- 3,
- "09:00-18:00",
- "30",
- "Execute action"),$col++);
- table_row(array(
- 4,
- "09:00-18:00",
- "0",
- "Increase severity"),$col++);
- table_row(array(
- 5,
- "09:00-18:00",
- "300",
- "Increase administrative hierarcy"),$col++);
-
- $result=DBselect("select escalationid, name from escalations order by name");
- $col=0;
- while($row=DBfetch($result))
- {
- break;
- $actions="<a href=\"config.php?config=2&register=change&escalationid=".$row["escalationid"]."\">".S_CHANGE."</a>";
- table_row(array(
- $row["escalationid"],
- $row["name"],
- $actions),$col++);
- }
- if(DBnum_rows($result)==0)
+ if(isset($_GET["escalationid"]))
{
- echo "<TR BGCOLOR=#EEEEEE>";
- echo "<TD COLSPAN=3 ALIGN=CENTER>".S_NO_ESCALATION_DETAILS."</TD>";
- echo "<TR>";
+ echo "<br>";
+ show_table_header(S_ESCALATION_RULES);
+
+ table_begin();
+ table_header(array(S_LEVEL,S_TIME,S_DELAY_BEFORE_ACTION,S_ACTIONS));
+
+ $result=DBselect("select * from escalation_rules order by level");
+ $col=0;
+ while($row=DBfetch($result))
+ {
+ $actions="<a href=\"config.php?config=2&register=change&escalationruleid=".$row["escalationruleid"]."\">".S_CHANGE."</a>";
+ table_row(array(
+ $row["level"],
+ $row["period"],
+ $row["delay"],
+ $row["action"],
+ $actions),$col++);
+ }
+ if(DBnum_rows($result)==0)
+ {
+ echo "<TR BGCOLOR=#EEEEEE>";
+ echo "<TD COLSPAN=4 ALIGN=CENTER>".S_NO_ESCALATION_DETAILS."</TD>";
+ echo "<TR>";
+ }
+ table_end();
+
+ insert_escalation_rule_form($_GET["escalationid"],$_GET["escalationruleid"]);
}
- table_end();
}
?>
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index 64f07f63..007f58e1 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -85,6 +85,7 @@
if(!$result)
{
error("SQL error: ".mysql_error());
+ error("Query: $query");
}
return $result;
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index c179dbd1..0951452f 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -39,6 +39,7 @@
define("AUDIT_RESOURCE_GRAPH", 6);
define("AUDIT_RESOURCE_GRAPH_ELEMENT", 7);
define("AUDIT_RESOURCE_ESCALATION", 8);
+ define("AUDIT_RESOURCE_ESCALATION_RULE",9);
diff --git a/frontends/php/include/escalations.inc.php b/frontends/php/include/escalations.inc.php
index 32c70e96..7f0576b8 100644
--- a/frontends/php/include/escalations.inc.php
+++ b/frontends/php/include/escalations.inc.php
@@ -101,4 +101,25 @@
return $result;
}
+
+ # Add escalation rule definition
+
+ function add_escalation_rule($escalationid,$level,$period,$delay,$actiontype)
+ {
+ if(!check_right("Configuration of Zabbix","U",0))
+ {
+ error("Insufficient permissions");
+ return 0;
+ }
+
+ $sql="insert into escalation_rules (escalationid,level,period,delay,actiontype) values ($escalationid,$level,'$period',$delay,$actiontype)";
+ $result=DBexecute($sql);
+ if(!$result)
+ {
+ return $result;
+ }
+ $escalationruleid=DBinsert_id($result,"escalation_rules","escalationruleid");
+
+ return $result;
+ }
?>
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index f25fd897..80a3253a 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -1110,4 +1110,76 @@
show_table2_header_end();
}
+
+ # Insert escalation rule form
+ function insert_escalation_rule_form($escalationid,$escalationruleid)
+ {
+ if(isset($escalationruleid))
+ {
+ $result=DBselect("select * from escalation_rules where escalationruleid=$escalationruleid");
+
+ $row=DBfetch($result);
+
+ $level=$row["level"];
+ $period=$row["period"];
+ $delay=$row["delay"];
+ $actiontype=$row["actiontype"];
+ }
+ else
+ {
+ $level=1;
+ $period="1-7,00:00-23:59";
+ $delay=0;
+ $actiontype=0;
+ }
+
+ $col=0;
+
+ show_form_begin("escalationrule");
+ echo S_ESCALATION_RULE;
+
+ 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>";
+ echo "<input class=\"biginput\" name=\"escalationid\" type=\"hidden\" value=\"$escalationid\" size=8>";
+ if(isset($escalationruleid))
+ {
+ echo "<input class=\"biginput\" name=\"escalationruleid\" type=\"hidden\" value=\"$escalationruleid\" size=8>";
+ }
+
+ echo S_LEVEL;
+ show_table2_h_delimiter();
+ echo "<input class=\"biginput\" name=\"level\" size=2 value=\"$level\">";
+
+ show_table2_v_delimiter($col++);
+ echo S_PERIOD;
+ show_table2_h_delimiter();
+ echo "<input class=\"biginput\" name=\"period\" size=32 value=\"$period\">";
+
+ show_table2_v_delimiter($col++);
+ echo S_DELAY;
+ show_table2_h_delimiter();
+ echo "<input class=\"biginput\" name=\"delay\" size=32 value=\"$delay\">";
+
+ show_table2_v_delimiter($col++);
+ echo S_ACTION;
+ show_table2_h_delimiter();
+ echo "<SELECT class=\"biginput\" NAME=\"actiontype\" size=\"1\">";
+ echo "<OPTION VALUE=\"0\" "; if($actiontype==0) echo "SELECTED"; echo ">Do nothing";
+ echo "<OPTION VALUE=\"1\" "; if($actiontype==1) echo "SELECTED"; echo ">Execute actions";
+ echo "<OPTION VALUE=\"2\" "; if($actiontype==2) echo "SELECTED"; echo ">Increase severity";
+ echo "<OPTION VALUE=\"3\" "; if($actiontype==3) echo "SELECTED"; echo ">Increase administrative hierarcy";
+ echo "</SELECT>";
+
+
+ show_table2_v_delimiter2($col++);
+ echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add rule\">";
+ if(isset($escalationid))
+ {
+ echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"update rule\">";
+ echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"delete rule\" onClick=\"return Confirm('Delete selected escalation rule?');\">";
+ }
+
+ show_table2_header_end();
+ }
?>
diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php
index d36fc027..1b100c33 100644
--- a/frontends/php/include/local_en.inc.php
+++ b/frontends/php/include/local_en.inc.php
@@ -171,6 +171,8 @@
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_RULE_ADDED", "Escalation rule added");
+ define("S_ESCALATION_RULE_WAS_NOT_ADDED", "Escalation rule was not added");
define("S_ESCALATION_UPDATED", "Escalation updated");
define("S_ESCALATION_WAS_NOT_UPDATED", "Escalation was not updated");
define("S_ESCALATION_DELETED", "Escalation deleted");
diff --git a/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/mysql/patch.sql b/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/mysql/patch.sql
index b80bc610..8fa46e2e 100644
--- a/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/mysql/patch.sql
+++ b/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/mysql/patch.sql
@@ -20,11 +20,12 @@ CREATE TABLE escalations (
--
CREATE TABLE escalation_rules (
- ruleid int(4) NOT NULL auto_increment,
+ escalationruleid int(4) NOT NULL auto_increment,
escalationid int(4) DEFAULT '0' NOT NULL,
- period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
level int(4) DEFAULT '0' NOT NULL,
+ period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
+ delay int(4) DEFAULT '0' NOT NULL,
actiontype int(4) DEFAULT '0' NOT NULL,
- PRIMARY KEY (ruleid),
+ PRIMARY KEY (escalationruleid),
KEY (escalationid)
) type=InnoDB;
diff --git a/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/postgresql/patch.sql b/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/postgresql/patch.sql
index 55285d04..e9a36cb8 100644
--- a/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/postgresql/patch.sql
+++ b/upgrades/dbpatches/1.1alpha10_to_1.1alpha11/postgresql/patch.sql
@@ -21,11 +21,12 @@ CREATE UNIQUE INDEX escalations_name on escalations (name);
--
CREATE TABLE escalation_rules (
- ruleid serial,
+ escalationruleid serial,
escalationid int4 DEFAULT '0' NOT NULL,
- period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
level int4 DEFAULT '0' NOT NULL,
+ period varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
+ delay int4 DEFAULT '0' NOT NULL,
actiontype int4 DEFAULT '0' NOT NULL,
- PRIMARY KEY (ruleid),
+ PRIMARY KEY (escalationruleid),
FOREIGN KEY (escalationid) REFERENCES escalations
);