当前位置: 首页>>代码示例>>PHP>>正文


PHP discovery_check_type2str函数代码示例

本文整理汇总了PHP中discovery_check_type2str函数的典型用法代码示例。如果您正苦于以下问题:PHP discovery_check_type2str函数的具体用法?PHP discovery_check_type2str怎么用?PHP discovery_check_type2str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了discovery_check_type2str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: discovery_check2str

function discovery_check2str($type, $key, $port)
{
    $externalParam = '';
    if ($key !== '') {
        switch ($type) {
            case SVC_SNMPv1:
            case SVC_SNMPv2c:
            case SVC_SNMPv3:
            case SVC_AGENT:
                $externalParam = ' "' . $key . '"';
                break;
        }
    }
    $result = discovery_check_type2str($type);
    if ($port && (svc_default_port($type) !== $port || $type === SVC_TCP)) {
        $result .= ' (' . $port . ')';
    }
    return $result . $externalParam;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:19,代码来源:discovery.inc.php

示例2: discovery_check2str

function discovery_check2str($type, $snmp_community, $key_, $ports)
{
    $external_param = null;
    $port_def = svc_default_port($type);
    switch ($type) {
        case SVC_SNMPv1:
        case SVC_SNMPv2:
        case SVC_SNMPv3:
        case SVC_AGENT:
            $external_param = ' "' . $key_ . '"';
            break;
    }
    return discovery_check_type2str($type) . ($port_def == $ports ? '' : ' (' . $ports . ')') . $external_param;
}
开发者ID:phedders,项目名称:zabbix,代码行数:14,代码来源:discovery.inc.php

示例3: CVar

     $conditionFormList->addItem(new CVar('new_condition[value]', '0'));
     $condition = array(new CTextBox('drule', '', ZBX_TEXTBOX_STANDARD_SIZE, true), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=drules&srcfld1=druleid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=drule", 450, 450);', 'link_menu'));
     break;
 case CONDITION_TYPE_DCHECK:
     $conditionFormList->addItem(new CVar('new_condition[value]', '0'));
     $condition = array(new CTextBox('dcheck', '', ZBX_TEXTBOX_STANDARD_SIZE, true), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=dchecks&srcfld1=dcheckid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=dcheck&writeonly=1", 450, 450);', 'link_menu'));
     break;
 case CONDITION_TYPE_PROXY:
     $conditionFormList->addItem(new CVar('new_condition[value]', '0'));
     $condition = array(new CTextBox('proxy', '', ZBX_TEXTBOX_STANDARD_SIZE, true), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=proxies&srcfld1=hostid&srcfld2=host' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=proxy' . '", 450, 450);', 'link_menu'));
     break;
 case CONDITION_TYPE_DHOST_IP:
     $condition = new CTextBox('new_condition[value]', '192.168.0.1-127,192.168.2.1', ZBX_TEXTBOX_STANDARD_SIZE);
     break;
 case CONDITION_TYPE_DSERVICE_TYPE:
     $discoveryCheckTypes = discovery_check_type2str();
     order_result($discoveryCheckTypes);
     $condition = new CComboBox('new_condition[value]');
     foreach ($discoveryCheckTypes as $key => $discoveryCheckType) {
         $condition->addItem($key, $discoveryCheckType);
     }
     break;
 case CONDITION_TYPE_DSERVICE_PORT:
     $condition = new CTextBox('new_condition[value]', '0-1023,1024-49151', ZBX_TEXTBOX_STANDARD_SIZE);
     break;
 case CONDITION_TYPE_DSTATUS:
     $condition = new CComboBox('new_condition[value]');
     foreach (array(DOBJECT_STATUS_UP, DOBJECT_STATUS_DOWN, DOBJECT_STATUS_DISCOVER, DOBJECT_STATUS_LOST) as $stat) {
         $condition->addItem($stat, discovery_object_status2str($stat));
     }
     break;
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:configuration.action.edit.php

示例4: insert_drule_form

if (isset($_REQUEST["form"])) {
    /* form */
    insert_drule_form();
} else {
    show_table_header(S_DISCOVERY_BIG);
    /* table */
    $form = new CForm();
    $form->SetName('frmdrules');
    $tblDiscovery = new CTableInfo(S_NO_DISCOVERY_RULES_DEFINED);
    $tblDiscovery->SetHeader(array(array(new CCheckBox('all_drules', null, "CheckAll('" . $form->GetName() . "','all_drules');"), make_sorting_link(S_NAME, 'd.name')), make_sorting_link(S_IP_RANGE, 'd.iprange'), make_sorting_link(S_DELAY, 'd.delay'), S_CHECKS, S_STATUS));
    $db_rules = DBselect('SELECT d.* ' . ' FROM drules d' . ' WHERE ' . DBin_node('druleid') . order_by('d.name,d.iprange,d.delay', 'd.druleid'));
    while ($rule_data = DBfetch($db_rules)) {
        $cheks = array();
        $db_checks = DBselect("select * from dchecks where druleid=" . $rule_data["druleid"] . " order by type,druleid");
        while ($check_data = DBfetch($db_checks)) {
            $cheks[] = discovery_check_type2str($check_data['type']);
        }
        $status = new CCol(new CLink(discovery_status2str($rule_data["status"]), '?g_druleid%5B%5D=' . $rule_data['druleid'] . ($rule_data["status"] == DRULE_STATUS_ACTIVE ? '&group_disable=1' : '&group_enable=1'), discovery_status2style($rule_data["status"])));
        $description = array();
        if ($rule_data["proxy_hostid"]) {
            $proxy = get_host_by_hostid($rule_data["proxy_hostid"]);
            array_push($description, $proxy["host"], ":");
        }
        array_push($description, new CLink($rule_data['name'], "?form=update&druleid=" . $rule_data['druleid'], 'action'));
        $drule = new CCol(array(new CCheckBox('g_druleid[' . $rule_data["druleid"] . ']', null, null, $rule_data["druleid"]), SPACE, $description));
        $tblDiscovery->AddRow(array($drule, $rule_data['iprange'], $rule_data['delay'], implode(',', $cheks), $status));
    }
    $tblDiscovery->SetFooter(new CCol(array(new CButtonQMessage('group_enable', S_ENABLE_SELECTED, S_ENABLE_SELECTED_RULES_Q), SPACE, new CButtonQMessage('group_disable', S_DISABLE_SELECTED, S_DISABLE_SELECTED_RULES_Q), SPACE, new CButtonQMessage('group_delete', S_DELETE_SELECTED, S_DELETE_SELECTED_RULES_Q))));
    $form->AddItem($tblDiscovery);
    $form->Show();
}
开发者ID:rennhak,项目名称:zabbix,代码行数:31,代码来源:discoveryconf.php

示例5: get_history_of_discovery_events

function get_history_of_discovery_events($start, $end)
{
    $sql_cond = ' AND e.clock>' . $start;
    $sql_cond .= ' AND e.clock<' . $end;
    $sql = 'SELECT DISTINCT e.source,e.object,e.objectid,e.clock,e.value ' . ' FROM events e' . ' WHERE e.source=' . EVENT_SOURCE_DISCOVERY . $sql_cond . order_by('e.clock');
    $db_events = DBselect($sql);
    $table = new CTableInfo(S_NO_EVENTS_FOUND);
    $table->SetHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
    $col = 0;
    while ($event_data = DBfetch($db_events)) {
        $value = new CCol(trigger_value2str($event_data['value']), get_trigger_value_style($event_data['value']));
        switch ($event_data['object']) {
            case EVENT_OBJECT_DHOST:
                $object_data = DBfetch(DBselect('SELECT ip FROM dhosts WHERE dhostid=' . $event_data['objectid']));
                $description = SPACE;
                break;
            case EVENT_OBJECT_DSERVICE:
                $object_data = DBfetch(DBselect('SELECT h.ip,s.type,s.port ' . ' FROM dhosts h,dservices s ' . ' WHERE h.dhostid=s.dhostid ' . ' AND s.dserviceid=' . $event_data['objectid']));
                $description = S_SERVICE . ': ' . discovery_check_type2str($object_data['type']) . '; ' . S_PORT . ': ' . $object_data['port'];
                break;
            default:
                continue;
        }
        if (!$object_data) {
            continue;
        }
        $table->AddRow(array(date('Y.M.d H:i:s', $event_data['clock']), $object_data['ip'], $description, $value));
        $col++;
    }
    return $table;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:31,代码来源:events.inc.php

示例6: validate_condition

function validate_condition($conditiontype, $value)
{
    global $USER_DETAILS;
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_groups[$value])) {
                error(S_INCORRECT_GROUP);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST_TEMPLATE:
            $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_hosts[$value])) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER:
            if (!DBfetch(DBselect('select triggerid from triggers where triggerid=' . $value)) || !check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $value)) {
                error(S_INCORRECT_TRIGGER);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST:
            $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true));
            if (!isset($available_hosts[$value])) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            if (!validate_period($value)) {
                error(S_INCORRECT_PERIOD . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DHOST_IP:
            if (!validate_ip_range($value)) {
                error(S_INCORRECT_IP . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            if (S_UNKNOWN == discovery_check_type2str($value)) {
                error(S_INCORRECT_DISCOVERY_CHECK);
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            if (!validate_port_list($value)) {
                error(S_INCORRECT_PORT . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSTATUS:
            if (S_UNKNOWN == discovery_object_status2str($value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            if (S_UNKNOWN == condition_value2str($conditiontype, $value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_TRIGGER_VALUE:
        case CONDITION_TYPE_TRIGGER_SEVERITY:
        case CONDITION_TYPE_MAINTENANCE:
        case CONDITION_TYPE_DUPTIME:
        case CONDITION_TYPE_DVALUE:
        case CONDITION_TYPE_APPLICATION:
            break;
        default:
            error(S_INCORRECT_CONDITION_TYPE);
            return false;
            break;
    }
    return true;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:82,代码来源:actions.inc.php

示例7: discovery_check_type2str

                 if (isset($dhosts[$event_data['objectid']])) {
                     $event_data['object_data'] = $dhosts[$event_data['objectid']];
                 } else {
                     $event_data['object_data']['ip'] = S_UNKNOWN;
                 }
                 $event_data['description'] = S_HOST;
                 break;
             case EVENT_OBJECT_DSERVICE:
                 if (isset($dservices[$event_data['objectid']])) {
                     $event_data['object_data'] = $dservices[$event_data['objectid']];
                 } else {
                     $event_data['object_data']['ip'] = S_UNKNOWN;
                     $event_data['object_data']['type'] = S_UNKNOWN;
                     $event_data['object_data']['port'] = S_UNKNOWN;
                 }
                 $event_data['description'] = S_SERVICE . ': ' . discovery_check_type2str($event_data['object_data']['type']) . '; ' . S_PORT . ': ' . $event_data['object_data']['port'];
                 break;
             default:
                 continue;
         }
         if (!isset($event_data['object_data'])) {
             continue;
         }
         $table->addRow(array(zbx_date2str(S_EVENTS_DISCOVERY_TIME_FORMAT, $event_data['clock']), $event_data['object_data']['ip'], $event_data['description'], new CCol(discovery_value($event_data['value']), discovery_value_style($event_data['value']))));
     }
 } else {
     $table->setHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 ? S_HOST : null, S_DESCRIPTION, S_STATUS, S_SEVERITY, S_DURATION, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
     $triggers = array();
     if ($pageFilter->hostid > 0 || $pageFilter->groupid > 0) {
         $trigOpt = array('nodeids' => get_current_nodeid(), 'output' => API_OUTPUT_SHORTEN);
         if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) {
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:events.php

示例8: actionConditionValueToString

/**
 * Converts numerical action condition values to their corresponding string values according to action condition type.
 *
 * For action condition types such as: hosts, host groups, templates, proxies, triggers, discovery rules
 * and discovery checks, action condition values contain IDs. All unique IDs are first collected and then queried.
 * For other action condition types values are returned as they are or converted using simple string convertion
 * functions according to action condition type.
 *
 * @param array $actions							array of actions
 * @param array $action['filter']					array containing arrays of action conditions and other data
 * @param array $action['filter']['conditions']		array of action conditions
 * @param array $config								array containing configuration parameters for getting trigger
 *													severity names
 *
 * @return array									returns an array of actions condition string values
 */
function actionConditionValueToString(array $actions, array $config)
{
    $result = [];
    $groupIds = [];
    $triggerIds = [];
    $hostIds = [];
    $templateIds = [];
    $proxyIds = [];
    $dRuleIds = [];
    $dCheckIds = [];
    foreach ($actions as $i => $action) {
        $result[$i] = [];
        foreach ($action['filter']['conditions'] as $j => $condition) {
            // unknown types and all of the default values for other types are 'Unknown'
            $result[$i][$j] = _('Unknown');
            switch ($condition['conditiontype']) {
                case CONDITION_TYPE_HOST_GROUP:
                    $groupIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_TRIGGER:
                    $triggerIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_HOST:
                    $hostIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_TEMPLATE:
                    $templateIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_PROXY:
                    $proxyIds[$condition['value']] = $condition['value'];
                    break;
                    // return values as is for following condition types
                // return values as is for following condition types
                case CONDITION_TYPE_TRIGGER_NAME:
                case CONDITION_TYPE_HOST_METADATA:
                case CONDITION_TYPE_HOST_NAME:
                case CONDITION_TYPE_TIME_PERIOD:
                case CONDITION_TYPE_DHOST_IP:
                case CONDITION_TYPE_DSERVICE_PORT:
                case CONDITION_TYPE_DUPTIME:
                case CONDITION_TYPE_DVALUE:
                case CONDITION_TYPE_APPLICATION:
                    $result[$i][$j] = $condition['value'];
                    break;
                case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
                    $result[$i][$j] = $condition['value'] ? _('Ack') : _('Not Ack');
                    break;
                case CONDITION_TYPE_MAINTENANCE:
                    $result[$i][$j] = _('maintenance');
                    break;
                case CONDITION_TYPE_TRIGGER_VALUE:
                    $result[$i][$j] = trigger_value2str($condition['value']);
                    break;
                case CONDITION_TYPE_TRIGGER_SEVERITY:
                    $result[$i][$j] = getSeverityName($condition['value'], $config);
                    break;
                case CONDITION_TYPE_DRULE:
                    $dRuleIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_DCHECK:
                    $dCheckIds[$condition['value']] = $condition['value'];
                    break;
                case CONDITION_TYPE_DOBJECT:
                    $result[$i][$j] = discovery_object2str($condition['value']);
                    break;
                case CONDITION_TYPE_DSERVICE_TYPE:
                    $result[$i][$j] = discovery_check_type2str($condition['value']);
                    break;
                case CONDITION_TYPE_DSTATUS:
                    $result[$i][$j] = discovery_object_status2str($condition['value']);
                    break;
                case CONDITION_TYPE_EVENT_TYPE:
                    $result[$i][$j] = eventType($condition['value']);
                    break;
            }
        }
    }
    $groups = [];
    $triggers = [];
    $hosts = [];
    $templates = [];
    $proxies = [];
    $dRules = [];
    $dChecks = [];
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:actions.inc.php

示例9: CVar

     break;
 case CONDITION_TYPE_DCHECK:
     $conditionFormList->addItem(new CVar('new_condition[value]', '0'));
     $rowCondition[] = array(new CTextBox('dcheck', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=dchecks&srcfld1=dcheckid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=dcheck&writeonly=1", 450, 450);', 'link_menu'));
     break;
 case CONDITION_TYPE_PROXY:
     $conditionFormList->addItem(new CVar('new_condition[value]', '0'));
     $rowCondition[] = array(new CTextBox('proxy', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=proxies&srcfld1=hostid&srcfld2=host' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=proxy' . '", 450, 450);', 'link_menu'));
     break;
 case CONDITION_TYPE_DHOST_IP:
     $rowCondition[] = new CTextBox('new_condition[value]', '192.168.0.1-127,192.168.2.1', ZBX_TEXTBOX_STANDARD_SIZE);
     break;
 case CONDITION_TYPE_DSERVICE_TYPE:
     $conditionValueComboBox = new CComboBox('new_condition[value]');
     foreach (array(SVC_SSH, SVC_LDAP, SVC_SMTP, SVC_FTP, SVC_HTTP, SVC_POP, SVC_NNTP, SVC_IMAP, SVC_TCP, SVC_AGENT, SVC_SNMPv1, SVC_SNMPv2c, SVC_SNMPv3, SVC_ICMPPING) as $svc) {
         $conditionValueComboBox->addItem($svc, discovery_check_type2str($svc));
     }
     $rowCondition[] = $conditionValueComboBox;
     break;
 case CONDITION_TYPE_DSERVICE_PORT:
     $rowCondition[] = new CTextBox('new_condition[value]', '0-1023,1024-49151', ZBX_TEXTBOX_STANDARD_SIZE);
     break;
 case CONDITION_TYPE_DSTATUS:
     $conditionValueComboBox = new CComboBox('new_condition[value]');
     foreach (array(DOBJECT_STATUS_UP, DOBJECT_STATUS_DOWN, DOBJECT_STATUS_DISCOVER, DOBJECT_STATUS_LOST) as $stat) {
         $conditionValueComboBox->addItem($stat, discovery_object_status2str($stat));
     }
     $rowCondition[] = $conditionValueComboBox;
     break;
 case CONDITION_TYPE_DOBJECT:
     $conditionValueComboBox = new CComboBox('new_condition[value]');
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:configuration.action.edit.php

示例10: array

     $class = 'enabled';
     $time = 'lastup';
     if (DHOST_STATUS_DISABLED == $dhost['status']) {
         $class = 'disabled';
         $time = 'lastdown';
     }
     $discovery_info[$dhost['ip']] = array('class' => $class, 'host' => $dhost['host'], 'time' => $dhost[$time], 'druleid' => $dhost['druleid']);
     $db_dservices = DBselect('SELECT type,port,key_,status,lastup,lastdown FROM dservices ' . ' WHERE dhostid=' . $dhost['dhostid'] . ' order by status,type,port');
     while ($dservice = DBfetch($db_dservices)) {
         $class = 'active';
         $time = 'lastup';
         if (DSVC_STATUS_DISABLED == $dservice['status']) {
             $class = 'inactive';
             $time = 'lastdown';
         }
         $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . (empty($dservice['key_']) ? '' : ':' . $dservice['key_']);
         $discovery_info[$dhost['ip']]['services'][$service_name] = array('class' => $class, 'time' => $dservice[$time]);
     }
 }
 if ($druleid == 0 && !empty($discovery_info)) {
     $col = new CCol(array(bold($drule['name']), SPACE . '(' . count($discovery_info) . SPACE . S_ITEMS . ')'));
     $col->setColSpan(count($services) + 3);
     $table->addRow(array(get_node_name_by_elid($drule['druleid']), $col));
 }
 foreach ($discovery_info as $ip => $h_data) {
     $table_row = array(get_node_name_by_elid($h_data['druleid']), new CSpan($ip, $h_data['class']), new CSpan(empty($h_data['host']) ? '-' : $h_data['host']), new CSpan($h_data['time'] == 0 ? '' : convert_units(time() - $h_data['time'], 'uptime'), $h_data['class']));
     foreach ($services as $name => $foo) {
         $class = null;
         $time = SPACE;
         $hint = new CDiv(SPACE, $class);
         $hintTable = new CTableInfo();
开发者ID:phedders,项目名称:zabbix,代码行数:31,代码来源:discovery.php

示例11: validate_condition

function validate_condition($conditiontype, $value)
{
    global $USER_DETAILS;
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $groups = CHostGroup::get(array('groupids' => $value, 'output' => API_OUTPUT_SHORTEN, 'nodeids' => get_current_nodeid(true)));
            if (empty($groups)) {
                error(S_INCORRECT_GROUP);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST_TEMPLATE:
            $templates = CTemplate::get(array('templateids' => $value, 'output' => API_OUTPUT_SHORTEN, 'nodeids' => get_current_nodeid(true)));
            if (empty($templates)) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER:
            $triggers = CTrigger::get(array('triggerids' => $value, 'output' => API_OUTPUT_SHORTEN, 'nodeids' => get_current_nodeid(true)));
            if (empty($triggers)) {
                error(S_INCORRECT_TRIGGER);
                return false;
            }
            break;
        case CONDITION_TYPE_HOST:
            $hosts = CHost::get(array('hostids' => $value, 'output' => API_OUTPUT_SHORTEN, 'nodeids' => get_current_nodeid(true)));
            if (empty($hosts)) {
                error(S_INCORRECT_HOST);
                return false;
            }
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            if (!validate_period($value)) {
                error(S_INCORRECT_PERIOD . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DHOST_IP:
            if (!validate_ip_range($value)) {
                error(S_INCORRECT_IP . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            if (S_UNKNOWN == discovery_check_type2str($value)) {
                error(S_INCORRECT_DISCOVERY_CHECK);
                return false;
            }
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            if (!validate_port_list($value)) {
                error(S_INCORRECT_PORT . ' [' . $value . ']');
                return false;
            }
            break;
        case CONDITION_TYPE_DSTATUS:
            if (S_UNKNOWN == discovery_object_status2str($value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            if (S_UNKNOWN == condition_value2str($conditiontype, $value)) {
                error(S_INCORRECT_DISCOVERY_STATUS);
                return false;
            }
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_TRIGGER_VALUE:
        case CONDITION_TYPE_TRIGGER_SEVERITY:
        case CONDITION_TYPE_MAINTENANCE:
        case CONDITION_TYPE_NODE:
        case CONDITION_TYPE_DRULE:
        case CONDITION_TYPE_DCHECK:
        case CONDITION_TYPE_DOBJECT:
        case CONDITION_TYPE_PROXY:
        case CONDITION_TYPE_DUPTIME:
        case CONDITION_TYPE_DVALUE:
        case CONDITION_TYPE_APPLICATION:
        case CONDITION_TYPE_HOST_NAME:
            break;
        default:
            error(S_INCORRECT_CONDITION_TYPE);
            return false;
            break;
    }
    return true;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:89,代码来源:actions.inc.php

示例12: discovery_check2str

function discovery_check2str($type, $snmp_community, $key_, $port)
{
    $external_param = '';
    switch ($type) {
        case SVC_SNMPv1:
        case SVC_SNMPv2:
        case SVC_SNMPv3:
        case SVC_AGENT:
            $external_param = ' "' . $key_ . '"';
            break;
    }
    $result = discovery_check_type2str($type);
    if (svc_default_port($type) != $port || $type == SVC_TCP) {
        $result .= ' (' . $port . ')';
    }
    $result .= $external_param;
    return $result;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:18,代码来源:discovery.inc.php

示例13: validateConditions

 /**
  * Validate conditions.
  *
  * @static
  * @param $conditions
  * @return bool
  */
 public static function validateConditions($conditions)
 {
     $conditions = zbx_toArray($conditions);
     $hostGroupidsAll = array();
     $templateidsAll = array();
     $triggeridsAll = array();
     $hostidsAll = array();
     $discoveryRuleidsAll = array();
     $discoveryCheckidsAll = array();
     $proxyidsAll = array();
     $discoveryCheckTypes = discovery_check_type2str();
     $discoveryObjectStatuses = discovery_object_status2str();
     $timePeriodValidator = new CTimePeriodValidator();
     foreach ($conditions as $condition) {
         switch ($condition['conditiontype']) {
             case CONDITION_TYPE_HOST_GROUP:
                 $hostGroupidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_HOST_TEMPLATE:
                 $templateidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_TRIGGER:
                 $triggeridsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_HOST:
                 $hostidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_DRULE:
                 $discoveryRuleidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_DCHECK:
                 $discoveryCheckidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_PROXY:
                 $proxyidsAll[$condition['value']] = $condition['value'];
                 break;
             case CONDITION_TYPE_TIME_PERIOD:
                 if (!$timePeriodValidator->validate($condition['value'])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition period "%s".', $condition['value']));
                 }
                 break;
             case CONDITION_TYPE_DHOST_IP:
                 if (!validate_ip_range($condition['value'])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition ip "%s".', $condition['value']));
                 }
                 break;
             case CONDITION_TYPE_DSERVICE_TYPE:
                 if (!isset($discoveryCheckTypes[$condition['value']])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery check.'));
                 }
                 break;
             case CONDITION_TYPE_DSERVICE_PORT:
                 if (!validate_port_list($condition['value'])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition port "%s".', $condition['value']));
                 }
                 break;
             case CONDITION_TYPE_DSTATUS:
                 if (!isset($discoveryObjectStatuses[$condition['value']])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery status.'));
                 }
                 break;
             case CONDITION_TYPE_MAINTENANCE:
                 // maintenance condition has no value...
                 break;
             case CONDITION_TYPE_TRIGGER_NAME:
             case CONDITION_TYPE_TRIGGER_VALUE:
             case CONDITION_TYPE_TRIGGER_SEVERITY:
             case CONDITION_TYPE_NODE:
             case CONDITION_TYPE_DOBJECT:
             case CONDITION_TYPE_DUPTIME:
             case CONDITION_TYPE_DVALUE:
             case CONDITION_TYPE_APPLICATION:
             case CONDITION_TYPE_HOST_NAME:
                 if (zbx_empty($condition['value'])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                 }
                 break;
             default:
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition type.'));
                 break;
         }
     }
     if (!API::HostGroup()->isWritable($hostGroupidsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host group. Host group does not exist or you have no access to it.'));
     }
     if (!API::Host()->isWritable($hostidsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host. Host does not exist or you have no access to it.'));
     }
     if (!API::Template()->isWritable($templateidsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition template. Template does not exist or you have no access to it.'));
     }
     if (!API::Trigger()->isWritable($triggeridsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition trigger. Trigger does not exist or you have no access to it.'));
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CAction.php

示例14: get_history_of_discovery_events

function get_history_of_discovery_events($end_time, $limit, &$last_clock = null)
{
    $table = new CTableInfo(S_NO_EVENTS_FOUND);
    $table->setHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
    $col = 0;
    $clock = array();
    $dsc_events = array();
    $sql = 'SELECT DISTINCT e.source,e.object,e.objectid,e.clock,e.value ' . ' FROM events e' . ' WHERE e.source=' . EVENT_SOURCE_DISCOVERY . ' AND e.clock<' . $end_time . ' ORDER BY e.clock DESC';
    $db_events = DBselect($sql, $limit);
    while ($event_data = DBfetch($db_events)) {
        switch ($event_data['object']) {
            case EVENT_OBJECT_DHOST:
                $sql = 'SELECT ip FROM dhosts WHERE dhostid=' . $event_data['objectid'];
                if ($object_data = DBfetch(DBselect($sql))) {
                    $event_data['object_data'] = $object_data;
                } else {
                    $event_data['object_data']['ip'] = S_UNKNOWN;
                }
                $event_data['description'] = SPACE;
                break;
            case EVENT_OBJECT_DSERVICE:
                $sql = 'SELECT h.ip,s.type,s.port ' . ' FROM dhosts h,dservices s ' . ' WHERE h.dhostid=s.dhostid ' . ' AND s.dserviceid=' . $event_data['objectid'];
                if ($object_data = DBfetch(DBselect($sql))) {
                    $event_data['object_data'] = $object_data;
                } else {
                    $event_data['object_data']['ip'] = S_UNKNOWN;
                    $event_data['object_data']['type'] = S_UNKNOWN;
                    $event_data['object_data']['port'] = S_UNKNOWN;
                }
                $event_data['description'] = S_SERVICE . ': ' . discovery_check_type2str($event_data['object_data']['type']) . '; ' . S_PORT . ': ' . $event_data['object_data']['port'];
                break;
            default:
                continue;
        }
        if (!isset($event_data['object_data'])) {
            continue;
        }
        $clock[] = $event_data['clock'];
        $dsc_events[] = $event_data;
    }
    $last_clock = !empty($clock) ? min($clock) : null;
    order_page_result($dsc_events, 'clock', ZBX_SORT_DOWN);
    foreach ($dsc_events as $num => $event_data) {
        $value = new CCol(trigger_value2str($event_data['value']), get_trigger_value_style($event_data['value']));
        $table->addRow(array(date('Y.M.d H:i:s', $event_data['clock']), $event_data['object_data']['ip'], $event_data['description'], $value));
    }
    return $table;
}
开发者ID:phedders,项目名称:zabbix,代码行数:48,代码来源:events.inc.php

示例15: order_result

    $data['proxies'] = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND));
    order_result($data['proxies'], 'host');
    // render view
    $discoveryView = new CView('configuration.discovery.edit', $data);
    $discoveryView->render();
    $discoveryView->show();
} else {
    $data = array();
    // get drules
    $data['drules'] = API::DRule()->get(array('output' => API_OUTPUT_EXTEND, 'sortfield' => getPageSortField('name'), 'selectDChecks' => API_OUTPUT_EXTEND, 'editable' => true));
    if (!empty($data['drules'])) {
        foreach ($data['drules'] as $druleid => $drule) {
            // checks
            $checks = array();
            foreach ($drule['dchecks'] as $check) {
                $checks[$check['type']] = discovery_check_type2str($check['type']);
            }
            order_result($checks);
            $data['drules'][$druleid]['checks'] = $checks;
            // description
            $data['drules'][$druleid]['description'] = array();
            if (!empty($drule['proxy_hostid'])) {
                $proxy = get_host_by_hostid($drule['proxy_hostid']);
                array_push($data['drules'][$druleid]['description'], $proxy['host'] . NAME_DELIMITER);
            }
        }
        order_result($data['drules'], getPageSortOrder());
    }
    // get paging
    $data['paging'] = getPagingLine($data['drules'], array('druleid'));
    // nodes
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:discoveryconf.php


注:本文中的discovery_check_type2str函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。