diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-03-17 09:28:38 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-03-17 09:28:38 +0000 |
| commit | f91de3b73c3ac3381a2a6d4013e344348608fe2e (patch) | |
| tree | ceb30d66d25f860f3453fea4e46b35365a5e869b /frontends/php/include | |
| parent | 3c3213bb40ae0e2d9334287837458f0fcd2ee863 (diff) | |
| download | zabbix-f91de3b73c3ac3381a2a6d4013e344348608fe2e.tar.gz zabbix-f91de3b73c3ac3381a2a6d4013e344348608fe2e.tar.xz zabbix-f91de3b73c3ac3381a2a6d4013e344348608fe2e.zip | |
- hard-linked templates works when adding an action (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@1704 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/actions.inc.php | 44 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 2 |
2 files changed, 43 insertions, 3 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index 17f332c8..85849ab8 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -51,7 +51,8 @@ if($scope==2) { $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values (0,$id,$good,$delay,0,'*Automatically generated*','*Automatically generated*',$scope,$severity,$recipient)"; - return DBexecute($sql); + $result=DBexecute($sql); + return DBinsert_id($result,"actions","actionid"); } elseif($scope==1) { @@ -69,7 +70,8 @@ else { $sql="insert into actions (triggerid,userid,good,delay,nextcheck,subject,message,scope,severity,recipient) values ($triggerid,$id,$good,$delay,0,'$subject','$message',$scope,$severity,$recipient)"; - return DBexecute($sql); + $result=DBexecute($sql); + return DBinsert_id($result,"actions","actionid"); } } @@ -98,4 +100,42 @@ return delete_alert_by_actionid($actionid); } + + # Add action to hardlinked hosts + + function add_action_to_templates($actionid) + { + if($actionid<=0) + { + return; + } + + $action=get_action_by_actionid($actionid); + $trigger=get_trigger_by_triggerid($action["triggerid"]); + + $sql="select distinct h.hostid from hosts h,functions f, items i where i.itemid=f.itemid and h.hostid=i.hostid and f.triggerid=".$action["triggerid"]; + $result=DBselect($sql); + if(DBnum_rows($result)!=1) + { + return; + } + + $row=DBfetch($result); + + $hostid=$row["hostid"]; + + $sql="select hostid,templateid,actions from hosts_templates where templateid=$hostid"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + if($row["actions"]&1 == 0) continue; + + $sql="select distinct f.triggerid from functions f,items i,triggers t where t.description='".addslashes($trigger["description"])."' and t.triggerid=f.triggerid and i.itemid=f.itemid and i.hostid=".$row["hostid"]; + $result2=DBselect($sql); + while($row2=DBfetch($result2)) + { + add_action($row2["triggerid"], $action["userid"], $action["good"], $action["delay"], $action["subject"], $action["message"], $action["scope"], $action["severity"], $action["recipient"], $action["userid"]); + } + } + } ?> diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index e2314b67..3b2884dc 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -423,7 +423,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $hostid=$row["hostid"]; - $sql="select hostid,templateid,items from hosts_templates where templateid=$hostid"; + $sql="select hostid,templateid,triggers from hosts_templates where templateid=$hostid"; $result=DBselect($sql); while($row=DBfetch($result)) { |
