• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP id2nodeid函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: execute_script

function execute_script($scriptid, $hostid)
{
    $res = 1;
    $command = script_make_command($scriptid, $hostid);
    $nodeid = id2nodeid($hostid);
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    if (!$socket) {
        $res = 0;
    }
    if ($res) {
        global $ZBX_SERVER, $ZBX_SERVER_PORT;
        $res = socket_connect($socket, $ZBX_SERVER, $ZBX_SERVER_PORT);
    }
    if ($res) {
        $send = "Command­{$nodeid}­{$hostid}­{$command}\n";
        socket_write($socket, $send);
    }
    if ($res) {
        $res = socket_read($socket, 65535);
    }
    if ($res) {
        list($flag, $msg) = split("­", $res);
        $message["flag"] = $flag;
        $message["message"] = $msg;
    } else {
        $message["flag"] = -1;
        $message["message"] = S_CONNECT_TO_SERVER_ERROR . ' [' . $ZBX_SERVER . ':' . $ZBX_SERVER_PORT . '] [' . socket_strerror(socket_last_error()) . ']';
    }
    if ($socket) {
        socket_close($socket);
    }
    return $message;
}
开发者ID:rennhak,项目名称:zabbix,代码行数:33,代码来源:scripts.inc.php


示例2: __construct

 public function __construct($groupid = 0, $style = STYLE_HORISONTAL)
 {
     $this->nodeid = id2nodeid($groupid);
     $this->groupid = $groupid;
     $this->style = null;
     parent::__construct(null, 'hosts_info');
     $this->setOrientation($style);
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:8,代码来源:class.chostsinfo.php


示例3: __construct

 public function __construct($groupid = 0, $style = STYLE_HORISONTAL)
 {
     $this->nodeid = id2nodeid($groupid);
     $this->groupid = $groupid;
     $this->style = null;
     parent::CTable(NULL, "hosts_info");
     $this->SetOrientation($style);
 }
开发者ID:rennhak,项目名称:zabbix,代码行数:8,代码来源:class.chostsinfo.php


示例4: make_latest_issues

function make_latest_issues($params = array())
{
    global $USER_DETAILS;
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array());
    $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts);
    $config = select_config();
    $sql_select = '';
    $sql_from = '';
    $sql_where = '';
    $limit = 20;
    if (!empty($params)) {
        if (isset($params['limit'])) {
            $limit = $params['limit'];
        }
        if (isset($params['groupid']) && $params['groupid'] > 0) {
            $sql_select .= ',g.name ';
            $sql_from .= ',groups g ';
            $sql_where .= ' AND g.groupid=hg.groupid ' . ' AND hg.groupid=' . $params['groupid'];
        }
        if (isset($params['hostid']) && $params['hostid'] > 0) {
            $sql_where .= ' AND h.hostid=' . $params['hostid'];
        }
    }
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, isset($params['groupid']) && $params['groupid'] > 0 ? S_GROUP : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
    $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . $sql_select . ' FROM triggers t,hosts h,items i,functions f,hosts_groups hg ' . $sql_from . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . $sql_where . ' ORDER BY t.lastchange DESC';
    $result = DBselect($sql, $limit);
    while ($row = DBfetch($result)) {
        // Check for dependencies
        if (trigger_dependent($row["triggerid"])) {
            continue;
        }
        $host = null;
        $menus = '';
        $host_nodeid = id2nodeid($row['hostid']);
        foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) {
            $script_nodeid = id2nodeid($script['scriptid']);
            if (bccomp($host_nodeid, $script_nodeid) == 0) {
                $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
            }
        }
        $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
        $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=0&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        $menus = rtrim($menus, ',');
        $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);";
        $host = new CSpan($row['host'], 'link');
        $host->setAttribute('onclick', 'javascript: ' . $menus);
        $host->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';");
        $event_sql = 'SELECT DISTINCT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type, t.url ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
        $res_events = DBSelect($event_sql, 1);
        while ($row_event = DBfetch($res_events)) {
            $ack = NULL;
            if ($config['event_ack_enable']) {
                if ($row_event['acknowledged'] == 1) {
                    $ack_info = make_acktab_by_eventid($row_event['eventid']);
                    $ack_info->setAttribute('style', 'width: auto;');
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'], 'action');
                    $ack->setHint($ack_info);
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'], 'on');
                }
            }
            //			$description = expand_trigger_description($row['triggerid']);
            $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT);
            //actions
            $actions = get_event_actions_stat_hints($row_event['eventid']);
            $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'events.php?triggerid=' . $row['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock'], 'action');
            if ($row_event['url']) {
                $description = new CLink($description, $row_event['url'], 'action', null, true);
            } else {
                $description = new CSpan($description, 'pointer');
            }
            $description = new CCol($description, get_severity_style($row["priority"]));
            $description->setHint(make_popup_eventlist($row_event['eventid'], $row['type']));
            $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions));
        }
        unset($row, $description, $actions, $alerts, $hint);
    }
    $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time())));
    return $table;
}
开发者ID:phedders,项目名称:zabbix,代码行数:82,代码来源:blocks.inc.php


