Ad Widget

Collapse

PATCH: Also use expression as a key when importing triggers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kassec
    Junior Member
    • Dec 2007
    • 13

    #1

    PATCH: Also use expression as a key when importing triggers

    Relates to http://zabbix.com/forum/showthread.php?t=9305.

    This patch (against 1.4.5) allows to import several triggers with the same description and different expressions.

    Code:
    --- include/import.inc.php	(rev 1.4.5)
    +++ include/import.inc.php	2008-04-02 02:32:08.000000000 +0200
    @@ -388,11 +388,22 @@
     									$this->data[XML_TAG_HOST]['name'],
     									$data['expression']);
     
    -						if($trigger = DBfetch(DBselect('select distinct t.triggerid,t.templateid '.
    +						$result = DBselect('select distinct t.triggerid,t.templateid,t.expression '.
     							' from triggers t,functions f,items i '.
     							' where t.triggerid=f.triggerid and f.itemid=i.itemid'.
     							' and i.hostid='.$this->data[XML_TAG_HOST]['hostid'].
    -							' and t.description='.zbx_dbstr($data['description']))))
    +							' and t.description='.zbx_dbstr($data['description']));
    +
    +						while($trigger = DBfetch($result))
    +						{
    +							if(explode_exp($trigger['expression'],0) == $data['expression'])
    +							{
    +								break;
    +							}
    +							
    +						}
    +
    +						if(!empty($trigger))
     						{ /* exist */
     							if($this->trigger['exist']==1) /* skip */
     							{
    Last edited by kassec; 02-04-2008, 03:29.
  • Aly
    ZABBIX developer
    • May 2007
    • 1126

    #2
    Thank you. Applied.
    Zabbix | ex GUI developer

    Comment

    Working...