Esempio n. 1
0
    $result = DBend($result);
    $updated = count($groupHostDiscoveryRuleId);
    $messageSuccess = $enable ? _n('Discovery rule enabled', 'Discovery rules enabled', $updated) : _n('Discovery rule disabled', 'Discovery rules disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable discovery rules', 'Cannot enable discovery rules', $updated) : _n('Cannot disable discovery rules', 'Cannot disable discovery rules', $updated);
    show_messages($result, $messageSuccess, $messageFailed);
    clearCookies($result, getRequest('hostid'));
} elseif ($_REQUEST['go'] == 'delete' && isset($_REQUEST['g_hostdruleid'])) {
    $goResult = API::DiscoveryRule()->delete($_REQUEST['g_hostdruleid']);
    show_messages($goResult, _('Discovery rules deleted'), _('Cannot delete discovery rules'));
    clearCookies($goResult, $_REQUEST['hostid']);
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $data = getItemFormData(array('is_discovery_rule' => true));
    $data['page_header'] = _('CONFIGURATION OF DISCOVERY RULES');
    // render view
    $itemView = new CView('configuration.item.edit', $data);
    $itemView->render();
    $itemView->show();
} else {
    $data = array('hostid' => get_request('hostid', 0), 'host' => $host, 'showErrorColumn' => $host['status'] != HOST_STATUS_TEMPLATE);
    $sortfield = getPageSortField('name');
    // discoveries
    $data['discoveries'] = API::DiscoveryRule()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectItems' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectHostPrototypes' => API_OUTPUT_COUNT, 'sortfield' => $sortfield, 'limit' => $config['search_limit'] + 1));
    $data['discoveries'] = CMacrosResolverHelper::resolveItemNames($data['discoveries']);
    if ($sortfield === 'status') {
        orderItemsByStatus($data['discoveries'], getPageSortOrder());
    } else {
        order_result($data['discoveries'], $sortfield, getPageSortOrder());
Esempio n. 2
0
    $result = DBend($result);
    if ($result) {
        uncheckTableRows(getRequest('parent_discoveryid'));
    }
    show_messages($result, _('Item prototypes deleted'), _('Cannot delete item prototypes'));
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $itemPrototype = [];
    if (hasRequest('itemid')) {
        $itemPrototype = API::ItemPrototype()->get(['itemids' => getRequest('itemid'), 'output' => ['itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'multiplier', 'delta', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'formula', 'logtimefmt', 'templateid', 'valuemapid', 'delay_flex', 'params', 'ipmi_sensor', 'data_type', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'interfaceid', 'port', 'description', 'snmpv3_authprotocol', 'snmpv3_privprotocol', 'snmpv3_contextname']]);
        $itemPrototype = reset($itemPrototype);
    }
    $data = getItemFormData($itemPrototype);
    $data['config'] = select_config();
    // render view
    $itemView = new CView('configuration.item.prototype.edit', $data);
    $itemView->render();
    $itemView->show();
} else {
    $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name'));
    $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
    CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
    CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
    $config = select_config();
    $data = ['form' => getRequest('form'), 'parent_discoveryid' => getRequest('parent_discoveryid'), 'hostid' => $discoveryRule['hostid'], 'sort' => $sortField, 'sortorder' => $sortOrder];
    $data['items'] = API::ItemPrototype()->get(['discoveryids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectApplications' => API_OUTPUT_EXTEND, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1]);
    foreach ($data['items'] as &$item) {
        if ($item['value_type'] == ITEM_VALUE_TYPE_STR || $item['value_type'] == ITEM_VALUE_TYPE_LOG || $item['value_type'] == ITEM_VALUE_TYPE_TEXT) {
Esempio n. 3
0
            $host = reset($item['hosts']);
            add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM, _('Item') . ' [' . $item['key_'] . '] [' . $item['itemid'] . '] ' . _('Host') . ' [' . $host['name'] . ']');
        }
    }
    show_messages(DBend($go_result), _('Items deleted'), _('Cannot delete items'));
}
if ($_REQUEST['go'] != 'none' && !empty($go_result)) {
    $url = new CUrl();
    $path = $url->getPath();
    insert_js('cookie.eraseArray("' . $path . '")');
}
/*
 * Display
 */
if (isset($_REQUEST['form']) && str_in_array($_REQUEST['form'], array(_('Create item'), 'update', 'clone'))) {
    $data = getItemFormData();
    $data['page_header'] = _('CONFIGURATION OF ITEMS');
    // render view
    $itemView = new CView('configuration.item.edit', $data);
    $itemView->render();
    $itemView->show();
} elseif ($_REQUEST['go'] == 'massupdate' || isset($_REQUEST['massupdate']) && isset($_REQUEST['group_itemid'])) {
    $data = array('form' => get_request('form', null), 'hostid' => get_request('hostid', null), 'itemids' => get_request('group_itemid', array()), 'description' => get_request('description', ''), 'delay' => get_request('delay', ZBX_ITEM_DELAY_DEFAULT), 'delay_flex' => get_request('delay_flex', array()), 'history' => get_request('history', 90), 'status' => get_request('status', 0), 'type' => get_request('type', 0), 'interfaceid' => get_request('interfaceid', 0), 'snmp_community' => get_request('snmp_community', 'public'), 'port' => get_request('port', ''), 'value_type' => get_request('value_type', ITEM_VALUE_TYPE_UINT64), 'data_type' => get_request('data_type', ITEM_DATA_TYPE_DECIMAL), 'trapper_hosts' => get_request('trapper_hosts', ''), 'units' => get_request('units', ''), 'authtype' => get_request('authtype', ''), 'username' => get_request('username', ''), 'password' => get_request('password', ''), 'publickey' => get_request('publickey', ''), 'privatekey' => get_request('privatekey', ''), 'valuemapid' => get_request('valuemapid', 0), 'delta' => get_request('delta', 0), 'trends' => get_request('trends', DAY_IN_YEAR), 'applications' => get_request('applications', array()), 'snmpv3_securityname' => get_request('snmpv3_securityname', ''), 'snmpv3_securitylevel' => get_request('snmpv3_securitylevel', 0), 'snmpv3_authpassphrase' => get_request('snmpv3_authpassphrase', ''), 'snmpv3_privpassphrase' => get_request('snmpv3_privpassphrase', ''), 'formula' => get_request('formula', '1'), 'logtimefmt' => get_request('logtimefmt', ''), 'initial_item_type' => null, 'multiple_interface_types' => false);
    // hosts
    $data['hosts'] = API::Host()->get(array('itemids' => $data['itemids'], 'selectInterfaces' => API_OUTPUT_EXTEND));
    $data['is_multiple_hosts'] = count($data['hosts']) > 1;
    if (!$data['is_multiple_hosts']) {
        $data['hosts'] = reset($data['hosts']);
        // set the initial chosen interface to one of the interfaces the items use
        $items = API::Item()->get(array('itemids' => zbx_objectValues($data['hosts']['items'], 'itemid'), 'output' => array('itemid', 'type')));
        $usedInterfacesTypes = array();
Esempio n. 4
0
    $messageSuccess = $enable ? _n('Discovery rule enabled', 'Discovery rules enabled', $updated) : _n('Discovery rule disabled', 'Discovery rules disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable discovery rule', 'Cannot enable discovery rules', $updated) : _n('Cannot disable discovery rule', 'Cannot disable discovery rules', $updated);
    show_messages($result, $messageSuccess, $messageFailed);
} elseif (hasRequest('action') && getRequest('action') == 'discoveryrule.massdelete' && hasRequest('g_hostdruleid')) {
    $result = API::DiscoveryRule()->delete(getRequest('g_hostdruleid'));
    if ($result) {
        uncheckTableRows(getRequest('hostid'));
    }
    show_messages($result, _('Discovery rules deleted'), _('Cannot delete discovery rules'));
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $formItem = hasRequest('itemid') && !hasRequest('clone') ? $item : [];
    $data = getItemFormData($formItem, ['is_discovery_rule' => true]);
    $data['lifetime'] = getRequest('lifetime', 30);
    $data['evaltype'] = getRequest('evaltype');
    $data['formula'] = getRequest('formula');
    $data['conditions'] = getRequest('conditions', []);
    // update form
    if (hasRequest('itemid') && !getRequest('form_refresh')) {
        $data['lifetime'] = $item['lifetime'];
        $data['evaltype'] = $item['filter']['evaltype'];
        $data['formula'] = $item['filter']['formula'];
        $data['conditions'] = $item['filter']['conditions'];
    } elseif (hasRequest('clone')) {
        unset($data['itemid']);
        $data['form'] = 'clone';
    }
    // render view
Esempio n. 5
0
    $result = DBend($result);
    if ($result) {
        uncheckTableRows(getRequest('hostid'));
    }
    show_messages($result, _('Items deleted'), _('Cannot delete items'));
}
/*
 * Display
 */
if (isset($_REQUEST['form']) && str_in_array($_REQUEST['form'], array(_('Create item'), 'update', 'clone'))) {
    $item = array();
    if (hasRequest('itemid')) {
        $item = API::Item()->get(array('itemids' => getRequest('itemid'), 'output' => array('itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'multiplier', 'delta', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'formula', 'logtimefmt', 'templateid', 'valuemapid', 'delay_flex', 'params', 'ipmi_sensor', 'data_type', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'interfaceid', 'port', 'description', 'inventory_link', 'lifetime', 'snmpv3_authprotocol', 'snmpv3_privprotocol', 'snmpv3_contextname')));
        $item = reset($item);
    }
    $data = getItemFormData($item);
    $data['page_header'] = _('CONFIGURATION OF ITEMS');
    $data['inventory_link'] = getRequest('inventory_link');
    if (hasRequest('itemid') && !getRequest('form_refresh')) {
        $data['inventory_link'] = $item['inventory_link'];
    }
    // render view
    $itemView = new CView('configuration.item.edit', $data);
    $itemView->render();
    $itemView->show();
} elseif ((hasRequest('action') && getRequest('action') == 'item.massupdateform' || hasRequest('massupdate')) && hasRequest('group_itemid')) {
    $data = array('form' => getRequest('form'), 'action' => 'item.massupdateform', 'hostid' => getRequest('hostid'), 'itemids' => getRequest('group_itemid', array()), 'description' => getRequest('description', ''), 'delay' => getRequest('delay', ZBX_ITEM_DELAY_DEFAULT), 'delay_flex' => getRequest('delay_flex', array()), 'history' => getRequest('history', 90), 'status' => getRequest('status', 0), 'type' => getRequest('type', 0), 'interfaceid' => getRequest('interfaceid', 0), 'snmp_community' => getRequest('snmp_community', 'public'), 'port' => getRequest('port', ''), 'value_type' => getRequest('value_type', ITEM_VALUE_TYPE_UINT64), 'data_type' => getRequest('data_type', ITEM_DATA_TYPE_DECIMAL), 'trapper_hosts' => getRequest('trapper_hosts', ''), 'units' => getRequest('units', ''), 'authtype' => getRequest('authtype', ''), 'username' => getRequest('username', ''), 'password' => getRequest('password', ''), 'publickey' => getRequest('publickey', ''), 'privatekey' => getRequest('privatekey', ''), 'valuemapid' => getRequest('valuemapid', 0), 'delta' => getRequest('delta', 0), 'trends' => getRequest('trends', DAY_IN_YEAR), 'applications' => getRequest('applications', array()), 'snmpv3_contextname' => getRequest('snmpv3_contextname', ''), 'snmpv3_securityname' => getRequest('snmpv3_securityname', ''), 'snmpv3_securitylevel' => getRequest('snmpv3_securitylevel', 0), 'snmpv3_authprotocol' => getRequest('snmpv3_authprotocol', ITEM_AUTHPROTOCOL_MD5), 'snmpv3_authpassphrase' => getRequest('snmpv3_authpassphrase', ''), 'snmpv3_privprotocol' => getRequest('snmpv3_privprotocol', ITEM_PRIVPROTOCOL_DES), 'snmpv3_privpassphrase' => getRequest('snmpv3_privpassphrase', ''), 'formula' => getRequest('formula', '1'), 'logtimefmt' => getRequest('logtimefmt', ''), 'initial_item_type' => null, 'multiple_interface_types' => false, 'visible' => getRequest('visible', array()));
    $data['displayApplications'] = true;
    $data['displayInterfaces'] = true;
    // hosts
    $data['hosts'] = API::Host()->get(array('output' => array('hostid'), 'itemids' => $data['itemids'], 'selectItems' => array('itemid'), 'selectInterfaces' => API_OUTPUT_EXTEND));