示例5: access_deny

$dbGraph = API::Graph()->get(array('graphids' => $_REQUEST['graphid'], 'output' => API_OUTPUT_EXTEND, 'expandName' => 1));
//    _ex($dbGraph,0);
if (!$dbGraph) {
    access_deny();
} else {
    $dbGraph = reset($dbGraph);
}
$host = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'graphids' => $_REQUEST['graphid'], 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => true));
$host = reset($host);
/*
 * Display
 */
$timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime')));
CProfile::update('web.screens.graphid', $_REQUEST['graphid'], PROFILE_TYPE_ID);
$chartHeader = '';
if (id2nodeid($dbGraph['graphid']) != get_current_nodeid()) {
    $chartHeader = get_node_name_by_elid($dbGraph['graphid'], true, NAME_DELIMITER);
}
$chartHeader .= $host['name'] . NAME_DELIMITER . $dbGraph['name'];
$graph = new CLineGraphDraw_Zabbix($dbGraph['graphtype']);
$graph->setHeader($chartHeader);
$graph->setPeriod($timeline['period']);
$graph->setSTime($timeline['stime']);
if (isset($_REQUEST['border'])) {
    $graph->setBorder(0);
}
$width = get_request('width', 0);
if ($width <= 0) {
    $width = $dbGraph['width'];
}
$height = get_request('height', 0);
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:zabbix_chart.php


示例6: in_node

function in_node($id_var, $nodes = null)
{
    if (is_null($nodes)) {
        $nodes = get_current_nodeid();
    }
    if (empty($nodes)) {
        $nodes = 0;
    }
    if (zbx_numeric($nodes)) {
        $nodes = array($nodes);
    } else {
        if (is_string($nodes)) {
            if (!eregi('([0-9\\,]+)', $nodes)) {
                fatal_error('Incorrect "nodes" for "in_node". Passed [' . $nodes . ']');
            }
            $nodes = explode(',', $nodes);
        } else {
            if (!is_array($nodes)) {
                fatal_error('Incorrect type of "nodes" for "in_node". Passed [' . gettype($nodes) . ']');
            }
        }
    }
    return uint_in_array(id2nodeid($id_var), $nodes);
}
开发者ID:rennhak,项目名称:zabbix,代码行数:24,代码来源:db.inc.php


示例7: condition_value2str

function condition_value2str($conditiontype, $value)
{
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $group = get_hostgroup_by_groupid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true);
            }
            $str_val .= $group['name'];
            break;
        case CONDITION_TYPE_TRIGGER:
            $str_val = expand_trigger_description($value);
            break;
        case CONDITION_TYPE_HOST:
        case CONDITION_TYPE_HOST_TEMPLATE:
            $host = get_host_by_hostid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true);
            }
            $str_val .= $host['host'];
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $str_val = trigger_value2str($value);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $str_val = get_severity_description($value);
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $str_val = $value;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $str_val = S_MAINTENANCE_SMALL;
            break;
        case CONDITION_TYPE_DHOST_IP:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $str_val = discovery_check_type2str($value);
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSTATUS:
            $str_val = discovery_object_status2str($value);
            break;
        case CONDITION_TYPE_DUPTIME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DVALUE:
            $str_val = $value;
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            $str_val = $value ? S_ACK : S_NOT_ACK;
            break;
        case CONDITION_TYPE_APPLICATION:
            $str_val = $value;
            break;
        default:
            return S_UNKNOWN;
            break;
    }
    return '"' . $str_val . '"';
}
开发者ID:rennhak,项目名称:zabbix,代码行数:68,代码来源:actions.inc.php


