/** * Mass update hosts * * @param _array $hosts multidimensional array with Hosts data * @param array $hosts['hosts'] Array of Host objects to update * @param string $hosts['fields']['host'] Host name. * @param array $hosts['fields']['groupids'] HostGroup IDs add Host to. * @param int $hosts['fields']['port'] Port. OPTIONAL * @param int $hosts['fields']['status'] Host Status. OPTIONAL * @param int $hosts['fields']['useip'] Use IP. OPTIONAL * @param string $hosts['fields']['dns'] DNS. OPTIONAL * @param string $hosts['fields']['ip'] IP. OPTIONAL * @param int $hosts['fields']['proxy_hostid'] Proxy Host ID. OPTIONAL * @param int $hosts['fields']['useipmi'] Use IPMI. OPTIONAL * @param string $hosts['fields']['ipmi_ip'] IPMAI IP. OPTIONAL * @param int $hosts['fields']['ipmi_port'] IPMI port. OPTIONAL * @param int $hosts['fields']['ipmi_authtype'] IPMI authentication type. OPTIONAL * @param int $hosts['fields']['ipmi_privilege'] IPMI privilege. OPTIONAL * @param string $hosts['fields']['ipmi_username'] IPMI username. OPTIONAL * @param string $hosts['fields']['ipmi_password'] IPMI password. OPTIONAL * @return boolean */ public static function massUpdate($data) { $hosts = zbx_toArray($data['hosts']); $hostids = zbx_objectValues($hosts, 'hostid'); try { self::BeginTransaction(__METHOD__); $options = array('hostids' => $hostids, 'editable' => 1, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => 1); $upd_hosts = self::get($options); foreach ($hosts as $hnum => $host) { if (!isset($upd_hosts[$host['hostid']])) { self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION); } } // CHECK IF HOSTS HAVE AT LEAST 1 GROUP {{{ if (isset($data['groups']) && empty($data['groups'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'No groups for hosts'); } // }}} CHECK IF HOSTS HAVE AT LEAST 1 GROUP // UPDATE HOSTS PROPERTIES {{{ if (isset($data['host'])) { if (count($hosts) > 1) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot mass update host name'); } $cur_host = reset($hosts); $options = array('filter' => array('host' => $cur_host['host']), 'output' => API_OUTPUT_SHORTEN, 'editable' => 1, 'nopermissions' => 1); $host_exists = self::get($options); $host_exist = reset($host_exists); if ($host_exist && $host_exist['hostid'] != $cur_host['hostid']) { self::exception(ZBX_API_ERROR_PARAMETERS, S_HOST . ' [ ' . $data['host'] . ' ] ' . S_ALREADY_EXISTS_SMALL); } //can't add host with the same name as existing template if (CTemplate::exists(array('host' => $cur_host['host']))) { self::exception(ZBX_API_ERROR_PARAMETERS, S_TEMPLATE . ' [ ' . $cur_host['host'] . ' ] ' . S_ALREADY_EXISTS_SMALL); } } if (isset($data['host']) && !preg_match('/^' . ZBX_PREG_HOST_FORMAT . '$/i', $data['host'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect characters used for Hostname [ ' . $data['host'] . ' ]'); } if (isset($data['dns']) && !empty($data['dns']) && !preg_match('/^' . ZBX_PREG_DNS_FORMAT . '$/i', $data['dns'])) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Incorrect characters used for DNS [ ' . $data['dns'] . ' ]'); } $sql_set = array(); if (isset($data['proxy_hostid'])) { $sql_set[] = 'proxy_hostid=' . $data['proxy_hostid']; } if (isset($data['host'])) { $sql_set[] = 'host=' . zbx_dbstr($data['host']); } if (isset($data['port'])) { $sql_set[] = 'port=' . $data['port']; } if (isset($data['status'])) { $sql_set[] = 'status=' . $data['status']; } if (isset($data['useip'])) { $sql_set[] = 'useip=' . $data['useip']; } if (isset($data['dns'])) { $sql_set[] = 'dns=' . zbx_dbstr($data['dns']); } if (isset($data['ip'])) { $sql_set[] = 'ip=' . zbx_dbstr($data['ip']); } if (isset($data['useipmi'])) { $sql_set[] = 'useipmi=' . $data['useipmi']; } if (isset($data['ipmi_port'])) { $sql_set[] = 'ipmi_port=' . $data['ipmi_port']; } if (isset($data['ipmi_authtype'])) { $sql_set[] = 'ipmi_authtype=' . $data['ipmi_authtype']; } if (isset($data['ipmi_privilege'])) { $sql_set[] = 'ipmi_privilege=' . $data['ipmi_privilege']; } if (isset($data['ipmi_username'])) { $sql_set[] = 'ipmi_username='******'ipmi_username']); } if (isset($data['ipmi_password'])) { $sql_set[] = 'ipmi_password='******'ipmi_password']); } if (isset($data['ipmi_ip'])) { $sql_set[] = 'ipmi_ip=' . zbx_dbstr($data['ipmi_ip']); } if (!empty($sql_set)) { $sql = 'UPDATE hosts SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $hostids); $result = DBexecute($sql); if (isset($data['status'])) { update_host_status($hostids, $data['status']); } } // }}} UPDATE HOSTS PROPERTIES // UPDATE HOSTGROUPS LINKAGE {{{ if (isset($data['groups']) && !is_null($data['groups'])) { $data['groups'] = zbx_toArray($data['groups']); $host_groups = CHostGroup::get(array('hostids' => $hostids)); $host_groupids = zbx_objectValues($host_groups, 'groupid'); $new_groupids = zbx_objectValues($data['groups'], 'groupid'); $groups_to_add = array_diff($new_groupids, $host_groupids); if (!empty($groups_to_add)) { $result = self::massAdd(array('hosts' => $hosts, 'groups' => zbx_toObject($groups_to_add, 'groupid'))); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t add group'); } } $groupids_to_del = array_diff($host_groupids, $new_groupids); if (!empty($groupids_to_del)) { $result = self::massRemove(array('hostids' => $hostids, 'groupids' => $groupids_to_del)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove group'); } } } // }}} UPDATE HOSTGROUPS LINKAGE $data['templates_clear'] = isset($data['templates_clear']) ? zbx_toArray($data['templates_clear']) : array(); $cleared_templateids = array(); foreach ($hostids as $hostid) { foreach ($data['templates_clear'] as $tpl) { $result = unlink_template($hostid, $tpl['templateid'], false); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot unlink template [ ' . $tpl['templateid'] . ' ]'); } $cleared_templateids[] = $tpl['templateid']; } } // UPDATE TEMPLATE LINKAGE {{{ if (isset($data['templates']) && !is_null($data['templates'])) { $opt = array('hostids' => $hostids, 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => true); $host_templates = CTemplate::get($opt); $host_templateids = array_keys($host_templates); $new_templateids = zbx_objectValues($data['templates'], 'templateid'); $templates_to_del = array_diff($host_templateids, $new_templateids); $templates_to_del = array_diff($templates_to_del, $cleared_templateids); if (!empty($templates_to_del)) { $result = self::massRemove(array('hostids' => $hostids, 'templateids' => $templates_to_del)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_UNLINK_TEMPLATE); } } $result = self::massAdd(array('hosts' => $hosts, 'templates' => $data['templates'])); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_LINK_TEMPLATE); } } // }}} UPDATE TEMPLATE LINKAGE // UPDATE MACROS {{{ if (isset($data['macros']) && !is_null($data['macros'])) { $macrosToAdd = zbx_toHash($data['macros'], 'macro'); $hostMacros = CUserMacro::get(array('hostids' => $hostids, 'output' => API_OUTPUT_EXTEND)); $hostMacros = zbx_toHash($hostMacros, 'macro'); // Delete $macrosToDelete = array(); foreach ($hostMacros as $hmnum => $hmacro) { if (!isset($macrosToAdd[$hmacro['macro']])) { $macrosToDelete[] = $hmacro['macro']; } } // Update $macrosToUpdate = array(); foreach ($macrosToAdd as $nhmnum => $nhmacro) { if (isset($hostMacros[$nhmacro['macro']])) { $macrosToUpdate[] = $nhmacro; unset($macrosToAdd[$nhmnum]); } } //---- if (!empty($macrosToDelete)) { $result = self::massRemove(array('hostids' => $hostids, 'macros' => $macrosToDelete)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove macro'); } } if (!empty($macrosToUpdate)) { $result = CUsermacro::massUpdate(array('hosts' => $hosts, 'macros' => $macrosToUpdate)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update macro'); } } if (!empty($macrosToAdd)) { $result = self::massAdd(array('hosts' => $hosts, 'macros' => $macrosToAdd)); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot add macro'); } } } // }}} UPDATE MACROS // PROFILE {{{ if (isset($data['profile']) && !is_null($data['profile'])) { if (empty($data['profile'])) { $sql = 'DELETE FROM hosts_profiles WHERE ' . DBcondition('hostid', $hostids); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete profile'); } } else { $existing_profiles = array(); $existing_profiles_db = DBselect('SELECT hostid FROM hosts_profiles WHERE ' . DBcondition('hostid', $hostids)); while ($existing_profile = DBfetch($existing_profiles_db)) { $existing_profiles[] = $existing_profile['hostid']; } $hostids_without_profile = array_diff($hostids, $existing_profiles); $fields = array_keys($data['profile']); $fields = implode(', ', $fields); $values = array_map('zbx_dbstr', $data['profile']); $values = implode(', ', $values); foreach ($hostids_without_profile as $hostid) { $sql = 'INSERT INTO hosts_profiles (hostid, ' . $fields . ') VALUES (' . $hostid . ', ' . $values . ')'; if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot create profile'); } } if (!empty($existing_profiles)) { $host_profile_fields = array('devicetype', 'name', 'os', 'serialno', 'tag', 'macaddress', 'hardware', 'software', 'contact', 'location', 'notes'); $sql_set = array(); foreach ($host_profile_fields as $field) { if (isset($data['profile'][$field])) { $sql_set[] = $field . '=' . zbx_dbstr($data['profile'][$field]); } } $sql = 'UPDATE hosts_profiles SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $existing_profiles); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update profile'); } } } } // }}} PROFILE // EXTENDED PROFILE {{{ if (isset($data['extendedProfile']) && !is_null($data['extendedProfile'])) { if (empty($data['extendedProfile'])) { $sql = 'DELETE FROM hosts_profiles_ext WHERE ' . DBcondition('hostid', $hostids); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete extended profile'); } } else { $existing_profiles = array(); $existing_profiles_db = DBselect('SELECT hostid FROM hosts_profiles_ext WHERE ' . DBcondition('hostid', $hostids)); while ($existing_profile = DBfetch($existing_profiles_db)) { $existing_profiles[] = $existing_profile['hostid']; } $hostids_without_profile = array_diff($hostids, $existing_profiles); $fields = array_keys($data['extendedProfile']); $fields = implode(', ', $fields); $values = array_map('zbx_dbstr', $data['extendedProfile']); $values = implode(', ', $values); foreach ($hostids_without_profile as $hostid) { $sql = 'INSERT INTO hosts_profiles_ext (hostid, ' . $fields . ') VALUES (' . $hostid . ', ' . $values . ')'; if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot create extended profile'); } } if (!empty($existing_profiles)) { $host_profile_ext_fields = array('device_alias', 'device_type', 'device_chassis', 'device_os', 'device_os_short', 'device_hw_arch', 'device_serial', 'device_model', 'device_tag', 'device_vendor', 'device_contract', 'device_who', 'device_status', 'device_app_01', 'device_app_02', 'device_app_03', 'device_app_04', 'device_app_05', 'device_url_1', 'device_url_2', 'device_url_3', 'device_networks', 'device_notes', 'device_hardware', 'device_software', 'ip_subnet_mask', 'ip_router', 'ip_macaddress', 'oob_ip', 'oob_subnet_mask', 'oob_router', 'date_hw_buy', 'date_hw_install', 'date_hw_expiry', 'date_hw_decomm', 'site_street_1', 'site_street_2', 'site_street_3', 'site_city', 'site_state', 'site_country', 'site_zip', 'site_rack', 'site_notes', 'poc_1_name', 'poc_1_email', 'poc_1_phone_1', 'poc_1_phone_2', 'poc_1_cell', 'poc_1_screen', 'poc_1_notes', 'poc_2_name', 'poc_2_email', 'poc_2_phone_1', 'poc_2_phone_2', 'poc_2_cell', 'poc_2_screen', 'poc_2_notes'); $sql_set = array(); foreach ($host_profile_ext_fields as $field) { if (isset($data['extendedProfile'][$field])) { $sql_set[] = $field . '=' . zbx_dbstr($data['extendedProfile'][$field]); } } $sql = 'UPDATE hosts_profiles_ext SET ' . implode(', ', $sql_set) . ' WHERE ' . DBcondition('hostid', $existing_profiles); if (!DBexecute($sql)) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update extended profile'); } } } } // }}} EXTENDED PROFILE self::EndTransaction(true, __METHOD__); return array('hostids' => $hostids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }
function delete_host($hostids, $unlink_mode = false) { zbx_value2array($hostids); if (empty($hostids)) { return true; } $ret = false; // unlink child hosts $db_childs = get_hosts_by_templateid($hostids); while ($db_child = DBfetch($db_childs)) { unlink_template($db_child['hostid'], $hostids, $unlink_mode); } // delete web tests $del_httptests = array(); $db_httptests = get_httptests_by_hostid($hostids); while ($db_httptest = DBfetch($db_httptests)) { $del_httptests[$db_httptest['httptestid']] = $db_httptest['httptestid']; } if (!empty($del_httptests)) { delete_httptest($del_httptests); } // delete items -> triggers -> graphs $del_items = array(); $db_items = get_items_by_hostid($hostids); while ($db_item = DBfetch($db_items)) { $del_items[$db_item['itemid']] = $db_item['itemid']; } delete_item($del_items); // delete screen items DBexecute('DELETE FROM screens_items WHERE ' . DBcondition('resourceid', $hostids)) . ' AND resourcetype=' . SCREEN_RESOURCE_HOST_TRIGGERS; // delete host from maps delete_sysmaps_elements_with_hostid($hostids); // delete host from maintenances DBexecute('DELETE FROM maintenances_hosts WHERE ' . DBcondition('hostid', $hostids)); // delete host from group DBexecute('DELETE FROM hosts_groups WHERE ' . DBcondition('hostid', $hostids)); // delete host from template linkages DBexecute('DELETE FROM hosts_templates WHERE ' . DBcondition('hostid', $hostids)); // disable actions $actionids = array(); // conditions $sql = 'SELECT DISTINCT actionid ' . ' FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . DBcondition('value', $hostids, false, true); // FIXED[POSIBLE value type violation]!!! $db_actions = DBselect($sql); while ($db_action = DBfetch($db_actions)) { $actionids[$db_action['actionid']] = $db_action['actionid']; } DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids)); // operations $sql = 'SELECT DISTINCT o.actionid ' . ' FROM operations o ' . ' WHERE o.operationtype IN (' . OPERATION_TYPE_GROUP_ADD . ',' . OPERATION_TYPE_GROUP_REMOVE . ') ' . ' AND ' . DBcondition('o.objectid', $hostids); $db_actions = DBselect($sql); while ($db_action = DBfetch($db_actions)) { $actionids[$db_action['actionid']] = $db_action['actionid']; } if (!empty($actionids)) { DBexecute('UPDATE actions ' . ' SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . DBcondition('actionid', $actionids)); } // delete action conditions DBexecute('DELETE FROM conditions ' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . DBcondition('value', $hostids, false, true)); // FIXED[POSIBLE value type violation]!!! // delete action operations DBexecute('DELETE FROM operations ' . ' WHERE operationtype IN (' . OPERATION_TYPE_TEMPLATE_ADD . ',' . OPERATION_TYPE_TEMPLATE_REMOVE . ') ' . ' AND ' . DBcondition('objectid', $hostids)); // delete host profile delete_host_profile($hostids); delete_host_profile_ext($hostids); $applicationids = array(); $query = 'SELECT a.applicationid' . ' FROM applications a' . ' WHERE ' . DBcondition('a.hostid', $hostids); $db_applications = DBselect($query); while ($app = DBfetch($db_applications)) { $applicationids[] = $app['applicationid']; } $result = delete_application($applicationids); if (!$result) { return false; } // delete host foreach ($hostids as $id) { /* The section should be improved */ $host_old = get_host_by_hostid($id); $result = DBexecute('DELETE FROM hosts WHERE hostid=' . $id); if ($result) { if ($host_old['status'] == HOST_STATUS_TEMPLATE) { info(S_TEMPLATE . SPACE . $host_old['host'] . SPACE . S_HOST_HAS_BEEN_DELETED_MSG_PART2); add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TEMPLATE, $id, $host_old['host'], 'hosts', NULL, NULL); } else { info(S_HOST_HAS_BEEN_DELETED_MSG_PART1 . SPACE . $host_old['host'] . SPACE . S_HOST_HAS_BEEN_DELETED_MSG_PART2); add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST, $id, $host_old['host'], 'hosts', NULL, NULL); } } else { break; } } return $result; }
/** * remove Hosts to HostGroups. All Hosts are added to all HostGroups. * * @param array $data * @param array $data['templateids'] * @param array $data['groupids'] * @param array $data['hostids'] * @param array $data['macroids'] * @return boolean */ public static function massRemove($data) { $templateids = zbx_toArray($data['templateids']); try { self::BeginTransaction(__METHOD__); $upd_templates = self::get(array('templateids' => $templateids, 'editable' => 1, 'preservekeys' => 1)); foreach ($templateids as $templateid) { if (!isset($upd_templates[$templateid])) { self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION); } } if (isset($data['groupids'])) { $options = array('groupids' => zbx_toArray($data['groupids']), 'templateids' => $templateids); $result = CHostGroup::massRemove($options); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t unlink groups'); } } if (isset($data['hostids'])) { $hostids = zbx_toArray($data['hostids']); foreach ($hostids as $hostid) { foreach ($templateids as $templateid) { $result = unlink_template($hostid, $templateid, true); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t unlink hosts'); } } } } if (isset($data['templateids_link'])) { $templateids_link = zbx_toArray($data['templateids_link']); foreach ($templateids_link as $templateid_link) { foreach ($templateids as $templateid) { $result = unlink_template($templateid, $templateid_link, true); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t unlink templates'); } } } } if (isset($data['macros'])) { $options = array('templateids' => $templateids, 'macros' => zbx_toArray($data['macros'])); $result = CUserMacro::massRemove($options); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove macros'); } } self::EndTransaction(true, __METHOD__); return array('templateids' => $templateids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }
access_deny(); } } $templates = get_request('templates', array()); $_REQUEST['proxy_hostid'] = get_request('proxy_hostid', 0); $clone_hostid = false; if ($_REQUEST['form'] == 'full_clone') { $clone_hostid = $_REQUEST['hostid']; unset($_REQUEST['hostid']); } $result = true; DBstart(); if (isset($_REQUEST['hostid'])) { if (isset($_REQUEST['clear_templates'])) { foreach ($_REQUEST['clear_templates'] as $id) { $result &= unlink_template($_REQUEST['hostid'], $id, false); } } $result = update_host($_REQUEST['hostid'], $_REQUEST['host'], $_REQUEST['port'], $_REQUEST['status'], $useip, $_REQUEST['dns'], $_REQUEST['ip'], $_REQUEST['proxy_hostid'], $templates, $useipmi, $_REQUEST['ipmi_ip'], $_REQUEST['ipmi_port'], $_REQUEST['ipmi_authtype'], $_REQUEST['ipmi_privilege'], $_REQUEST['ipmi_username'], $_REQUEST['ipmi_password'], $_REQUEST['newgroup'], $groups); $msg_ok = S_HOST_UPDATED; $msg_fail = S_CANNOT_UPDATE_HOST; /* $audit_action = AUDIT_ACTION_UPDATE;*/ $hostid = $_REQUEST['hostid']; } else { $hostid = $result = add_host($_REQUEST['host'], $_REQUEST['port'], $_REQUEST['status'], $useip, $_REQUEST['dns'], $_REQUEST['ip'], $_REQUEST['proxy_hostid'], $templates, $useipmi, $_REQUEST['ipmi_ip'], $_REQUEST['ipmi_port'], $_REQUEST['ipmi_authtype'], $_REQUEST['ipmi_privilege'], $_REQUEST['ipmi_username'], $_REQUEST['ipmi_password'], $_REQUEST['newgroup'], $groups); $msg_ok = S_HOST_ADDED; $msg_fail = S_CANNOT_ADD_HOST; /* $audit_action = AUDIT_ACTION_ADD;*/ } if (!zbx_empty($hostid) && $hostid && $clone_hostid && $_REQUEST['form'] == 'full_clone') { // Host applications
$result &= copy_graph_to_host($db_graph['graphid'], $templateid, true); } } // --->>> <<<--- // <<<--- LINK/UNLINK HOSTS --->>> if ($result) { $hosts = array_intersect($hosts, $available_hosts); //-- unlink -- $linked_hosts = array(); $db_childs = get_hosts_by_templateid($templateid); while ($db_child = DBfetch($db_childs)) { $linked_hosts[$db_child['hostid']] = $db_child['hostid']; } $unlink_hosts = array_diff($linked_hosts, $hosts); foreach ($unlink_hosts as $id => $value) { $result &= unlink_template($value, $templateid, false); } //-- link -- $link_hosts = array_diff($hosts, $linked_hosts); $template_name = DBfetch(DBselect('SELECT host FROM hosts WHERE hostid=' . $templateid)); foreach ($link_hosts as $id => $hostid) { $host_groups = array(); $db_hosts_groups = DBselect('SELECT groupid FROM hosts_groups WHERE hostid=' . $hostid); while ($hg = DBfetch($db_hosts_groups)) { $host_groups[] = $hg['groupid']; } $host = get_host_by_hostid($hostid); $templates_tmp = get_templates_by_hostid($hostid); $templates_tmp[$templateid] = $template_name['host']; $result &= update_host($hostid, $host['host'], $host['port'], $host['status'], $host['useip'], $host['dns'], $host['ip'], $host['proxy_hostid'], $templates_tmp, $host['useipmi'], $host['ipmi_ip'], $host['ipmi_port'], $host['ipmi_authtype'], $host['ipmi_privilege'], $host['ipmi_username'], $host['ipmi_password'], null, $host_groups); }