示例#1
0
    DBstart();
    $result = $enable ? activate_item($groupItemId) : disable_item($groupItemId);
    $result = DBend($result);
    $updated = count($groupItemId);
    $messageSuccess = $enable ? _n('Item prototype enabled', 'Item prototypes enabled', $updated) : _n('Item prototype disabled', 'Item prototypes disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable item prototype', 'Cannot enable item prototypes', $updated) : _n('Cannot disable item prototype', 'Cannot disable item prototypes', $updated);
    if ($result) {
        uncheckTableRows(getRequest('parent_discoveryid'));
    }
    show_messages($result, $messageSuccess, $messageFailed);
} elseif (hasRequest('action') && getRequest('action') == 'itemprototype.massdelete' && hasRequest('group_itemid')) {
    DBstart();
    $result = API::Itemprototype()->delete(getRequest('group_itemid'));
    $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
示例#2
0
    $regExps = [];
    foreach ($regExpIds as $regExpId) {
        $regExps[$regExpId] = getRegexp($regExpId);
    }
    DBstart();
    $result = DBexecute('DELETE FROM regexps WHERE ' . dbConditionInt('regexpid', $regExpIds));
    $regExpCount = count($regExpIds);
    if ($result) {
        foreach ($regExps as $regExpId => $regExp) {
            add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_REGEXP, 'Id [' . $regExpId . '] ' . _('Name') . ' [' . $regExp['name'] . ']');
        }
        unset($_REQUEST['form'], $_REQUEST['regexpid']);
    }
    $result = DBend($result);
    if ($result) {
        uncheckTableRows();
    }
    show_messages($result, _n('Regular expression deleted', 'Regular expressions deleted', $regExpCount), _n('Cannot delete regular expression', 'Cannot delete regular expressions', $regExpCount));
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $data = ['form_refresh' => getRequest('form_refresh'), 'regexpid' => getRequest('regexpid')];
    if (isset($_REQUEST['regexpid']) && !isset($_REQUEST['form_refresh'])) {
        $regExp = DBfetch(DBSelect('SELECT re.name,re.test_string' . ' FROM regexps re' . ' WHERE re.regexpid=' . zbx_dbstr($_REQUEST['regexpid'])));
        $data['name'] = $regExp['name'];
        $data['test_string'] = $regExp['test_string'];
        $data['expressions'] = DBfetchArray(DBselect('SELECT e.expressionid,e.expression,e.expression_type,e.exp_delimiter,e.case_sensitive' . ' FROM expressions e' . ' WHERE e.regexpid=' . zbx_dbstr($_REQUEST['regexpid']) . ' ORDER BY e.expression_type'));
    } else {
        $data['name'] = getRequest('name', '');
示例#3
0
    $groupHostDiscoveryRuleId = getRequest('g_hostdruleid');
    $enable = getRequest('action') == 'discoveryrule.massenable';
    DBstart();
    $result = $enable ? activate_item($groupHostDiscoveryRuleId) : disable_item($groupHostDiscoveryRuleId);
    $result = DBend($result);
    if ($result) {
        uncheckTableRows(getRequest('hostid'));
    }
    $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 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')) {
示例#4
0
    show_messages($result, _n('Application deleted', 'Applications deleted', $deleted), _n('Cannot delete application', 'Cannot delete applications', $deleted));
} elseif (hasRequest('applications') && str_in_array(getRequest('action'), array('application.massenable', 'application.massdisable'))) {
    $enableApplicationItems = getRequest('action') === 'application.massenable';
    $applications = API::Application()->get(array('output' => array(), 'applicationids' => getRequest('applications', array()), 'selectItems' => array('itemid'), 'hostids' => $pageFilter->hostid > 0 ? $pageFilter->hostid : null));
    $actionSuccessful = true;
    $updatedItemCount = 0;
    DBstart();
    foreach ($applications as $application) {
        foreach ($application['items'] as $item) {
            $actionSuccessful &= $enableApplicationItems ? activate_item($item['itemid']) : disable_item($item['itemid']);
            $updatedItemCount++;
        }
    }
    $actionSuccessful = DBend($actionSuccessful);
    if ($actionSuccessful) {
        uncheckTableRows($pageFilter->hostid);
    }
    $messageSuccess = $enableApplicationItems ? _n('Item enabled', 'Items enabled', $updatedItemCount) : _n('Item disabled', 'Items disabled', $updatedItemCount);
    $messageFailed = $enableApplicationItems ? _n('Cannot enable item', 'Cannot enable items', $updatedItemCount) : _n('Cannot disable item', 'Cannot disable items', $updatedItemCount);
    show_messages($actionSuccessful, $messageSuccess, $messageFailed);
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $data = array('applicationid' => getRequest('applicationid'), 'form' => getRequest('form'), 'form_refresh' => getRequest('form_refresh', 0));
    if (isset($data['applicationid']) && !isset($_REQUEST['form_refresh'])) {
        $dbApplication = reset($dbApplication);
        $data['appname'] = $dbApplication['name'];
        $data['hostid'] = $dbApplication['hostid'];
    } else {
    }
    $result = API::HostPrototype()->update($update);
    $result = DBend($result);
    $updated = count($update);
    $messageSuccess = $enable ? _n('Host prototype enabled', 'Host prototypes enabled', $updated) : _n('Host prototype disabled', 'Host prototypes disabled', $updated);
    $messageFailed = $enable ? _n('Cannot enable host prototype', 'Cannot enable host prototypes', $updated) : _n('Cannot disable host prototype', 'Cannot disable host prototypes', $updated);
    if ($result) {
        uncheckTableRows($discoveryRule['itemid']);
    }
    show_messages($result, $messageSuccess, $messageFailed);
} elseif (hasRequest('action') && getRequest('action') == 'hostprototype.massdelete' && getRequest('group_hostid')) {
    DBstart();
    $result = API::HostPrototype()->delete(getRequest('group_hostid'));
    $result = DBend($result);
    if ($result) {
        uncheckTableRows($discoveryRule['itemid']);
    }
    show_messages($result, _('Host prototypes deleted'), _('Cannot delete host prototypes'));
}
/*
 * Display
 */
