summaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/php/actionconf.php23
-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
5 files changed, 110 insertions, 35 deletions
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index 06e4737d..bb73301b 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -47,7 +47,7 @@
$_REQUEST["repeatdelay"]=600;
}
- $actionid=add_action($_REQUEST["userid"], $_REQUEST["good"], $_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["usrgrpid"],$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]);
+ $actionid=add_action($_REQUEST["userid"], $_REQUEST["delay"], $_REQUEST["subject"], $_REQUEST["message"],$_REQUEST["recipient"],$_REQUEST["usrgrpid"],$_REQUEST["maxrepeats"],$_REQUEST["repeatdelay"]);
// add_action_to_linked_hosts($actionid);
for($i=1;$i<=1000;$i++)
{
@@ -99,7 +99,7 @@
}
if($_REQUEST["register"]=="delete")
{
- delete_action_from_templates($_REQUEST["actionid"]);
+// delete_action_from_templates($_REQUEST["actionid"]);
$result=delete_action($_REQUEST["actionid"]);
show_messages($result,S_ACTION_DELETED,S_CANNOT_DELETE_ACTION);
if($result)
@@ -176,7 +176,7 @@
$result=DBselect($sql);
table_begin();
- table_header(array(S_SOURCE,S_SEND_MESSAGE_TO,S_WHEN_TRIGGER,S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS));
+ table_header(array(S_SOURCE,S_SEND_MESSAGE_TO,S_DELAY,S_SUBJECT,S_REPEATS,S_ACTIONS));
$col=0;
while($row=DBfetch($result))
{
@@ -192,22 +192,6 @@
$recipient=$groupd["name"];
}
- if($row["good"] == 1)
- {
-# echo "<TD><FONT COLOR=\"#AA0000\">".S_ON."</FONT></TD>";
- $good=array("value"=>S_ON,"class"=>"on");
- }
- else if($row["good"] == 0)
- {
-# echo "<TD><FONT COLOR=\"#00AA00\">".S_OFF."</FONT></TD>";
- $good=array("value"=>S_OFF,"class"=>"off");
- }
- else if($row["good"] == 2)
- {
-# echo "<TD><FONT COLOR=\"#AA0000\">".S_ON."</FONT>/<FONT COLOR=\"#00AA00\">OFF</FONT></TD>";
- $good=array("value"=>S_ON."/".S_OFF,"class"=>"on");
- }
-
if($row["maxrepeats"] == 0)
{
$maxrepeats=S_NO_REPEATS;
@@ -222,7 +206,6 @@
table_row(array(
get_source_description($row["source"]),
$recipient,
- $good,
htmlspecialchars($row["delay"]),
htmlspecialchars($row["subject"]),
$maxrepeats,
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;
+ }
?>