diff options
author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-02 08:34:41 +0000 |
---|---|---|
committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-02 08:34:41 +0000 |
commit | 82e68eabae069748d6691cab742f5fde436a56cb (patch) | |
tree | 17d7ca73441a35f93acd529c47caaf7387973382 | |
parent | 83b5e44b019bfa89d96c3e14a903497eb93bcde7 (diff) | |
download | zabbix-82e68eabae069748d6691cab742f5fde436a56cb.tar.gz zabbix-82e68eabae069748d6691cab742f5fde436a56cb.tar.xz zabbix-82e68eabae069748d6691cab742f5fde436a56cb.zip |
- added possibility to add triggers with same description but different expression
- fixes in export (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5575 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r-- | frontends/php/include/export.inc.php | 31 | ||||
-rw-r--r-- | frontends/php/include/import.inc.php | 23 |
2 files changed, 31 insertions, 23 deletions
diff --git a/frontends/php/include/export.inc.php b/frontends/php/include/export.inc.php index a86f4a5b..84b0c52d 100644 --- a/frontends/php/include/export.inc.php +++ b/frontends/php/include/export.inc.php @@ -325,22 +325,23 @@ // based on mod by scricca $data = DBfetch(DBselect('SELECT hp.* FROM hosts_profiles hp WHERE hp.hostid='.$hostid)); - if(!$data) return false; - - zbx_xmlwriter_start_element ($memory,XML_TAG_HOSTPROFILE); - - $map =& $ZBX_EXPORT_MAP[XML_TAG_HOSTPROFILE]; - - foreach($map['attribures'] as $db_name => $xml_name){ - if(empty($xml_name)) $xml_name = $db_name; - zbx_xmlwriter_write_attribute($memory, $xml_name, $data[$db_name]); - } - foreach($map['elements'] as $db_name => $xml_name){ - if(empty($data[$db_name])) continue; - if(empty($xml_name)) $xml_name = $db_name; - zbx_xmlwriter_write_element($memory, $xml_name, $data[$db_name]); +// if(!$data) return false; + if($data){ + zbx_xmlwriter_start_element ($memory,XML_TAG_HOSTPROFILE); + + $map =& $ZBX_EXPORT_MAP[XML_TAG_HOSTPROFILE]; + + foreach($map['attribures'] as $db_name => $xml_name){ + if(empty($xml_name)) $xml_name = $db_name; + zbx_xmlwriter_write_attribute($memory, $xml_name, $data[$db_name]); + } + foreach($map['elements'] as $db_name => $xml_name){ + if(empty($data[$db_name])) continue; + if(empty($xml_name)) $xml_name = $db_name; + zbx_xmlwriter_write_element($memory, $xml_name, $data[$db_name]); + } + zbx_xmlwriter_end_element($memory); // XML_TAG_HOSTPROFILE } - zbx_xmlwriter_end_element($memory); //-- if($db_groups = DBselect('select g.name from groups g, hosts_groups hg'. diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php index b36bcc46..242f4871 100644 --- a/frontends/php/include/import.inc.php +++ b/frontends/php/include/import.inc.php @@ -461,15 +461,22 @@ $data['expression'] = str_replace('{HOSTNAME}', $this->data[XML_TAG_HOST]['name'], $data['expression']); + + $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'])); + + while($trigger = DBfetch($result)){ + if(explode_exp($trigger['expression'],0) == $data['expression']){ + break; // while + } + } - if($trigger = DBfetch(DBselect('select distinct t.triggerid,t.templateid '. - ' 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'])))) - { /* exist */ - if($this->trigger['exist']==1) /* skip */ - { + if(!empty($trigger)){ /* exist */ + if($this->trigger['exist']==1){ /* skip */ info('Trigger ['.$data['description'].'] skipped - user rule'); break; // case } |