if (isset($_REQUEST['form'])) {
    $data = array('discovery_rule' => $discoveryRule, 'host_prototype' => array('hostid' => getRequest('hostid'), 'templateid' => getRequest('templateid'), 'host' => getRequest('host'), 'name' => getRequest('name'), 'status' => getRequest('status', HOST_STATUS_MONITORED), 'templates' => array(), 'inventory' => array('inventory_mode' => getRequest('inventory_mode', HOST_INVENTORY_DISABLED)), 'groupPrototypes' => getRequest('group_prototypes', array())), 'groups' => array());
    // add already linked and new templates
    $data['host_prototype']['templates'] = API::Template()->get(array('output' => array('templateid', 'name'), 'templateids' => getRequest('templates', array())));
    // add parent host
    $parentHost = API::Host()->get(array('output' => API_OUTPUT_EXTEND, 'selectGroups' => array('groupid', 'name'), 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectMacros' => API_OUTPUT_EXTEND, 'hostids' => $discoveryRule['hostid'], 'templated_hosts' => true));
    $parentHost = reset($parentHost);
    $data['parent_host'] = $parentHost;
    if (getRequest('group_links')) {
示例#6
0
                if (!isset($dbGroups[$groupid])) {
                    access_deny();
                }
            }
            $options['groupids'] = getRequest('copy_targetid');
        }
        $dbHosts = API::Host()->get($options);
        DBstart();
        foreach (getRequest('group_graphid') as $graphid) {
            foreach ($dbHosts as $host) {
                $result &= (bool) copyGraphToHost($graphid, $host['hostid']);
            }
        }
        $result = DBend($result);
        if ($result) {
            uncheckTableRows(getRequest('parent_discoveryid') == 0 ? getRequest('hostid') : getRequest('parent_discoveryid'));
            unset($_REQUEST['group_graphid']);
        }
        show_messages($result, _('Graphs copied'), _('Cannot copy graphs'));
    } else {
        error(_('No target selected.'));
    }
    show_messages();
}
/*
 * Display
 */
$pageFilter = new CPageFilter(array('groups' => array('with_hosts_and_templates' => true, 'editable' => true), 'hosts' => array('editable' => true, 'templated_hosts' => true), 'groupid' => getRequest('groupid'), 'hostid' => getRequest('hostid')));
if (empty($_REQUEST['parent_discoveryid'])) {
    if ($pageFilter->groupid > 0) {
        $_REQUEST['groupid'] = $pageFilter->groupid;
示例#7
0
                    access_deny();
                }
            }
            $options['groupids'] = getRequest('copy_targetid');
        }
        $dbHosts = API::Host()->get($options);
        DBstart();
        foreach (getRequest('group_graphid') as $graphid) {
            foreach ($dbHosts as $host) {
                $result &= (bool) copyGraphToHost($graphid, $host['hostid']);
            }
        }
        $result = DBend($result);
        $graphs_count = count(getRequest('group_graphid'));
        if ($result) {
            uncheckTableRows(getRequest('parent_discoveryid') == 0 ? $hostId : getRequest('parent_discoveryid'));
            unset($_REQUEST['group_graphid']);
        }
        show_messages($result, _n('Graph copied', 'Graphs copied', $graphs_count), _n('Cannot copy graph', 'Cannot copy graphs', $graphs_count));
    } else {
        error(_('No target selected.'));
    }
    show_messages();
}
/*
 * Display
 */
$pageFilter = new CPageFilter(['groups' => ['with_hosts_and_templates' => true, 'editable' => true], 'hosts' => ['editable' => true, 'templated_hosts' => true], 'groupid' => $groupId, 'hostid' => $hostId]);
if (empty($_REQUEST['parent_discoveryid'])) {
    if ($pageFilter->groupid > 0) {
        $groupId = $pageFilter->groupid;