diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 08:15:19 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-08-29 08:15:19 +0000 |
| commit | 2ce640571ab5c0db1a26858f96ba804e36f1fb37 (patch) | |
| tree | 127d1eb470fcf23af2ec7395d877052fb13fe5f1 /frontends/php/include | |
| parent | a97ce3766daf613ce516b6899584c5b4614e7f19 (diff) | |
| download | zabbix-2ce640571ab5c0db1a26858f96ba804e36f1fb37.tar.gz zabbix-2ce640571ab5c0db1a26858f96ba804e36f1fb37.tar.xz zabbix-2ce640571ab5c0db1a26858f96ba804e36f1fb37.zip | |
- fixed addition of triggers to linked hosts (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@2008 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/items.inc.php | 3 | ||||
| -rw-r--r-- | frontends/php/include/triggers.inc.php | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index e44c66e1..b58a4685 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -116,7 +116,8 @@ $result=DBexecute($sql); if($result) { - info("Added new item $key"); + $host=get_host_by_hostid($hostid); + info("Added new item ".$host["host"].":$key"); } return DBinsert_id($result,"items","itemid"); } diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 08cff671..59ea982d 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -337,7 +337,6 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } $trigger=get_trigger_by_triggerid($triggerid); - $expression_old=$trigger["expression"]; $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=$triggerid"; $result=DBselect($sql); @@ -350,10 +349,13 @@ 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); + // Loop: linked hosts while($row=DBfetch($result)) { + $expression_old=$trigger["expression"]; + if($row["triggers"]&1 == 0) continue; $sql="insert into triggers (description,priority,status,comments,url,value,expression) values ('".addslashes($trigger["description"])."',".$trigger["priority"].",".$trigger["status"].",'".addslashes($trigger["comments"])."','".addslashes($trigger["url"])."',2,'$expression_old')"; @@ -363,6 +365,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $sql="select i.key_,f.parameter,f.function,f.functionid from functions f,items i where i.itemid=f.itemid and f.triggerid=$triggerid"; $result2=DBselect($sql); + // Loop: functions while($row2=DBfetch($result2)) { $sql="select itemid from items where key_=\"".$row2["key_"]."\" and hostid=".$row["hostid"]; @@ -380,8 +383,8 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; $item=get_item_by_itemid($row3["itemid"]); $sql="insert into functions (itemid,triggerid,function,parameter) values (".$item["itemid"].",$triggerid_new,'".$row2["function"]."','".$row2["parameter"]."')"; - $result4=DBexecute($sql); - $functionid=DBinsert_id($result4,"functions","functionid"); + $result5=DBexecute($sql); + $functionid=DBinsert_id($result5,"functions","functionid"); $sql="update triggers set expression='$expression_old' where triggerid=$triggerid_new"; DBexecute($sql); |
