From 823d0bd76e9c1ef1d45710bca152d44cfd6ce611 Mon Sep 17 00:00:00 2001 From: hugetoad Date: Mon, 26 Dec 2005 13:48:13 +0000 Subject: Better configuration of actions. Not finished... git-svn-id: svn://svn.zabbix.com/trunk@2427 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/forms.inc.php | 337 ++++++++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+) (limited to 'frontends/php/include/forms.inc.php') diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 5b0dc705..2a1e85db 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -1490,4 +1490,341 @@ show_table2_header_end(); } + + function insert_action_form() + { + global $_REQUEST; + + if(isset($_REQUEST["actionid"])) + { + $action=get_action_by_actionid($_REQUEST["actionid"]); + + $actionid=$action["actionid"]; + $triggerid=$action["triggerid"]; + $source=$action["source"]; + $filter_trigger_name=$action["filter_trigger_name"]; + $good=$action["good"]; + $delay=$action["delay"]; + // Otherwise symbols like ",' will not be shown + $subject=htmlspecialchars($action["subject"]); + $message=$action["message"]; + $uid=$action["userid"]; + $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],$action["scope"]); + $severity=$action["severity"]; + $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],$action["recipient"]); + $maxrepeats=$action["maxrepeats"]; + $repeatdelay=$action["repeatdelay"]; + if(isset($_REQUEST["repeat"])) + { + $repeat=$_REQUEST["repeat"]; + } + else if($maxrepeats==0) + { + $repeat=0; + } + else + { + $repeat=1; + } + } + else + { + $source=0; + $filter_trigger_name=""; + $trigger=get_trigger_by_triggerid($_REQUEST["triggerid"]); + $description=htmlspecialchars(stripslashes($trigger["description"])); + + // $delay=30; + $delay=@iif(isset($_REQUEST["delay"]),$_REQUEST["delay"],30); +// $subject=$description; + $subject=@iif(isset($_REQUEST["subject"]),$_REQUEST["subject"],$description); + $scope=@iif(isset($_REQUEST["scope"]),$_REQUEST["scope"],0); + $good=@iif(isset($_REQUEST["good"]),$_REQUEST["good"],1); + $recipient=@iif(isset($_REQUEST["recipient"]),$_REQUEST["recipient"],RECIPIENT_TYPE_GROUP); +// $severity=0; + $severity=@iif(isset($_REQUEST["severity"]),$_REQUEST["severity"],0); + $maxrepeats=@iif(isset($_REQUEST["maxrepeats"]),$_REQUEST["maxrepeats"],0); + $repeatdelay=@iif(isset($_REQUEST["repeatdelay"]),$_REQUEST["repeatdelay"],600); + $repeat=@iif(isset($_REQUEST["repeat"]),$_REQUEST["repeat"],0); + + $sql="select i.description, h.host, i.key_ from hosts h, items i,functions f where f.triggerid=".$_REQUEST["triggerid"]." and h.hostid=i.hostid and f.itemid=i.itemid order by i.description"; + $result=DBselect($sql); + if(isset($_REQUEST["message"])) + { + $message=$_REQUEST["message"]; + } + else + { + $message="INSERT YOUR MESSAGE HERE\n\n------Latest data------\n\n"; + while($row=DBfetch($result)) + { + $message=$message.$row["description"].": {".$row["host"].":".$row["key_"].".last(0)} (latest value)\n"; + $message=$message.$row["description"].": {".$row["host"].":".$row["key_"].".max(300)} (maximum value for last 5 min)\n"; + $message=$message.$row["description"].": {".$row["host"].":".$row["key_"].".min(300)} (minimum value for last 5 min)\n\n"; + } + $message=$message."---------End--------\n"; + } + } + + + show_form_begin("actions.action"); + echo nbsp(S_NEW_ACTION); + $col=0; + + show_table2_v_delimiter($col++); + echo "
"; + if(isset($_REQUEST["actionid"])) + { + echo ""; + } + echo nbsp(S_SOURCE); + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo nbsp(S_FILTER_HOST_GROUP); + show_table2_h_delimiter(); + $h2=""; + + show_table2_v_delimiter($col++); + echo nbsp(S_FILTER_HOST); + show_table2_h_delimiter(); + $h2=""; + + show_table2_v_delimiter($col++); + echo S_FILTER_TRIGGER; + show_table2_h_delimiter(); + $h2=" "; + + $h2=$h2." "; + echo $h2; + + if(isset($_REQUEST["hostid"])) + { + show_table2_v_delimiter($col++); + echo " "; + show_table2_h_delimiter(); + $result=DBselect("select t.triggerid,t.description from triggers t,functions f, hosts h, items i where h.hostid=i.hostid and f.itemid=i.itemid and t.triggerid=f.triggerid and h.hostid=".$_REQUEST["hostid"]." order by t.description"); + echo ""; + } + + show_table2_v_delimiter($col++); + echo S_FILTER_TRIGGER_NAME; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo nbsp(S_WHEN_TRIGGER_BECOMES); + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo nbsp(S_SEND_MESSAGE_TO); + show_table2_h_delimiter(); + echo ""; + + if($recipient==RECIPIENT_TYPE_GROUP) + { + show_table2_v_delimiter($col++); + echo nbsp(S_GROUP); + show_table2_h_delimiter(); + echo ""; + } + else + { + show_table2_v_delimiter($col++); + echo nbsp(S_USER); + show_table2_h_delimiter(); + echo ""; + } + + + show_table2_v_delimiter($col++); + echo nbsp(S_DELAY_BETWEEN_MESSAGES_IN_SEC); + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_SUBJECT; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_MESSAGE; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_SCOPE; + show_table2_h_delimiter(); + echo ""; + + if($scope>0) + { + show_table2_v_delimiter($col++); + echo nbsp(S_USE_IF_TRIGGER_SEVERITY); + show_table2_h_delimiter(); + echo ""; + } + else + { + echo ""; + } + + show_table2_v_delimiter($col++); + echo nbsp(S_REPEAT); + show_table2_h_delimiter(); + echo ""; + + if($repeat>0) + { + show_table2_v_delimiter($col++); + echo S_NUMBER_OF_REPEATS; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_DELAY_BETWEEN_REPEATS; + show_table2_h_delimiter(); + echo ""; + } + + show_table2_v_delimiter2(); + echo ""; + if(isset($actionid)) + { + echo ""; + echo ""; + } + + show_table2_header_end(); + } ?> -- cgit