示例8: condition_value2str

function condition_value2str($conditiontype, $value)
{
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $groups = API::HostGroup()->get(array('groupids' => $value, 'output' => array('name'), 'nodeids' => get_current_nodeid(true), 'limit' => 1));
            if ($groups) {
                $group = reset($groups);
                $str_val = '';
                if (id2nodeid($value) != get_current_nodeid()) {
                    $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER);
                }
                $str_val .= $group['name'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_TRIGGER:
            $trigs = API::Trigger()->get(array('triggerids' => $value, 'expandDescription' => true, 'output' => array('description'), 'selectHosts' => array('name'), 'nodeids' => get_current_nodeid(true), 'limit' => 1));
            if ($trigs) {
                $trig = reset($trigs);
                $host = reset($trig['hosts']);
                $str_val = '';
                if (id2nodeid($value) != get_current_nodeid()) {
                    $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER);
                }
                $str_val .= $host['name'] . NAME_DELIMITER . $trig['description'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_HOST:
        case CONDITION_TYPE_TEMPLATE:
            if ($host = get_host_by_hostid($value)) {
                $str_val = '';
                if (id2nodeid($value) != get_current_nodeid()) {
                    $str_val = get_node_name_by_elid($value, true, NAME_DELIMITER);
                }
                $str_val .= $host['name'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_HOST_METADATA:
        case CONDITION_TYPE_HOST_NAME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $str_val = trigger_value2str($value);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $str_val = getSeverityCaption($value);
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $str_val = $value;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $str_val = _('maintenance');
            break;
        case CONDITION_TYPE_NODE:
            if ($node = get_node_by_nodeid($value)) {
                $str_val = $node['name'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_DRULE:
            if ($drule = get_discovery_rule_by_druleid($value)) {
                $str_val = $drule['name'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_DCHECK:
            $row = DBfetch(DBselect('SELECT dr.name,c.dcheckid,c.type,c.key_,c.ports' . ' FROM drules dr,dchecks c' . ' WHERE dr.druleid=c.druleid' . ' AND c.dcheckid=' . zbx_dbstr($value)));
            if ($row) {
                $str_val = $row['name'] . NAME_DELIMITER . discovery_check2str($row['type'], $row['key_'], $row['ports']);
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_DOBJECT:
            $str_val = discovery_object2str($value);
            break;
        case CONDITION_TYPE_PROXY:
            if ($host = get_host_by_hostid($value)) {
                $str_val = $host['host'];
            } else {
                return _('Unknown');
            }
            break;
        case CONDITION_TYPE_DHOST_IP:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $str_val = discovery_check_type2str($value);
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $str_val = $value;
            break;
//.........这里部分代码省略.........
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:actions.inc.php


示例9: array

 $params = array('nodeids' => get_current_nodeid(true), 'templateids' => $templateids, 'editable' => 1);
 $rw_templates = CTemplate::get($params);
 $rw_templates = zbx_toHash($rw_templates, 'templateid');
 $params = array('nodeids' => get_current_nodeid(true), 'search' => array('host' => $search), 'countOutput' => 1, 'editable' => 1);
 $overalCount = CTemplate::get($params);
 $viewCount = count($templates);
 $header = array(ZBX_DISTRIBUTED ? new CCol(S_NODE) : null, new CCol(S_TEMPLATES), new CCol(S_APPLICATIONS), new CCol(S_ITEMS), new CCol(S_TRIGGERS), new CCol(S_GRAPHS));
 $table = new CTableInfo();
 $table->setHeader($header);
 foreach ($templates as $tnum => $template) {
     $templateid = $template['hostid'];
     $group = reset($template['groups']);
     $link = 'groupid=' . $group['groupid'] . '&hostid=' . $templateid . '&switch_node=' . id2nodeid($templateid);
     $caption = make_decoration($template['host'], $search);
     if (isset($rw_templates[$templateid])) {
         $template_link = new CLink($caption, 'templates.php?form=update&' . '&templateid=' . $templateid . '&switch_node=' . id2nodeid($templateid));
         $applications_link = array(new CLink(S_APPLICATIONS, 'applications.php?' . $link), ' (' . $template['applications'] . ')');
         $items_link = array(new CLink(S_ITEMS, 'items.php?' . $link), ' (' . $template['items'] . ')');
         $triggers_link = array(new CLink(S_TRIGGERS, 'triggers.php?' . $link), ' (' . $template['triggers'] . ')');
         $graphs_link = array(new CLink(S_GRAPHS, 'graphs.php?' . $link), ' (' . $template['graphs'] . ')');
     } else {
         $template_link = new CSpan($caption);
         $applications_link = array(new CSpan(S_APPLICATIONS, 'unknown'), ' (' . $template['applications'] . ')');
         $items_link = array(new CSpan(S_ITEMS, 'unknown'), ' (' . $template['items'] . ')');
         $triggers_link = array(new CSpan(S_TRIGGERS, 'unknown'), ' (' . $template['triggers'] . ')');
         $graphs_link = array(new CSpan(S_GRAPHS, 'unknown'), ' (' . $template['graphs'] . ')');
     }
     $table->addRow(array(get_node_name_by_elid($templateid, true), $template_link, $applications_link, $items_link, $triggers_link, $graphs_link));
 }
 $table->setFooter(new CCol(S_DISPLAYING . SPACE . $viewCount . SPACE . S_OF_SMALL . SPACE . $overalCount . SPACE . S_FOUND_SMALL));
 $wdgt_templates = new CWidget('search_templates', $table);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:search.php


示例10: get_node_name_by_elid

function get_node_name_by_elid($objectId, $forceWithAllNodes = null, $delimiter = '')
{
    global $ZBX_NODES, $ZBX_VIEWED_NODES;
    if ($forceWithAllNodes === false || is_null($forceWithAllNodes) && $ZBX_VIEWED_NODES['selected'] != 0) {
        return null;
    }
    $nodeId = id2nodeid($objectId);
    if (!isset($ZBX_NODES[$nodeId])) {
        return null;
    }
    return $ZBX_NODES[$nodeId]['name'] . $delimiter;
}
开发者ID:itnihao,项目名称:Zabbix_,代码行数:12,代码来源:nodes.inc.php


示例11: in_node

function in_node($id_var, $nodes = null)
{
    if (is_null($nodes)) {
        $nodes = get_current_nodeid();
    }
    if (empty($nodes)) {
        $nodes = 0;
    }
    if (zbx_ctype_digit($nodes)) {
        $nodes = array($nodes);
    } elseif (is_string($nodes)) {
        if (!preg_match('/^([0-9,]+)$/', $nodes)) {
            fatal_error('Incorrect "nodes" for "in_node". Passed [' . $nodes . ']');
        }
        $nodes = explode(',', $nodes);
    } elseif (!is_array($nodes)) {
        fatal_error('Incorrect type of "nodes" for "in_node". Passed [' . gettype($nodes) . ']');
    }
    return uint_in_array(id2nodeid($id_var), $nodes);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:20,代码来源:db.inc.php


示例12: make_latest_issues

function make_latest_issues($filter = array())
{
    global $page;
    $config = select_config();
    $limit = isset($filter['limit']) ? $filter['limit'] : 20;
    $options = array('groupids' => $filter['groupids'], 'monitored' => 1, 'maintenance' => $filter['maintenance'], 'skipDependent' => 1, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'select_groups' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'lastchange', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $limit);
    if (isset($filter['hostids'])) {
        $options['hostids'] = $filter['hostids'];
    }
    $triggers = CTrigger::get($options);
    // GATHER HOSTS FOR SELECTED TRIGGERS {{{
    $triggers_hosts = array();
    foreach ($triggers as $tnum => $trigger) {
        // if trigger is lost(broken expression) we skip it
        if (empty($trigger['hosts'])) {
            unset($triggers[$tnum]);
            continue;
        }
        $triggers_hosts = array_merge($triggers_hosts, $trigger['hosts']);
    }
    $triggers_hosts = zbx_toHash($triggers_hosts, 'hostid');
    $triggers_hostids = array_keys($triggers_hosts);
    // }}} GATHER HOSTS FOR SELECTED TRIGGERS
    $scripts_by_hosts = CScript::getScriptsByHosts($triggers_hostids);
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
    $thosts_cache = array();
    foreach ($triggers as $tnum => $trigger) {
        // Check for dependencies
        $group = reset($trigger['groups']);
        $host = reset($trigger['hosts']);
        $trigger['hostid'] = $host['hostid'];
        $trigger['host'] = $host['host'];
        $host = null;
        $menus = '';
        $host_nodeid = id2nodeid($trigger['hostid']);
        foreach ($scripts_by_hosts[$trigger['hostid']] as $id => $script) {
            $script_nodeid = id2nodeid($script['scriptid']);
            if (bccomp($host_nodeid, $script_nodeid) == 0) {
                $menus .= "[" . zbx_jsvalue($script['name']) . ",\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $trigger['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
            }
        }
        if (!empty($scripts_by_hosts)) {
            $menus = "['" . S_TOOLS . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus;
        }
        if (isset($thosts_cache[$trigger['hostid']])) {
            $hprofile = $thosts_cache[$trigger['hostid']];
        } else {
            $hprofile = CHost::get(array('hostids' => $trigger['hostid'], 'output' => API_OUTPUT_SHORTEN, 'select_profile' => API_OUTPUT_EXTEND));
            $hprofile = reset($hprofile);
            $thosts_cache[$hprofile['hostid']] = $hprofile;
        }
        $menus .= "['" . S_LINKS . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
        $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=" . $group['groupid'] . '&hostid=' . $trigger['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        if (!empty($hprofile['profile'])) {
            $menus .= "['" . S_PROFILE . "',\"javascript: redirect('hostprofiles.php?hostid=" . $trigger['hostid'] . "&prof_type=0')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        }
        if (!empty($hprofile['profile_ext'])) {
            $menus .= "['" . S_EXTENDED_PROFILE . "',\"javascript: redirect('hostprofiles.php?hostid=" . $trigger['hostid'] . "&prof_type=1')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        }
        $menus = rtrim($menus, ',');
        $menus = 'show_popup_menu(event,[' . $menus . '],180);';
        $host = new CSpan($trigger['host'], 'link_menu pointer');
        $host->setAttribute('onclick', 'javascript: ' . $menus);
        //$host = new CSpan($trigger['host'],'link_menu pointer');
        //$host->setAttribute('onclick','javascript: '.$menus);
        // Maintenance {{{
        $trigger_host = $triggers_hosts[$trigger['hostid']];
        $text = null;
        $style = 'link_menu';
        if ($trigger_host['maintenance_status']) {
            $style .= ' orange';
            $options = array('maintenanceids' => $trigger_host['maintenanceid'], 'output' => API_OUTPUT_EXTEND);
            $maintenances = CMaintenance::get($options);
            $maintenance = reset($maintenances);
            $text = $maintenance['name'];
            $text .= ' [' . ($trigger_host['maintenance_type'] ? S_NO_DATA_MAINTENANCE : S_NORMAL_MAINTENANCE) . ']';
        }
        $host = new CSpan($trigger['host'], $style . ' pointer');
        $host->setAttribute('onclick', 'javascript: ' . $menus);
        if (!is_null($text)) {
            $host->setHint($text, '', '', false);
        }
        // }}} Maintenance
        $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged' . ' FROM events e' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND e.objectid=' . $trigger['triggerid'] . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
        $res_events = DBSelect($event_sql, 1);
        while ($row_event = DBfetch($res_events)) {
            $ack = NULL;
            if ($config['event_ack_enable']) {
                if ($row_event['acknowledged'] == 1) {
                    $ack_info = make_acktab_by_eventid($row_event['eventid']);
                    $ack_info->setAttribute('style', 'width: auto;');
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'off');
                    $ack->setHint($ack_info, '', '', false);
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'on');
                }
            }
            //			$description = expand_trigger_description($row['triggerid']);
            $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT);
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:blocks.inc.php


示例13: checkInput

 protected function checkInput(&$users, $method)
 {
     $create = $method === 'create';
     $update = $method === 'update';
     if ($update) {
         $userDBfields = array('userid' => null);
         $dbUsers = $this->get(array('output' => array('userid', 'alias', 'autologin', 'autologout'), 'userids' => zbx_objectValues($users, 'userid'), 'editable' => true, 'preservekeys' => true));
     } else {
         $userDBfields = array('alias' => null, 'passwd' => null, 'usrgrps' => null, 'user_medias' => array());
     }
     $themes = array_keys(Z::getThemes());
     $themes[] = THEME_DEFAULT;
     $themeValidator = new CSetValidator(array('values' => $themes));
     $alias = array();
     foreach ($users as &$user) {
         if (!check_db_fields($userDBfields, $user)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Wrong fields for user "%s".', $user['alias']));
         }
         // permissions
         if ($create) {
             if (self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to create users.'));
             }
             $dbUser = $user;
         } elseif ($update) {
             if (!isset($dbUsers[$user['userid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to update user or user does not exist.'));
             }
             if (bccomp(self::$userData['userid'], $user['userid']) != 0 && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('You do not have permissions to update other users.'));
             }
             $dbUser = $dbUsers[$user['userid']];
         }
         // check if user alias
         if (isset($user['alias'])) {
             // check if we change guest user
             if ($dbUser['alias'] === ZBX_GUEST_USER && $user['alias'] !== ZBX_GUEST_USER) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot rename guest user.'));
             }
             if (!isset($alias[$user['alias']])) {
                 $alias[$user['alias']] = $update ? $user['userid'] : 1;
             } else {
                 if ($create || bccomp($user['userid'], $alias[$user['alias']]) != 0) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate user alias "%s".', $user['alias']));
                 }
             }
             if (zbx_strlen($user['alias']) > 64) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _n('Maximum alias length is %1$d characters, "%2$s" is %3$d character.', 'Maximum alias length is %1$d characters, "%2$s" is %3$d characters.', 64, $user['alias'], zbx_strlen($user['alias'])));
             }
         }
         if (isset($user['usrgrps'])) {
             if (empty($user['usrgrps'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('User "%s" cannot be without user group.', $dbUser['alias']));
             }
             // checking if user tries to disable himself (not allowed). No need to check this on creating a user.
             if (!$create && bccomp(self::$userData['userid'], $user['userid']) == 0) {
                 $usrgrps = API::UserGroup()->get(array('usrgrpids' => zbx_objectValues($user['usrgrps'], 'usrgrpid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'nopermissions' => true));
                 foreach ($usrgrps as $groupid => $group) {
                     if ($group['gui_access'] == GROUP_GUI_ACCESS_DISABLED) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('User may not modify GUI access for himself by becoming a member of user group "%s".', $group['name']));
                     }
                     if ($group['users_status'] == GROUP_STATUS_DISABLED) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('User may not modify system status for himself by becoming a member of user group "%s".', $group['name']));
                     }
                 }
             }
         }
         if (isset($user['theme'])) {
             $themeValidator->messageInvalid = _s('Incorrect theme for user "%1$s".', $dbUser['alias']);
             $this->checkValidator($user['theme'], $themeValidator);
         }
         if (isset($user['type']) && USER_TYPE_SUPER_ADMIN != self::$userData['type']) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('You are not allowed to alter privileges for user "%s".', $dbUser['alias']));
         }
         if (isset($user['autologin']) && $user['autologin'] == 1 && $dbUser['autologout'] != 0) {
             $user['autologout'] = 0;
         }
         if (isset($user['autologout']) && $user['autologout'] > 0 && $dbUser['autologin'] != 0) {
             $user['autologin'] = 0;
         }
         if (array_key_exists('passwd', $user)) {
             if (is_null($user['passwd'])) {
                 unset($user['passwd']);
             } else {
                 if ($dbUser['alias'] == ZBX_GUEST_USER && !zbx_empty($user['passwd'])) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Not allowed to set password for user "guest".'));
                 }
                 $user['passwd'] = md5($user['passwd']);
             }
         }
         if (isset($user['alias'])) {
             $nodeids = $update ? id2nodeid($user['userid']) : get_current_nodeid(false);
             $userExist = $this->get(array('nodeids' => $nodeids, 'filter' => array('alias' => $user['alias']), 'nopermissions' => true));
             if ($exUser = reset($userExist)) {
                 if ($create || bccomp($exUser['userid'], $user['userid']) != 0) {
                     self::exception(ZBX_API_ERROR_PARAMETERS, _s('User with alias "%s" already exists.', $user['alias']));
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:CUser.php


示例14: condition_value2str

function condition_value2str($conditiontype, $value)
{
    switch ($conditiontype) {
        case CONDITION_TYPE_HOST_GROUP:
            $group = get_hostgroup_by_groupid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $group['name'];
            break;
        case CONDITION_TYPE_TRIGGER:
            $trig = CTrigger::get(array('triggerids' => $value, 'expandTriggerDescriptions' => true, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'nodeids' => get_current_nodeid(true)));
            $trig = reset($trig);
            $host = reset($trig['hosts']);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $host['host'] . ':' . $trig['description'];
            break;
        case CONDITION_TYPE_HOST:
        case CONDITION_TYPE_HOST_TEMPLATE:
            $host = get_host_by_hostid($value);
            $str_val = '';
            if (id2nodeid($value) != get_current_nodeid()) {
                $str_val = get_node_name_by_elid($value, true, ': ');
            }
            $str_val .= $host['host'];
            break;
        case CONDITION_TYPE_TRIGGER_NAME:
        case CONDITION_TYPE_HOST_NAME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_TRIGGER_VALUE:
            $str_val = trigger_value2str($value);
            break;
        case CONDITION_TYPE_TRIGGER_SEVERITY:
            $str_val = get_severity_description($value);
            break;
        case CONDITION_TYPE_TIME_PERIOD:
            $str_val = $value;
            break;
        case CONDITION_TYPE_MAINTENANCE:
            $str_val = S_MAINTENANCE_SMALL;
            break;
        case CONDITION_TYPE_NODE:
            $node = get_node_by_nodeid($value);
            $str_val = $node['name'];
            break;
        case CONDITION_TYPE_DRULE:
            $drule = get_discovery_rule_by_druleid($value);
            $str_val = $drule['name'];
            break;
        case CONDITION_TYPE_DCHECK:
            $row = DBfetch(DBselect('SELECT DISTINCT r.name,c.dcheckid,c.type,c.key_,c.snmp_community,c.ports' . ' FROM drules r,dchecks c WHERE r.druleid=c.druleid AND c.dcheckid=' . $value));
            $str_val = $row['name'] . ':' . discovery_check2str($row['type'], $row['snmp_community'], $row['key_'], $row['ports']);
            break;
        case CONDITION_TYPE_DOBJECT:
            $str_val = discovery_object2str($value);
            break;
        case CONDITION_TYPE_PROXY:
            $host = get_host_by_hostid($value);
            $str_val = $host['host'];
            break;
        case CONDITION_TYPE_DHOST_IP:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSERVICE_TYPE:
            $str_val = discovery_check_type2str($value);
            break;
        case CONDITION_TYPE_DSERVICE_PORT:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DSTATUS:
            $str_val = discovery_object_status2str($value);
            break;
        case CONDITION_TYPE_DUPTIME:
            $str_val = $value;
            break;
        case CONDITION_TYPE_DVALUE:
            $str_val = $value;
            break;
        case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
            $str_val = $value ? S_ACK : S_NOT_ACK;
            break;
        case CONDITION_TYPE_APPLICATION:
            $str_val = $value;
            break;
        default:
            return S_UNKNOWN;
            break;
    }
    return '"' . $str_val . '"';
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:95,代码来源:actions.inc.php


示例15: explode_exp

function explode_exp($expressionCompressed, $html = false, $resolveMacro = false, $sourceHost = null, $destinationHost = null)
{
    $expressionExpanded = $html ? array() : '';
    $trigger = array();
    for ($i = 0, $state = '', $max = zbx_strlen($expressionCompressed); $i < $max; $i++) {
        if ($expressionCompressed[$i] == '{') {
            if ($expressionCompressed[$i + 1] == '$') {
                $state = 'USERMACRO';
                $userMacro = '';
            } elseif ($expressionCompressed[$i + 1] == '#') {
                $state = 'LLDMACRO';
                $lldMacro = '';
            } else {
                $state = 'FUNCTIONID';
                $functionId = '';
                continue;
            }
        } elseif ($expressionCompressed[$i] == '}') {
            if ($state == 'USERMACRO') {
                $state = '';
                $userMacro .= '}';
                if ($resolveMacro) {
                    $functionData['expression'] = $userMacro;
                    $userMacro = CMacrosResolverHelper::resolveTriggerExpressionUserMacro($functionData);
                }
                if ($html) {
                    $expressionExpanded[] = $userMacro;
                } else {
                    $expressionExpanded .= $userMacro;
                }
                continue;
            } elseif ($state == 'LLDMACRO') {
                $state = '';
                $lldMacro .= '}';
                if ($html) {
                    $expressionExpanded[] = $lldMacro;
                } else {
                    $expressionExpanded .= $lldMacro;
                }
                continue;
            } elseif ($functionId == 'TRIGGER.VALUE') {
                $state = '';
                if ($html) {
                    $expressionExpanded[] = '{' . $functionId . '}';
                } else {
                    $expressionExpanded .= '{' . $functionId . '}';
                }
                continue;
            }
            $state = '';
            $error = true;
            if (is_numeric($functionId)) {
                $functionData = DBfetch(DBselect('SELECT h.host,h.hostid,i.itemid,i.key_,f.function,f.triggerid,f.parameter,i.itemid,i.status,i.type,i.flags' . ' FROM items i,functions f,hosts h' . ' WHERE f.functionid=' . zbx_dbstr($functionId) . ' AND i.itemid=f.itemid' . ' AND h.hostid=i.hostid'));
                if ($functionData) {
                    $error = false;
                    if ($resolveMacro) {
                        $trigger = $functionData;
                        // expand macros in item key
                        $items = CMacrosResolverHelper::resolveItemKeys(array($functionData));
                        $item = reset($items);
                        $functionData['key_'] = $item['key_expanded'];
                        // expand macros in function parameter
                        $functionParameters = CMacrosResolverHelper::resolveFunctionParameters(array($functionData));
                        $functionParameter = reset($functionParameters);
                        $functionData['parameter'] = $functionParameter['parameter_expanded'];
                    }
                    if ($sourceHost !== null && $destinationHost !== null && $sourceHost === $functionData['host']) {
                        $functionData['host'] = $destinationHost;
                    }
                    if ($html) {
                        if ($functionData['status'] == ITEM_STATUS_DISABLED) {
                            $style = 'disabled';
                        } elseif ($functionData['status'] == ITEM_STATUS_ACTIVE) {
                            $style = 'enabled';
                        } else {
                            $style = 'unknown';
                        }
                        if ($functionData['flags'] == ZBX_FLAG_DISCOVERY_CREATED || $functionData['type'] == ITEM_TYPE_HTTPTEST) {
                            $link = new CSpan($functionData['host'] . ':' . $functionData['key_'], $style);
                        } elseif ($functionData['flags'] == ZBX_FLAG_DISCOVERY_PROTOTYPE) {
                            $link = new CLink($functionData['host'] . ':' . $functionData['key_'], 'disc_prototypes.php?form=update&itemid=' . $functionData['itemid'] . '&parent_discoveryid=' . $trigger['discoveryRuleid'] . '&switch_node=' . id2nodeid($functionData['itemid']), $style);
                        } else {
                            $link = new CLink($functionData['host'] . ':' . $functionData['key_'], 'items.php?form=update&itemid=' . $functionData['itemid'] . '&switch_node=' . id2nodeid($functionData['itemid']), $style);
                        }
                        $expressionExpanded[] = array('{', $link, '.', bold($functionData['function'] . '('), $functionData['parameter'], bold(')'), '}');
                    } else {
                        $expressionExpanded .= '{' . $functionData['host'] . ':' . $functionData['key_'] . '.' . $functionData['function'] . '(' . $functionData['parameter'] . ')}';
                    }
                }
            }
            if ($error) {
                if ($html) {
                    $expressionExpanded[] = new CSpan('*ERROR*', 'on');
                } else {
                    $expressionExpanded .= '*ERROR*';
                }
            }
            continue;
        }
        switch ($state) {
//.........这里部分代码省略.........
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:triggers.inc.php


示例16: executeScript

 /**
  * Executes a script on the given host and returns the result.
  *
  * @param $scriptId
  * @param $hostId
  *
  * @return bool|array
  */
 public function executeScript($scriptId, $hostId)
 {
     return $this->request(array('request' => 'command', 'nodeid' => id2nodeid($hostId), 'scriptid' => $scriptI 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP idFederal2int函数代码示例发布时间:2022-05-15
下一篇:
PHP id函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap