summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-12-27 17:59:42 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-12-27 17:59:42 +0000
commit461bb2a4ff683a38e6b2066f8c3fec67e110e44a (patch)
tree330e16964a243f7c6f83a02af17c4c1b17441310 /frontends/php/include
parent324c7b6e8806397d52c637f352097158e8e0c7a4 (diff)
downloadzabbix-461bb2a4ff683a38e6b2066f8c3fec67e110e44a.tar.gz
zabbix-461bb2a4ff683a38e6b2066f8c3fec67e110e44a.tar.xz
zabbix-461bb2a4ff683a38e6b2066f8c3fec67e110e44a.zip
More changes for new configuration of actions.
git-svn-id: svn://svn.zabbix.com/trunk@2433 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/actions.inc.php42
-rw-r--r--frontends/php/include/defines.inc.php4
-rw-r--r--frontends/php/include/forms.inc.php63
-rw-r--r--frontends/php/include/triggers.inc.php13
4 files changed, 107 insertions, 15 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index 7b6b4370..3364467f 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -62,7 +62,7 @@
# Add Action
- function add_action( $userid, $good, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay)
+ function add_action( $userid, $delay, $subject, $message, $recipient, $usrgrpid, $maxrepeats, $repeatdelay)
{
// if(!check_right_on_trigger("A",$triggerid))
// {
@@ -79,7 +79,7 @@
$id = $usrgrpid;
}
- $sql="insert into actions (userid,good,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$good,$delay,0,'$subject','$message',$recipient,$maxrepeats,$repeatdelay)";
+ $sql="insert into actions (userid,delay,nextcheck,subject,message,recipient,maxrepeats,repeatdelay) values ($id,$delay,0,'$subject','$message',$recipient,$maxrepeats,$repeatdelay)";
$result=DBexecute($sql);
return DBinsert_id($result,"actions","actionid");
}
@@ -99,14 +99,26 @@
return DBexecute($sql);
}
+ # Delete Conditions associated with actionid
+
+ function delete_conditions_by_actionid($actionid)
+ {
+ $sql="delete from conditions where actionid=$actionid";
+ return DBexecute($sql);
+ }
+
# Delete Action
function delete_action( $actionid )
{
+ delete_conditions_by_actionid($actionid);
+ delete_alert_by_actionid($actionid);
+
$sql="delete from actions where actionid=$actionid";
$result=DBexecute($sql);
- return delete_alert_by_actionid($actionid);
+
+ return $result;
}
# Add action to hardlinked hosts
@@ -275,6 +287,22 @@
{
$op="<>";
}
+ else if($operator == CONDITION_OPERATOR_LIKE)
+ {
+ $op="like";
+ }
+ else if($operator == CONDITION_OPERATOR_NOT_LIKE)
+ {
+ $op="not like";
+ }
+ else if($operator == CONDITION_OPERATOR_IN)
+ {
+ $op="in";
+ }
+ else if($operator == CONDITION_OPERATOR_MORE_EQUAL)
+ {
+ $op=">=";
+ }
$desc=S_UNKNOWN;
if($conditiontype==CONDITION_TYPE_GROUP)
@@ -286,6 +314,14 @@
{
$desc=S_TRIGGER_DESCRIPTION." $op "."\"".$value."\"";
}
+ else if($conditiontype==CONDITION_TYPE_TRIGGER_SEVERITY)
+ {
+ $desc=S_TRIGGER_SEVERITY." $op "."\"".get_severity_description($value)."\"";
+ }
+ else if($conditiontype==CONDITION_TYPE_TIME_PERIOD)
+ {
+ $desc=S_TIME." $op "."\"".$value."\"";
+ }
else
{
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 76fbdc72..ff4d8c2a 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -52,6 +52,10 @@
define("CONDITION_OPERATOR_EQUAL", 0);
define("CONDITION_OPERATOR_NOT_EQUAL", 1);
+ define("CONDITION_OPERATOR_LIKE", 2);
+ define("CONDITION_OPERATOR_NOT_LIKE", 3);
+ define("CONDITION_OPERATOR_IN", 4);
+ define("CONDITION_OPERATOR_MORE_EQUAL", 5);
define("HOST_STATUS_MONITORED", 0);
define("HOST_STATUS_NOT_MONITORED", 1);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index deb740b7..3e046467 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -1508,7 +1508,6 @@
$subject=htmlspecialchars($action["subject"]);
$message=$action["message"];
$uid=$action["userid"];
- $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],$action["scope"]);
$recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]);
$maxrepeats=$action["maxrepeats"];
$repeatdelay=$action["repeatdelay"];
@@ -1524,6 +1523,16 @@
{
$repeat=1;
}
+ $sql="select conditiontype, operator, value from conditions where actionid=".$_REQUEST["actionid"];
+ $result=DBselect($sql);
+ $i=1;
+ while($condition=DBfetch($result))
+ {
+ $_REQUEST["conditiontype$i"]=$condition["conditiontype"];
+ $_REQUEST["conditionop$i"]=$condition["operator"];
+ $_REQUEST["conditionvalue$i"]=$condition["value"];
+ $i++;
+ }
}
else
{
@@ -1604,21 +1613,29 @@
// echo nbsp(" "."Condition");
// show_table2_h_delimiter();
$h2="<select class=\"biginput\" name=\"conditiontype\" onChange=\"submit()\">";
- $h2=$h2.form_select("conditiontype",0,S_HOST_GROUP);
- $h2=$h2.form_select("conditiontype",1,S_HOST);
- $h2=$h2.form_select("conditiontype",2,S_TRIGGER);
- $h2=$h2.form_select("conditiontype",3,S_TRIGGER_NAME);
- $h2=$h2.form_select("conditiontype",4,S_TRIGGER_SEVERITY);
- $h2=$h2.form_select("conditiontype",5,S_TRIGGER_VALUE);
- $h2=$h2.form_select("conditiontype",6,S_TIME_PERIOD);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_GROUP,S_HOST_GROUP);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_HOST,S_HOST);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER,S_TRIGGER);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_NAME,S_TRIGGER_NAME);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_SEVERITY,S_TRIGGER_SEVERITY);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TRIGGER_VALUE,S_TRIGGER_VALUE);
+ $h2=$h2.form_select("conditiontype",CONDITION_TYPE_TIME_PERIOD,S_TIME_PERIOD);
$h2=$h2."</SELECT>";
// echo $h2;
$h2=$h2."<select class=\"biginput\" name=\"operator\">";
- $h2=$h2.form_select("operator",0,"=");
- $h2=$h2.form_select("operator",1,"<>");
- $h2=$h2.form_select("operator",2,"like");
- $h2=$h2.form_select("operator",3,"not like");
+ if(in_array($conditiontype,array(CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST,CONDITION_TYPE_TRIGGER,CONDITION_TYPE_TRIGGER_SEVERITY,CONDITION_TYPE_TRIGGER_VALUE)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_EQUAL,"=");
+ if(in_array($conditiontype,array(CONDITION_TYPE_GROUP, CONDITION_TYPE_HOST,CONDITION_TYPE_TRIGGER,CONDITION_TYPE_TRIGGER_SEVERITY,CONDITION_TYPE_TRIGGER_VALUE)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_NOT_EQUAL,"<>");
+ if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_LIKE,"like");
+ if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_NAME)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_NOT_LIKE,"not like");
+ if(in_array($conditiontype,array(CONDITION_TYPE_TIME_PERIOD)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_IN,"in");
+ if(in_array($conditiontype,array(CONDITION_TYPE_TRIGGER_VALUE)))
+ $h2=$h2.form_select("operator",CONDITION_OPERATOR_MORE_EQUAL,">=");
$h2=$h2."</SELECT>";
// echo $h2;
@@ -1641,6 +1658,28 @@
{
$h2=$h2."<input class=\"biginput\" name=\"value\" value=\"\" size=40>";
}
+ else if($conditiontype == CONDITION_TYPE_TRIGGER_VALUE)
+ {
+ $h2=$h2."<select class=\"biginput\" name=\"value\">";
+ $h2=$h2.form_select("value",0,"ON");
+ $h2=$h2.form_select("value",1,"OFF");
+ $h2=$h2."</SELECT>";
+ }
+ else if($conditiontype == CONDITION_TYPE_TIME_PERIOD)
+ {
+ $h2=$h2."<input class=\"biginput\" name=\"value\" value=\"1-7,00:00-23:59\" size=40>";
+ }
+ else if($conditiontype == CONDITION_TYPE_TRIGGER_SEVERITY)
+ {
+ $h2=$h2."<select class=\"biginput\" name=\"severity\" size=1>";
+ $h2=$h2."<OPTION VALUE=\"0\">".S_NOT_CLASSIFIED;
+ $h2=$h2."<OPTION VALUE=\"1\">".S_INFORMATION;
+ $h2=$h2."<OPTION VALUE=\"2\">".S_WARNING;
+ $h2=$h2."<OPTION VALUE=\"3\">".S_AVERAGE;
+ $h2=$h2."<OPTION VALUE=\"4\">".S_HIGH;
+ $h2=$h2."<OPTION VALUE=\"5\">".S_DISASTER;
+ $h2=$h2."</SELECT>";
+ }
else
{
show_table2_v_delimiter($col++);
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index 6d89fbe5..cbb8f9fc 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -510,4 +510,17 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
}
}
+
+ function get_severity_description($severity)
+ {
+ $desc="Unknown";
+
+ if($severity == 0) $desc = S_NOT_CLASSIFIED;
+ else if($severity == 1) $desc = S_INFORMATION;
+ else if($severity == 2) $desc = S_WARNING;
+ else if($severity == 3) $desc = S_AVERAGE;
+ else if($severity == 4) $desc = S_HIGH;
+
+ return $desc;
+ }
?>