本文整理汇总了PHP中get_current_nodeid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_current_nodeid函数的具体用法?PHP get_current_nodeid怎么用?PHP get_current_nodeid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_current_nodeid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bodyToString
public function bodyToString()
{
$this->cleanItems();
$total = 0;
// fetch accessible host ids
$hosts = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'output' => array('hostid'), 'preservekeys' => true));
$hostIds = array_keys($hosts);
if (remove_nodes_from_id($this->groupid) > 0) {
$cond_from = ',hosts_groups hg';
$cond_where = ' AND hg.hostid=h.hostid AND hg.groupid=' . zbx_dbstr($this->groupid);
} else {
$cond_from = '';
$cond_where = andDbNode('h.hostid', $this->nodeid);
}
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$avail = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$notav = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) AS cnt' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND ' . dbConditionInt('h.hostid', $hostIds) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$uncn = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$node = get_node_by_nodeid($this->nodeid);
$header_str = _('Hosts info') . SPACE;
if ($node > 0) {
$header_str .= '(' . $node['name'] . ')' . SPACE;
}
if (remove_nodes_from_id($this->groupid) > 0) {
$group = get_hostgroup_by_groupid($this->groupid);
$header_str .= _('Group') . SPACE . '"' . $group['name'] . '"';
} else {
$header_str .= _('All groups');
}
$header = new CCol($header_str, 'header');
if ($this->style == STYLE_HORISONTAL) {
$header->setColspan(4);
}
$this->addRow($header);
$avail = new CCol($avail . ' ' . _('Available'), 'avail');
$notav = new CCol($notav . ' ' . _('Not available'), 'notav');
$uncn = new CCol($uncn . ' ' . _('Unknown'), 'uncn');
$total = new CCol($total . ' ' . _('Total'), 'total');
if ($this->style == STYLE_HORISONTAL) {
$this->addRow(array($avail, $notav, $uncn, $total));
} else {
$this->addRow($avail);
$this->addRow($notav);
$this->addRow($uncn);
$this->addRow($total);
}
return parent::bodyToString();
}
示例2: get_events_unacknowledged
function get_events_unacknowledged($db_element, $value_trigger = null, $value_event = null, $ack = false)
{
$elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array());
get_map_elements($db_element, $elements);
if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) {
return 0;
}
$config = select_config();
$options = array('nodeids' => get_current_nodeid(), 'output' => API_OUTPUT_SHORTEN, 'monitored' => 1, 'skipDependent' => 1, 'limit' => $config['search_limit'] + 1);
if (!is_null($value_trigger)) {
$options['filter'] = array('value' => $value_trigger);
}
if (!empty($elements['hosts_groups'])) {
$options['groupids'] = array_unique($elements['hosts_groups']);
}
if (!empty($elements['hosts'])) {
$options['hostids'] = array_unique($elements['hosts']);
}
if (!empty($elements['triggers'])) {
$options['triggerids'] = array_unique($elements['triggers']);
}
$triggerids = CTrigger::get($options);
$options = array('countOutput' => 1, 'triggerids' => zbx_objectValues($triggerids, 'triggerid'), 'object' => EVENT_OBJECT_TRIGGER, 'acknowledged' => $ack ? 1 : 0, 'value' => is_null($value_event) ? array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE) : $value_event, 'nopermissions' => 1);
$event_count = CEvent::get($options);
return $event_count;
}
示例3: slideshow_accessible
function slideshow_accessible($slideshowid, $perm)
{
$result = false;
$sql = 'SELECT s.slideshowid' . ' FROM slideshows s' . ' WHERE s.slideshowid=' . zbx_dbstr($slideshowid) . andDbNode('s.slideshowid', get_current_nodeid(null, $perm));
if (DBselect($sql)) {
$result = true;
$screenids = array();
$db_screens = DBselect('SELECT DISTINCT s.screenid' . ' FROM slides s' . ' WHERE s.slideshowid=' . zbx_dbstr($slideshowid));
while ($slide_data = DBfetch($db_screens)) {
$screenids[$slide_data['screenid']] = $slide_data['screenid'];
}
$options = array('screenids' => $screenids);
if ($perm == PERM_READ_WRITE) {
$options['editable'] = true;
}
$screens = API::Screen()->get($options);
$screens = zbx_toHash($screens, 'screenid');
foreach ($screenids as $screenid) {
if (!isset($screens[$screenid])) {
return false;
}
}
}
return $result;
}
示例4: getImageByIdent
function getImageByIdent($ident)
{
zbx_value2array($ident);
if (!isset($ident['name'])) {
return 0;
}
static $images;
if (is_null($images)) {
$images = array();
$dbImages = API::Image()->get(array('output' => array('imageid', 'name'), 'nodeids' => get_current_nodeid(true)));
foreach ($dbImages as $image) {
if (!isset($images[$image['name']])) {
$images[$image['name']] = array();
}
$nodeName = get_node_name_by_elid($image['imageid'], true);
if (!is_null($nodeName)) {
$images[$image['name']][$nodeName] = $image;
} else {
$images[$image['name']][] = $image;
}
}
}
$ident['name'] = trim($ident['name'], ' ');
if (!isset($images[$ident['name']])) {
return 0;
}
$searchedImages = $images[$ident['name']];
if (!isset($ident['node'])) {
return reset($searchedImages);
} elseif (isset($searchedImages[$ident['node']])) {
return $searchedImages[$ident['node']];
} else {
return 0;
}
}
示例5: init
/**
* Initializes nodes.
*
* @static
*/
public static function init()
{
global $ZBX_LOCALNODEID;
if (is_null(self::$nodeId)) {
self::$nodeId = get_current_nodeid(false);
self::$minNodeId = bcadd(bcmul(self::$nodeId, '100000000000000'), bcmul($ZBX_LOCALNODEID, '100000000000'), 0);
self::$maxNodeId = bcadd(self::$minNodeId, '99999999999', 0);
}
}
示例6: bodyToString
public function bodyToString()
{
global $USER_DETAILS;
$this->cleanItems();
$total = 0;
$accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
$cond_from = '';
if (remove_nodes_from_id($this->groupid) > 0) {
$cond_from = ', hosts_groups hg ';
$cond_where = 'AND hg.hostid=h.hostid AND hg.groupid=' . $this->groupid;
} else {
$cond_where = ' AND ' . DBin_node('h.hostid', $this->nodeid);
}
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_TRUE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$avail = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_FALSE . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$notav = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$db_host_cnt = DBselect('SELECT COUNT(DISTINCT h.hostid) as cnt ' . ' FROM hosts h' . $cond_from . ' WHERE h.available=' . HOST_AVAILABLE_UNKNOWN . ' AND h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ') ' . ' AND ' . DBcondition('h.hostid', $accessible_hosts) . $cond_where);
$host_cnt = DBfetch($db_host_cnt);
$uncn = $host_cnt['cnt'];
$total += $host_cnt['cnt'];
$node = get_node_by_nodeid($this->nodeid);
$header_str = S_HOSTS_INFO . SPACE;
$header_str .= S_FOR_GROUP_SMALL . SPACE . '"';
if ($node > 0) {
$header_str .= '(' . $node['name'] . ')' . SPACE;
}
if (remove_nodes_from_id($this->groupid) > 0) {
$group = get_hostgroup_by_groupid($this->groupid);
$header_str .= $group['name'] . '"';
} else {
$header_str .= S_ALL_S . '"';
}
$header = new CCol($header_str, "header");
if ($this->style == STYLE_HORISONTAL) {
$header->SetColspan(4);
}
$this->addRow($header);
$avail = new CCol($avail . ' ' . S_AVAILABLE, 'avail');
$notav = new CCol($notav . ' ' . S_NOT_AVAILABLE, 'notav');
$uncn = new CCol($uncn . ' ' . S_UNKNOWN, 'uncn');
$total = new CCol($total . ' ' . S_TOTAL, 'total');
if ($this->style == STYLE_HORISONTAL) {
$this->addRow(array($avail, $notav, $uncn, $total));
} else {
$this->addRow($avail);
$this->addRow($notav);
$this->addRow($uncn);
$this->addRow($total);
}
return parent::bodyToString();
}
示例7: get_events_unacknowledged
function get_events_unacknowledged($db_element, $value_trigger = null, $value_event = null, $ack = false)
{
$elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array());
get_map_elements($db_element, $elements);
if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) {
return 0;
}
$config = select_config();
$options = array('nodeids' => get_current_nodeid(), 'output' => array('triggerid'), 'monitored' => 1, 'skipDependent' => 1, 'limit' => $config['search_limit'] + 1);
if (!is_null($value_trigger)) {
$options['filter'] = array('value' => $value_trigger);
}
if (!empty($elements['hosts_groups'])) {
$options['groupids'] = array_unique($elements['hosts_groups']);
}
if (!empty($elements['hosts'])) {
$options['hostids'] = array_unique($elements['hosts']);
}
if (!empty($elements['triggers'])) {
$options['triggerids'] = array_unique($elements['triggers']);
}
$triggerids = API::Trigger()->get($options);
return API::Event()->get(array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'countOutput' => true, 'objectids' => zbx_objectValues($triggerids, 'triggerid'), 'filter' => array('value' => $value_event, 'acknowledged' => $ack ? 1 : 0)));
}
示例8: sysmap_accessible
function sysmap_accessible($sysmapid, $perm)
{
global $USER_DETAILS;
$nodes = get_current_nodeid(null, $perm);
$result = (bool) count($nodes);
$sql = 'SELECT * ' . ' FROM sysmaps_elements ' . ' WHERE sysmapid=' . $sysmapid . ' AND ' . DBin_node('sysmapid', $nodes);
$db_result = DBselect($sql);
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
//SDI($available_hosts);
while (($se_data = DBfetch($db_result)) && $result) {
switch ($se_data['elementtype']) {
case SYSMAP_ELEMENT_TYPE_HOST:
if (!isset($available_hosts[$se_data['elementid']])) {
$result = false;
}
break;
case SYSMAP_ELEMENT_TYPE_MAP:
$result = sysmap_accessible($se_data['elementid'], $perm);
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$available_triggers = get_accessible_triggers($perm, array(), PERM_RES_IDS_ARRAY);
if (!isset($available_triggers[$se_data['elementid']])) {
$result = false;
}
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$available_groups = get_accessible_groups_by_user($USER_DETAILS, $perm);
if (!isset($available_groups[$se_data['elementid']])) {
$result = false;
}
break;
}
}
//SDI($se_data['elementid']);
return $result;
}
示例9: make_hoststat_summary
function make_hoststat_summary($filter)
{
$table = new CTableInfo(_('No host groups found.'));
$table->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host group'), _('Without problems'), _('With problems'), _('Total')));
// get host groups
$groups = API::HostGroup()->get(array('nodeids' => get_current_nodeid(), 'groupids' => $filter['groupids'], 'monitored_hosts' => 1, 'output' => array('groupid', 'name')));
$groups = zbx_toHash($groups, 'groupid');
foreach ($groups as &$group) {
$group['nodename'] = get_node_name_by_elid($group['groupid']);
}
unset($group);
CArrayHelper::sort($groups, array(array('field' => 'nodename', 'order' => ZBX_SORT_UP), array('field' => 'name', 'order' => ZBX_SORT_UP)));
// get hosts
$hosts = API::Host()->get(array('nodeids' => get_current_nodeid(), 'groupids' => zbx_objectValues($groups, 'groupid'), 'hostids' => !empty($filter['hostids']) ? $filter['hostids'] : null, 'monitored_hosts' => true, 'filter' => array('maintenance_status' => $filter['maintenance']), 'output' => array('hostid', 'name'), 'selectGroups' => array('groupid')));
$hosts = zbx_toHash($hosts, 'hostid');
CArrayHelper::sort($hosts, array('name'));
// get triggers
$triggers = API::Trigger()->get(array('nodeids' => get_current_nodeid(), 'monitored' => true, 'maintenance' => $filter['maintenance'], 'expandData' => true, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => array('triggerid', 'priority'), 'selectHosts' => array('hostid')));
if ($filter['extAck']) {
$triggers_unack = API::Trigger()->get(array('nodeids' => get_current_nodeid(), 'monitored' => true, 'maintenance' => $filter['maintenance'], 'withLastEventUnacknowledged' => true, 'selectHosts' => API_OUTPUT_REFER, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => API_OUTPUT_REFER));
$triggers_unack = zbx_toHash($triggers_unack, 'triggerid');
foreach ($triggers_unack as $tunack) {
foreach ($tunack['hosts'] as $unack_host) {
$hosts_with_unack_triggers[$unack_host['hostid']] = $unack_host['hostid'];
}
}
}
$hosts_data = array();
$problematic_host_list = array();
$lastUnack_host_list = array();
$highest_severity = array();
$highest_severity2 = array();
foreach ($triggers as $trigger) {
foreach ($trigger['hosts'] as $trigger_host) {
if (!isset($hosts[$trigger_host['hostid']])) {
continue;
} else {
$host = $hosts[$trigger_host['hostid']];
}
if ($filter['extAck'] && isset($hosts_with_unack_triggers[$host['hostid']])) {
if (!isset($lastUnack_host_list[$host['hostid']])) {
$lastUnack_host_list[$host['hostid']] = array();
$lastUnack_host_list[$host['hostid']]['host'] = $host['name'];
$lastUnack_host_list[$host['hostid']]['hostid'] = $host['hostid'];
$lastUnack_host_list[$host['hostid']]['severities'] = array();
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
$lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
}
if (isset($triggers_unack[$trigger['triggerid']])) {
$lastUnack_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
}
foreach ($host['groups'] as $gnum => $group) {
if (!isset($highest_severity2[$group['groupid']])) {
$highest_severity2[$group['groupid']] = 0;
}
if ($trigger['priority'] > $highest_severity2[$group['groupid']]) {
$highest_severity2[$group['groupid']] = $trigger['priority'];
}
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
}
if (!isset($hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']])) {
$hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']] = $host['hostid'];
$hosts_data[$group['groupid']]['lastUnack']++;
}
}
}
if (!isset($problematic_host_list[$host['hostid']])) {
$problematic_host_list[$host['hostid']] = array();
$problematic_host_list[$host['hostid']]['host'] = $host['name'];
$problematic_host_list[$host['hostid']]['hostid'] = $host['hostid'];
$problematic_host_list[$host['hostid']]['severities'] = array();
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
$problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
}
$problematic_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
foreach ($host['groups'] as $gnum => $group) {
if (!isset($highest_severity[$group['groupid']])) {
$highest_severity[$group['groupid']] = 0;
}
if ($trigger['priority'] > $highest_severity[$group['groupid']]) {
$highest_severity[$group['groupid']] = $trigger['priority'];
}
if (!isset($hosts_data[$group['groupid']])) {
$hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
}
if (!isset($hosts_data[$group['groupid']]['hostids_all'][$host['hostid']])) {
$hosts_data[$group['groupid']]['hostids_all'][$host['hostid']] = $host['hostid'];
$hosts_data[$group['groupid']]['problematic']++;
}
}
}
//.........这里部分代码省略.........
示例10: get
/**
* Get Service data
*
* @param _array $options
* @param array $options['nodeids'] Node IDs
* @param array $options['groupids'] ServiceGroup IDs
* @param array $options['hostids'] Service IDs
* @param boolean $options['monitored_hosts'] only monitored Services
* @param boolean $options['templated_hosts'] include templates in result
* @param boolean $options['with_items'] only with items
* @param boolean $options['with_historical_items'] only with historical items
* @param boolean $options['with_triggers'] only with triggers
* @param boolean $options['with_httptests'] only with http tests
* @param boolean $options['with_graphs'] only with graphs
* @param boolean $options['editable'] only with read-write permission. Ignored for SuperAdmins
* @param boolean $options['selectGroups'] select ServiceGroups
* @param boolean $options['selectTemplates'] select Templates
* @param boolean $options['selectItems'] select Items
* @param boolean $options['selectTriggers'] select Triggers
* @param boolean $options['selectGraphs'] select Graphs
* @param boolean $options['selectApplications'] select Applications
* @param boolean $options['selectMacros'] select Macros
* @param int $options['count'] count Services, returned column name is rowscount
* @param string $options['pattern'] search hosts by pattern in Service name
* @param string $options['extendPattern'] search hosts by pattern in Service name, ip and DNS
* @param int $options['limit'] limit selection
* @param string $options['sortfield'] field to sort by
* @param string $options['sortorder'] sort order
* @return array|boolean Service data as array or false if error
*/
public function get($options = array())
{
$result = array();
$nodeCheck = false;
$userType = self::$userData['type'];
// allowed columns for sorting
$sortColumns = array('dserviceid', 'dhostid', 'ip');
// allowed output options for [ select_* ] params
$subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND, API_OUTPUT_CUSTOM);
$sqlParts = array('select' => array('dservices' => 'ds.dserviceid'), 'from' => array('dservices' => 'dservices ds'), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
$defOptions = array('nodeids' => null, 'dserviceids' => null, 'dhostids' => null, 'dcheckids' => null, 'druleids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectDRules' => null, 'selectDHosts' => null, 'selectDChecks' => null, 'selectHosts' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null, 'limitSelects' => null);
$options = zbx_array_merge($defOptions, $options);
if (is_array($options['output'])) {
unset($sqlParts['select']['dservices']);
$dbTable = DB::getSchema('dservices');
foreach ($options['output'] as $field) {
if (isset($dbTable['fields'][$field])) {
$sqlParts['select'][$field] = 's.' . $field;
}
}
$options['output'] = API_OUTPUT_CUSTOM;
}
// editable + PERMISSION CHECK
if (USER_TYPE_SUPER_ADMIN == $userType) {
} elseif (is_null($options['editable']) && self::$userData['type'] == USER_TYPE_ZABBIX_ADMIN) {
} elseif (!is_null($options['editable']) && self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
return array();
}
// nodeids
$nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
// dserviceids
if (!is_null($options['dserviceids'])) {
zbx_value2array($options['dserviceids']);
$sqlParts['where']['dserviceid'] = dbConditionInt('ds.dserviceid', $options['dserviceids']);
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('ds.dserviceid', $nodeids);
}
}
// dhostids
if (!is_null($options['dhostids'])) {
zbx_value2array($options['dhostids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sqlParts['select']['dhostid'] = 'ds.dhostid';
}
$sqlParts['where'][] = dbConditionInt('ds.dhostid', $options['dhostids']);
if (!is_null($options['groupCount'])) {
$sqlParts['group']['dhostid'] = 'ds.dhostid';
}
if (!$nodeCheck) {
$nodeCheck = true;
$sqlParts['where'][] = DBin_node('ds.dhostid', $nodeids);
}
}
// dcheckids
if (!is_null($options['dcheckids'])) {
zbx_value2array($options['dcheckids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sqlParts['select']['dcheckid'] = 'dc.dcheckid';
}
$sqlParts['from']['dhosts'] = 'dhosts dh';
$sqlParts['from']['dchecks'] = 'dchecks dc';
$sqlParts['where'][] = dbConditionInt('dc.dcheckid', $options['dcheckids']);
$sqlParts['where']['dhds'] = 'dh.hostid=ds.hostid';
$sqlParts['where']['dcdh'] = 'dc.druleid=dh.druleid';
if (!is_null($options['groupCount'])) {
$sqlParts['group']['dcheckid'] = 'dc.dcheckid';
}
}
// druleids
//.........这里部分代码省略.........
示例11: get
/**
* Get history data
*
* {@source}
* @access public
* @static
* @since 1.8.3
* @version 1.3
*
* @param array $options
* @param array $options['itemids']
* @param boolean $options['editable']
* @param string $options['pattern']
* @param int $options['limit']
* @param string $options['order']
* @return array|int item data as array or false if error
*/
public static function get($options = array())
{
global $USER_DETAILS;
$nodeCheck = false;
$result = array();
$sort_columns = array('itemid', 'clock');
// allowed columns for sorting
$subselects_allowed_outputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
// allowed output options for [ select_* ] params
$sql_parts = array('select' => array('history' => 'h.itemid'), 'from' => array(), 'where' => array(), 'group' => array(), 'order' => array(), 'limit' => null);
$def_options = array('history' => ITEM_VALUE_TYPE_UINT64, 'nodeids' => null, 'hostids' => null, 'itemids' => null, 'triggerids' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => null, 'startSearch' => null, 'excludeSearch' => null, 'time_from' => null, 'time_till' => null, 'output' => API_OUTPUT_REFER, 'countOutput' => null, 'groupCount' => null, 'groupOutput' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null);
$options = zbx_array_merge($def_options, $options);
switch ($options['history']) {
case ITEM_VALUE_TYPE_LOG:
$sql_parts['from']['history'] = 'history_log h';
$sort_columns[] = 'id';
break;
case ITEM_VALUE_TYPE_TEXT:
$sql_parts['from']['history'] = 'history_text h';
$sort_columns[] = 'id';
break;
case ITEM_VALUE_TYPE_STR:
$sql_parts['from']['history'] = 'history_str h';
break;
case ITEM_VALUE_TYPE_UINT64:
$sql_parts['from']['history'] = 'history_uint h';
break;
case ITEM_VALUE_TYPE_FLOAT:
default:
$sql_parts['from']['history'] = 'history h';
}
// editable + PERMISSION CHECK
if (USER_TYPE_SUPER_ADMIN == $USER_DETAILS['type'] || $options['nopermissions']) {
} else {
$itemOptions = array('editable' => $options['editable'], 'preservekeys' => 1);
if (!is_null($options['itemids'])) {
$itemOptions['itemids'] = $options['itemids'];
}
$items = CItem::get($itemOptions);
$options['itemids'] = array_keys($items);
}
// nodeids
$nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
// itemids
if (!is_null($options['itemids'])) {
zbx_value2array($options['itemids']);
$sql_parts['where']['itemid'] = DBcondition('h.itemid', $options['itemids']);
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
}
}
// hostids
if (!is_null($options['hostids'])) {
zbx_value2array($options['hostids']);
if ($options['output'] != API_OUTPUT_SHORTEN) {
$sql_parts['select']['hostid'] = 'i.hostid';
}
$sql_parts['from']['items'] = 'items i';
$sql_parts['where']['i'] = DBcondition('i.hostid', $options['hostids']);
$sql_parts['where']['hi'] = 'h.itemid=i.itemid';
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('i.hostid', $nodeids);
}
}
// node check !!!!!
// should be last, after all ****IDS checks
if (!$nodeCheck) {
$nodeCheck = true;
$sql_parts['where'][] = DBin_node('h.itemid', $nodeids);
}
// time_from
if (!is_null($options['time_from'])) {
$sql_parts['select']['clock'] = 'h.clock';
$sql_parts['where']['clock_from'] = 'h.clock>=' . $options['time_from'];
}
// time_till
if (!is_null($options['time_till'])) {
$sql_parts['select']['clock'] = 'h.clock';
$sql_parts['where']['clock_till'] = 'h.clock<=' . $options['time_till'];
}
// filter
//.........这里部分代码省略.........
示例12: array
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
require_once 'include/config.inc.php';
require_once 'include/graphs.inc.php';
$page['file'] = 'chart7.php';
$page['title'] = "S_CHART";
$page['type'] = PAGE_TYPE_IMAGE;
include_once 'include/page_header.php';
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array('period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'from' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'stime' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'name' => array(T_ZBX_STR, O_OPT, NULL, null, null), 'width' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'height' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'graphtype' => array(T_ZBX_INT, O_OPT, NULL, IN('2,3'), null), 'graph3d' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'legend' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'items' => array(T_ZBX_STR, O_OPT, NULL, null, null));
check_fields($fields);
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY, get_current_nodeid(true));
$items = get_request('items', array());
asort_by_key($items, 'sortorder');
foreach ($items as $gitem) {
if (!($host = DBfetch(DBselect('SELECT h.* FROM hosts h,items i WHERE h.hostid=i.hostid AND i.itemid=' . $gitem['itemid'])))) {
fatal_error(S_NO_ITEM_DEFINED);
}
if (!isset($available_hosts[$host['hostid']])) {
access_deny();
}
}
$effectiveperiod = navigation_bar_calc();
if (count($items) == 1) {
$_REQUEST['period'] = get_request('period', get_profile('web.item.graph.period', ZBX_PERIOD_DEFAULT, null, $items['itemid']));
if ($_REQUEST['period'] >= ZBX_MIN_PERIOD) {
update_profile('web.item.graph.period', $_REQUEST['period'], PROFILE_TYPE_INT, $items['itemid']);
示例13: CSpan
$cbFilter->setAttribute('onclick', "create_var('" . $dashForm->getName() . "', 'filterEnable', 0, true);");
} else {
$cbFilter = new CSpan(S_DISABLED, 'red underline pointer');
$cbFilter->setAttribute('onclick', "\$('dashform').enable(); create_var('" . $dashForm->getName() . "', 'filterEnable', 1, true);");
}
$dashForm->addRow(S_DASHBOARD_FILTER, $cbFilter);
$dashForm->addVar('groupids', $groupids);
$cmbGroups = new CComboBox('grpswitch', $grpswitch, 'submit();');
$cmbGroups->addItem(0, S_ALL_S);
$cmbGroups->addItem(1, S_SELECTED);
if (!$filterEnable) {
$cmbGroups->setAttribute('disabled', 'disabled');
}
$dashForm->addRow(S_HOST_GROUPS, $cmbGroups);
if ($grpswitch == 1) {
$options = array('nodeids' => get_current_nodeid(true), 'groupids' => $groupids, 'output' => API_OUTPUT_EXTEND);
$groups = CHostGroup::get($options);
order_result($groups, 'name');
$lstGroups = new CListBox('del_groups[]', null, 15);
$lstGroups->setAttribute('style', 'width: 200px;');
foreach ($groups as $gnum => $group) {
$lstGroups->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], true, ':') . $group['name']);
}
if (!$filterEnable) {
$lstGroups->setAttribute('disabled', 'disabled');
}
$addButton = new CButton('add', S_ADD, "return PopUp('popup_right.php?dstfrm=" . $dashForm->getName() . "&permission=" . PERM_READ_WRITE . "',450,450);");
if (!$filterEnable) {
$addButton->setAttribute('disabled', 'disabled');
}
$delButton = new CButton('delete', S_DELETE_SELECTED);
示例14: array
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
require_once 'include/config.inc.php';
require_once 'include/graphs.inc.php';
$page['file'] = 'chart7.php';
// $page['title'] = "S_CHART";
$page['type'] = PAGE_TYPE_IMAGE;
include_once 'include/page_header.php';
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array('period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'from' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'stime' => array(T_ZBX_INT, O_OPT, P_NZERO, null, null), 'border' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'name' => array(T_ZBX_STR, O_OPT, NULL, null, null), 'width' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'height' => array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0, 65535), null), 'graphtype' => array(T_ZBX_INT, O_OPT, NULL, IN('2,3'), null), 'graph3d' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'legend' => array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null), 'items' => array(T_ZBX_STR, O_OPT, NULL, null, null));
check_fields($fields);
$items = get_request('items', array());
asort_by_key($items, 'sortorder');
$options = array('webitems' => 1, 'itemids' => zbx_objectValues($items, 'itemid'), 'nodeids' => get_current_nodeid(true));
$db_data = CItem::get($options);
$db_data = zbx_toHash($db_data, 'itemid');
foreach ($items as $id => $gitem) {
if (!isset($db_data[$gitem['itemid']])) {
access_deny();
}
}
$effectiveperiod = navigation_bar_calc();
$graph = new CPie(get_request('graphtype', GRAPH_TYPE_NORMAL));
$graph->setHeader(get_request('name', ''));
$graph3d = get_request('graph3d', 0);
$legend = get_request('legend', 0);
if ($graph3d == 1) {
$graph->switchPie3D();
}
示例15: get_triggers_unacknowledged
function get_triggers_unacknowledged($db_element, $count_problems = null, $ack = false)
{
$elements = array('hosts' => array(), 'hosts_groups' => array(), 'triggers' => array());
get_map_elements($db_element, $elements);
if (empty($elements['hosts_groups']) && empty($elements['hosts']) && empty($elements['triggers'])) {
return 0;
}
$config = select_config();
$options = array('nodeids' => get_current_nodeid(), 'monitored' => true, 'countOutput' => true, 'filter' => array(), 'limit' => $config['search_limit'] + 1);
if ($ack) {
$options['withAcknowledgedEvents'] = 1;
} else {
$options['withUnacknowledgedEvents'] = 1;
}
if ($count_problems) {
$options['filter']['value'] = TRIGGER_VALUE_TRUE;
}
if (!empty($elements['hosts_groups'])) {
$options['groupids'] = array_unique($elements['hosts_groups']);
}
if (!empty($elements['hosts'])) {
$options['hostids'] = array_unique($elements['hosts']);
}
if (!empty($elements['triggers'])) {
$options['triggerids'] = array_unique($elements['triggers']);
}
return API::Trigger()->get($options);
}