diff options
author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-02 10:54:58 +0000 |
---|---|---|
committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-05-02 10:54:58 +0000 |
commit | 296a14631b8eac246ea609433e5d08c590e834a1 (patch) | |
tree | ea1fa134f1bd940214a689e8a1c627e0f15cdd57 /frontends/php/include/import.inc.php | |
parent | 83934fff62629f5942accbb249b0e8c2ebae7e70 (diff) | |
download | zabbix-296a14631b8eac246ea609433e5d08c590e834a1.tar.gz zabbix-296a14631b8eac246ea609433e5d08c590e834a1.tar.xz zabbix-296a14631b8eac246ea609433e5d08c590e834a1.zip |
- added exporting of applications and valuemap linkage (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@4079 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/import.inc.php')
-rw-r--r-- | frontends/php/include/import.inc.php | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php index 2ee2eb41..38e53ac5 100644 --- a/frontends/php/include/import.inc.php +++ b/frontends/php/include/import.inc.php @@ -137,13 +137,17 @@ array_push($this->main_node, $name); break; // case case XML_TAG_HOSTS: + case XML_TAG_GROUPS: case XML_TAG_ZABBIX_EXPORT: + case XML_TAG_APPLICATIONS: case XML_TAG_ITEMS: case XML_TAG_TRIGGERS: case XML_TAG_GRAPHS: /* case XML_TAG_SCREENS:*/ $this->sub_node = null; break; // case + case XML_TAG_GROUP: + case XML_TAG_APPLICATION: default: $this->sub_node = $name; break; // case @@ -202,6 +206,28 @@ array_push($this->data[XML_TAG_HOST]['groups'], $group["groupid"]); break; // case + case XML_TAG_APPLICATION: + if(!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) + break; //case + + if(!isset($this->data[XML_TAG_ITEM])) + break; //case + + if(!($application = DBfetch(DBselect('select applicationid from applications'. + ' where '.DBid2nodeid('applicationid').'='.$ZBX_CURNODEID. + ' and name='.zbx_dbstr($this->element_data). + ' and hostid='.$this->data[XML_TAG_HOST]['hostid'])))) + { + $applicationid = add_application($this->element_data, $this->data[XML_TAG_HOST]['hostid']); + } + else + { + $applicationid = $application['applicationid']; + } + + $this->data[XML_TAG_ITEM]['applications'][] = $applicationid; + + break; // case case XML_TAG_ITEM: if(!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { @@ -235,6 +261,22 @@ if(!isset($data['snmpv3_securitylevel'])) $data['snmpv3_securitylevel'] = 0; if(!isset($data['snmpv3_authpassphrase'])) $data['snmpv3_authpassphrase'] = ''; if(!isset($data['snmpv3_privpassphrase'])) $data['snmpv3_privpassphrase'] = ''; + if(!isset($data['valuemap'])) $data['valuemap'] = ''; + if(!isset($data['applications'])) $data['applications'] = array(); + + if(!empty($data['valuemap'])) + { + if( $valuemap = DBfetch(DBselect('select valuemapid from valuemaps '. + ' where '.DBid2nodeid('valuemapid').'='.$ZBX_CURNODEID. + ' and name='.zbx_dbstr($data['valuemap']))) ) + { + $data['valuemapid'] = $valuemap['valuemapid']; + } + else + { + $data['valuemapid'] = add_valuemap($data['valuemap'],array()); + } + } if($item = DBfetch(DBselect('select itemid,valuemapid,templateid from items'. ' where key_='.zbx_dbstr($data['key']). @@ -247,6 +289,9 @@ break; } + if( !isset($data['valuemapid']) ) + $data['valuemapid'] = $item['valuemapid']; + update_item( $item['itemid'], $data['description'], @@ -271,9 +316,12 @@ $data['formula'], $data['trends'], $data['logtimefmt'], - $item['valuemapid'], + $data['valuemapid'], $data['delay_flex'], - get_applications_by_itemid($item['itemid']), + array_unique(array_merge( + $data['applications'], + get_applications_by_itemid($item['itemid']) + )), $item['templateid']); } else @@ -284,6 +332,9 @@ break; // case } + if( !isset($data['valuemapid']) ) + $data['valuemapid'] = 0; + add_item( $data['description'], $data['key'], @@ -307,9 +358,9 @@ $data['formula'], $data['trends'], $data['logtimefmt'], - 0, + $data['valuemapid'], $data['delay_flex'], - array()); + $data['applications']); } break; // case |