PDA

View Full Version : are host/template linkages still broken?


mconigliaro
12-08-2005, 20:10
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?

mconigliaro
12-08-2005, 20:27
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

James Wells
12-08-2005, 22:38
Greetings,

Are templated trigger adds really working correctly for you? I ask because I am still having this problem (http://www.zabbix.com/forum/showthread.php?t=1181)

As for getting the actions to work correctly, I am still applying Karkinjub Marakint's patch (http://www.zabbix.com/forum/showthread.php?t=1030&highlight=actions) 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. :(

Alexei
13-08-2005, 20:40
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.

mconigliaro
15-08-2005, 15:30
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.

linuxdr
16-08-2005, 19:17
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.

James Wells
16-08-2005, 20:11
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.
Excellent, can you post a patch / diff file please.

linuxdr
18-08-2005, 15:51
I will try and put together a patch but here is the current code that I have for the function:

# 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,ex pression) 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++;
}
}
}

mconigliaro
18-08-2005, 16:40
you might also wait until the next release (which alexei said might be released sometime this week) for an official fix.

mconigliaro
18-08-2005, 20:30
hey james, i just confirmed that im having the same problem with templated trigger adds...