in 1.1alpha10, the linkages between templates and hosts were broken (ie: updating the items/triggers/actions of a template did not update the linked hosts). does anyone know if this was fixed in alpha 12?
Ad Widget
Collapse
are host/template linkages still broken?
Collapse
X
-
Tags: None
-
nevermind, i did my own testing. for future reference, here are my results on alpha12:
items
--
add: working
edit: working
delete: working
triggers
--
add: working
edit: broken
delete: broken
actions
--
add: broken
edit: broken
delete: broken -
Greetings,
Are templated trigger adds really working correctly for you? I ask because I am still having this problem
As for getting the actions to work correctly, I am still applying Karkinjub Marakint's patch which seems to work very very well.
Started trying to read through the UI to fix the triggers, but haven't found the root cause yet.
Comment
-
Sorry for these issues. Indeed, even 1.1alpha12 doesn't provide all functions required for successful management of host/templates linkage.
Hopefully it will be fixed in a next release.Comment
-
sorry, i never checked for the problem you're having. i was actually only checking to see if anything was added. chances are im having the same problem.Comment
-
Add trigger to templates fixed for alpha11
I was able to fix the add trigger to templates issue in Alpha 11. I can now add a trigger such as:
({server:ssh.last(0)}=0)&({server:ssh.prev(0)}=0)
I have verified that it works with at least 60 hosts attached to the template and changes the name "server" in both expressions to the correct hostname.Comment
-
Excellent, can you post a patch / diff file please.Originally posted by linuxdrI was able to fix the add trigger to templates issue in Alpha 11. I can now add a trigger such as:
({server:ssh.last(0)}=0)&({server:ssh.prev(0)}=0)
I have verified that it works with at least 60 hosts attached to the template and changes the name "server" in both expressions to the correct hostname.Comment
-
Current code
I will try and put together a patch but here is the current code that I have for the function:
Code:# Add item to hardlinked hosts function add_trigger_to_templates($triggerid) { if($triggerid<=0) { return; } $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); if(DBnum_rows($result)!=1) { return; } $row=DBfetch($result); $hostid=$row["hostid"]; $sql="select hostid,templateid,items from hosts_templates where templateid=$hostid"; $result=DBselect($sql); while($row=DBfetch($result)) { 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,'".$trigger["expression"]."')"; $result4=DBexecute($sql); $triggerid_new=DBinsert_id($result4,"triggers","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); $time_temp=1; while($row2=DBfetch($result2)) { $sql="select itemid from items where key_=\"".$row2["key_"]."\" and hostid=".$row["hostid"]; $result3=DBselect($sql); if(DBnum_rows($result3)!=1) { $sql="delete from triggers where triggerid=$triggerid_new"; DBexecute($sql); $sql="delete from functions where triggerid=$triggerid_new"; DBexecute($sql); break; } $row3=DBfetch($result3); $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"); $sql="update triggers set expression='".$trigger["expression"]."' where triggerid=$triggerid_new"; DBexecute($sql); if( $time_temp == 1 ) $expression=str_replace("{".$row2["functionid"]."}","{".$functionid."}",$trigger["expression"]); else $expression=str_replace("{".$row2["functionid"]."}","{".$functionid."}",$expression); //$expression_old=$expression; $sql="update triggers set expression='$expression' where triggerid=$triggerid_new"; DBexecute($sql); $host=get_host_by_hostid($row["hostid"]); info("Added trigger to linked host ".$host["host"]); $time_temp++; } } }Comment
-
you might also wait until the next release (which alexei said might be released sometime this week) for an official fix.Last edited by mconigliaro; 18-08-2005, 20:40.Comment
-
Comment
Comment