From 461bb2a4ff683a38e6b2066f8c3fec67e110e44a Mon Sep 17 00:00:00 2001 From: hugetoad Date: Tue, 27 Dec 2005 17:59:42 +0000 Subject: More changes for new configuration of actions. git-svn-id: svn://svn.zabbix.com/trunk@2433 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/actions.inc.php | 42 +++++++++++++++++++++-- frontends/php/include/defines.inc.php | 4 +++ frontends/php/include/forms.inc.php | 63 +++++++++++++++++++++++++++------- frontends/php/include/triggers.inc.php | 13 +++++++ 4 files changed, 107 insertions(+), 15 deletions(-) (limited to 'frontends/php/include') 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=""; // echo $h2; $h2=$h2.""; // echo $h2; @@ -1641,6 +1658,28 @@ { $h2=$h2.""; } + else if($conditiontype == CONDITION_TYPE_TRIGGER_VALUE) + { + $h2=$h2.""; + } + else if($conditiontype == CONDITION_TYPE_TIME_PERIOD) + { + $h2=$h2.""; + } + else if($conditiontype == CONDITION_TYPE_TRIGGER_SEVERITY) + { + $h2=$h2.""; + } 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; + } ?> -- cgit