本文整理汇总了PHP中zbx_toHash函数 的典型用法代码示例。如果您正苦于以下问题:PHP zbx_toHash函数的具体用法?PHP zbx_toHash怎么用?PHP zbx_toHash使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zbx_toHash函数 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Import maps.
*
* @param array $maps
*
* @return void
*/
public function import(array $maps)
{
$maps = zbx_toHash($maps, 'name');
$this->checkCircularMapReferences($maps);
do {
$im = $this->getIndependentMaps($maps);
$mapsToCreate = array();
$mapsToUpdate = array();
foreach ($im as $name) {
$map = $maps[$name];
unset($maps[$name]);
$map = $this->resolveMapReferences($map);
if ($mapId = $this->referencer->resolveMap($map['name'])) {
$map['sysmapid'] = $mapId;
$mapsToUpdate[] = $map;
} else {
$mapsToCreate[] = $map;
}
}
if ($this->options['maps']['createMissing'] && $mapsToCreate) {
$newMapIds = API::Map()->create($mapsToCreate);
foreach ($mapsToCreate as $num => $map) {
$mapId = $newMapIds['sysmapids'][$num];
$this->referencer->addMapRef($map['name'], $mapId);
}
}
if ($this->options['maps']['updateExisting'] && $mapsToUpdate) {
API::Map()->update($mapsToUpdate);
}
} while (!empty($im));
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:38, 代码来源:CMapImporter.php
示例2: validate
/**
* Validates the given condition formula and checks if the given conditions match the formula.
*
* @param array $object
*
* @return bool
*/
public function validate($object)
{
// validate only custom expressions
if ($object['evaltype'] != CONDITION_EVAL_TYPE_EXPRESSION) {
return true;
}
// check if the formula is valid
$parser = new CConditionFormula();
if (!$parser->parse($object['formula'])) {
$this->error($this->messageInvalidFormula, $object['formula'], $parser->error);
return false;
}
// check that all conditions used in the formula are defined in the "conditions" array
$conditions = zbx_toHash($object['conditions'], 'formulaid');
$constants = array_unique(zbx_objectValues($parser->constants, 'value'));
foreach ($constants as $constant) {
if (!array_key_exists($constant, $conditions)) {
$this->error($this->messageMissingCondition, $constant, $object['formula']);
return false;
}
unset($conditions[$constant]);
}
// check that the "conditions" array has no unused conditions
if ($conditions) {
$condition = reset($conditions);
$this->error($this->messageUnusedCondition, $condition['formulaid'], $object['formula']);
return false;
}
return true;
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:37, 代码来源:CConditionValidator.php
示例3: check_permission_for_action_conditions
function check_permission_for_action_conditions($conditions)
{
global $USER_DETAILS;
if (USER_TYPE_SUPER_ADMIN == $USER_DETAILS['type']) {
return true;
}
$groupids = array();
$hostids = array();
$triggerids = array();
foreach ($conditions as $ac_data) {
if ($ac_data['operator'] != 0) {
continue;
}
switch ($ac_data['type']) {
case CONDITION_TYPE_HOST_GROUP:
$groupids[$ac_data['value']] = $ac_data['value'];
break;
case CONDITION_TYPE_HOST:
case CONDITION_TYPE_HOST_TEMPLATE:
$hostids[$ac_data['value']] = $ac_data['value'];
break;
case CONDITION_TYPE_TRIGGER:
$triggerids[$ac_data['value']] = $ac_data['value'];
break;
}
}
$options = array('groupids' => $groupids, 'editable' => 1);
try {
$groups = CHostgroup::get($options);
$groups = zbx_toHash($groups, 'groupid');
foreach ($groupids as $hgnum => $groupid) {
if (!isset($groups[$groupid])) {
throw new Exception(S_INCORRECT_GROUP);
}
}
$options = array('hostids' => $hostids, 'editable' => 1);
$hosts = CHost::get($options);
$hosts = zbx_toHash($hosts, 'hostid');
foreach ($hostids as $hnum => $hostid) {
if (!isset($hosts[$hostid])) {
throw new Exception(S_INCORRECT_HOST);
}
}
$options = array('triggerids' => $triggerids, 'editable' => 1);
$triggers = CTrigger::get($options);
$triggers = zbx_toHash($triggers, 'triggerid');
foreach ($triggerids as $hnum => $triggerid) {
if (!isset($triggers[$triggerid])) {
throw new Exception(S_INCORRECT_TRIGGER);
}
}
} catch (Exception $e) {
// throw new Exception($e->getMessage());
// error($e->getMessage());
return false;
}
return true;
}
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:58, 代码来源:actions.inc.php
示例4: __construct
public function __construct(&$form, $name, $value = null, $size = 10)
{
$this->form =& $form;
$this->name = $name . '_tweenbox';
$this->varname = $name;
$this->value = zbx_toHash($value);
$this->id_l = $this->varname . '_left';
$this->id_r = $this->varname . '_right';
$this->lbox = new CListBox($this->id_l, null, $size);
$this->rbox = new CListBox($this->id_r, null, $size);
$this->lbox->setAttribute('style', 'width: 280px;');
$this->rbox->setAttribute('style', 'width: 280px;');
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:13, 代码来源:CTweenBox.php
示例5: import
/**
* Import maps.
*
* @param array $maps
*
* @return void
*/
public function import(array $maps)
{
$maps = zbx_toHash($maps, 'name');
$this->checkCircularMapReferences($maps);
$maps = $this->resolveMapElementReferences($maps);
/*
* Get all importable maps with removed elements and links. First import maps and then update maps with
* elements and links from import file. This way we make sure we are able to resolve any references
* between maps and links that are imported.
*/
$mapsWithoutElements = $this->getMapsWithoutElements($maps);
$mapsToProcess = array('createMissing' => array(), 'updateExisting' => array());
foreach ($mapsWithoutElements as $mapName => $mapWithoutElements) {
$mapId = $this->referencer->resolveMap($mapWithoutElements['name']);
if ($mapId) {
// Update sysmapid in source map too.
$mapWithoutElements['sysmapid'] = $mapId;
$maps[$mapName]['sysmapid'] = $mapId;
$mapsToProcess['updateExisting'][] = $mapWithoutElements;
} else {
$mapsToProcess['createMissing'][] = $mapWithoutElements;
}
}
if ($this->options['maps']['createMissing'] && $mapsToProcess['createMissing']) {
$newMapIds = API::Map()->create($mapsToProcess['createMissing']);
foreach ($mapsToProcess['createMissing'] as $num => $map) {
$mapId = $newMapIds['sysmapids'][$num];
$this->referencer->addMapRef($map['name'], $mapId);
$maps[$map['name']]['sysmapid'] = $mapId;
}
}
if ($this->options['maps']['updateExisting'] && $mapsToProcess['updateExisting']) {
API::Map()->update($mapsToProcess['updateExisting']);
}
// Form an array of maps that need to be updated with elements and links, respecting the create/update options.
$mapsToUpdate = array();
foreach ($mapsToProcess as $mapActionKey => $mapArray) {
if ($this->options['maps'][$mapActionKey] && $mapsToProcess[$mapActionKey]) {
foreach ($mapArray as $mapItem) {
$map = array('sysmapid' => $maps[$mapItem['name']]['sysmapid'], 'name' => $mapItem['name'], 'selements' => $maps[$mapItem['name']]['selements'], 'links' => $maps[$mapItem['name']]['links']);
$map = $this->resolveMapReferences($map);
// Remove the map name so API does not make an update query to the database.
unset($map['name']);
$mapsToUpdate[] = $map;
}
}
}
if ($mapsToUpdate) {
API::Map()->update($mapsToUpdate);
}
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:58, 代码来源:CMapImporter.php
示例6: __construct
public function __construct(&$form, $name, $value = null, $size = 10)
{
zbx_add_post_js('if (IE7) $$("select option[disabled]").each(function(e) { e.setStyle({color: "gray"}); });');
$this->form =& $form;
$this->name = $name . '_tweenbox';
$this->varname = $name;
$this->value = zbx_toHash($value);
$this->id_l = $this->varname . '_left';
$this->id_r = $this->varname . '_right';
$this->lbox = new CListBox($this->id_l, null, $size);
$this->rbox = new CListBox($this->id_r, null, $size);
$this->lbox->setAttribute('style', 'width: 280px;');
$this->rbox->setAttribute('style', 'width: 280px;');
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:14, 代码来源:class.ctweenbox.php
示例7: doAction
protected function doAction()
{
$filter = ['groupids' => null, 'maintenance' => null, 'severity' => null, 'trigger_name' => '', 'extAck' => 0];
if (CProfile::get('web.dashconf.filter.enable', 0) == 1) {
// groups
if (CProfile::get('web.dashconf.groups.grpswitch', 0) == 0) {
// null mean all groups
$filter['groupids'] = null;
} else {
$filter['groupids'] = zbx_objectValues(CFavorite::get('web.dashconf.groups.groupids'), 'value');
$hideHostGroupIds = zbx_objectValues(CFavorite::get('web.dashconf.groups.hide.groupids'), 'value');
if ($hideHostGroupIds) {
// get all groups if no selected groups defined
if (!$filter['groupids']) {
$dbHostGroups = API::HostGroup()->get(['output' => ['groupid']]);
$filter['groupids'] = zbx_objectValues($dbHostGroups, 'groupid');
}
$filter['groupids'] = array_diff($filter['groupids'], $hideHostGroupIds);
// get available hosts
$dbAvailableHosts = API::Host()->get(['groupids' => $filter['groupids'], 'output' => ['hostid']]);
$availableHostIds = zbx_objectValues($dbAvailableHosts, 'hostid');
$dbDisabledHosts = API::Host()->get(['groupids' => $hideHostGroupIds, 'output' => ['hostid']]);
$disabledHostIds = zbx_objectValues($dbDisabledHosts, 'hostid');
$filter['hostids'] = array_diff($availableHostIds, $disabledHostIds);
} else {
if (!$filter['groupids']) {
// null mean all groups
$filter['groupids'] = null;
}
}
}
// hosts
$maintenance = CProfile::get('web.dashconf.hosts.maintenance', 1);
$filter['maintenance'] = $maintenance == 0 ? 0 : null;
// triggers
$severity = CProfile::get('web.dashconf.triggers.severity', null);
$filter['severity'] = zbx_empty($severity) ? null : explode(';', $severity);
$filter['severity'] = zbx_toHash($filter['severity']);
$filter['trigger_name'] = CProfile::get('web.dashconf.triggers.name', '');
$config = select_config();
$filter['extAck'] = $config['event_ack_enable'] ? CProfile::get('web.dashconf.events.extAck', 0) : 0;
}
$this->setResponse(new CControllerResponseData(['filter' => $filter, 'user' => ['debug_mode' => $this->getDebugMode()]]));
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:44, 代码来源:CControllerWidgetSystemView.php
示例8: validate
/**
* Validates the given condition formula and checks if the given conditions match the formula.
*
* @param array $object
*
* @return bool
*/
public function validate($object)
{
if ($object['evaltype'] == CONDITION_EVAL_TYPE_AND) {
// get triggers count in formula
$trigger_count = 0;
foreach ($object['conditions'] as $condition) {
if (array_key_exists('conditiontype', $condition) && array_key_exists('operator', $condition) && $condition['conditiontype'] == CONDITION_TYPE_TRIGGER && $condition['operator'] == CONDITION_OPERATOR_EQUAL) {
$trigger_count++;
}
}
// check if multiple triggers are compared with AND
if ($trigger_count > 1) {
$this->error($this->messageAndWithSeveralTriggers);
return false;
}
}
// validate only custom expressions
if ($object['evaltype'] != CONDITION_EVAL_TYPE_EXPRESSION) {
return true;
}
// check if the formula is valid
$parser = new CConditionFormula();
if (!$parser->parse($object['formula'])) {
$this->error($this->messageInvalidFormula, $object['formula'], $parser->error);
return false;
}
// check that all conditions used in the formula are defined in the "conditions" array
$conditions = zbx_toHash($object['conditions'], 'formulaid');
$constants = array_unique(zbx_objectValues($parser->constants, 'value'));
foreach ($constants as $constant) {
if (!array_key_exists($constant, $conditions)) {
$this->error($this->messageMissingCondition, $constant, $object['formula']);
return false;
}
unset($conditions[$constant]);
}
// check that the "conditions" array has no unused conditions
if ($conditions) {
$condition = reset($conditions);
$this->error($this->messageUnusedCondition, $condition['formulaid'], $object['formula']);
return false;
}
return true;
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:51, 代码来源:CConditionValidator.php
示例9: import
/**
* Import screens.
*
* @param array $screens
*
* @return mixed
*/
public function import(array $screens)
{
$screens = zbx_toHash($screens, 'name');
$this->checkCircularScreenReferences($screens);
do {
$independentScreens = $this->getIndependentScreens($screens);
$screensToCreate = array();
$screensToUpdate = array();
foreach ($independentScreens as $name) {
$screen = $screens[$name];
unset($screens[$name]);
$screen = $this->resolveScreenReferences($screen);
if ($screenId = $this->referencer->resolveScreen($screen['name'])) {
$screen['screenid'] = $screenId;
$screensToUpdate[] = $screen;
} else {
$screensToCreate[] = $screen;
}
}
if ($this->options['screens']['createMissing'] && $screensToCreate) {
$newScreenIds = API::Screen()->create($screensToCreate);
foreach ($screensToCreate as $num => $newScreen) {
$screenidId = $newScreenIds['screenids'][$num];
$this->referencer->addScreenRef($newScreen['name'], $screenidId);
}
}
if ($this->options['screens']['updateExisting'] && $screensToUpdate) {
API::Screen()->update($screensToUpdate);
}
} while (!empty($independentScreens));
// if there are screens left in $screens, then they have unresolved references
foreach ($screens as $screen) {
$unresolvedReferences = array();
foreach ($screen['screenitems'] as $screenItem) {
if ($screenItem['resourcetype'] == SCREEN_RESOURCE_SCREEN && !$this->referencer->resolveScreen($screenItem['resource']['name'])) {
$unresolvedReferences[] = $screenItem['resource']['name'];
}
}
$unresolvedReferences = array_unique($unresolvedReferences);
throw new Exception(_n('Cannot import screen "%1$s": subscreen "%2$s" does not exist.', 'Cannot import screen "%1$s": subscreens "%2$s" do not exist.', $screen['name'], implode(', ', $unresolvedReferences), count($unresolvedReferences)));
}
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:49, 代码来源:CScreenImporter.php
示例10: array
}
$mapInfo = array();
foreach ($map['selements'] as $selement) {
// if element use icon map and icon map is set for map, and is host like element, we use default icon map icon
if ($map['iconmapid'] && $selement['use_iconmap'] && ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST || $selement['elementtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS)) {
$iconid = $defaultAutoIconId;
} else {
$iconid = $selement['iconid_off'];
}
$mapInfo[$selement['selementid']] = array('iconid' => $iconid, 'icon_type' => SYSMAP_ELEMENT_ICON_OFF);
$mapInfo[$selement['selementid']]['name'] = $selement['elementtype'] == SYSMAP_ELEMENT_TYPE_IMAGE ? _('Image') : $selement['elementName'];
}
$allLinks = true;
} else {
// we need selements to be a hash for further processing
$map['selements'] = zbx_toHash($map['selements'], 'selementid');
add_triggerExpressions($map['selements']);
$areas = populateFromMapAreas($map);
$mapInfo = getSelementsInfo($map, array('severity_min' => get_request('severity_min')));
processAreasCoordinates($map, $areas, $mapInfo);
$allLinks = false;
}
/*
* Draw map
*/
drawMapConnectors($im, $map, $mapInfo, $allLinks);
if (!isset($_REQUEST['noselements'])) {
drawMapHighligts($im, $map, $mapInfo);
drawMapSelements($im, $map, $mapInfo);
}
$expandMacros = get_request('expand_macros', true);
开发者ID:zubayr, 项目名称:zabbix-extras, 代码行数:31, 代码来源:zbxe-customer-logo.php
示例11: get
//.........这里部分代码省略.........
if (!is_null($options['countOutput'])) {
return $result;
}
// Adding Objects
// select_drules
if (!is_null($options['selectDRules'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1);
if (is_array($options['selectDRules']) || str_in_array($options['selectDRules'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectDRules'];
$drules = API::DRule()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($drules, 'name');
}
foreach ($drules as $druleid => $drule) {
unset($drules[$druleid]['dservices']);
$count = array();
foreach ($drule['dservices'] as $dnum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['drules'][] =& $drules[$druleid];
}
}
} elseif (API_OUTPUT_COUNT == $options['selectDRules']) {
$objParams['countOutput'] = 1;
$objParams['groupCount'] = 1;
$drules = API::DRule()->get($objParams);
$drules = zbx_toHash($drules, 'dserviceid');
foreach ($result as $dserviceid => $dservice) {
if (isset($drules[$dserviceid])) {
$result[$dserviceid]['drules'] = $drules[$dserviceid]['rowscount'];
} else {
$result[$dserviceid]['drules'] = 0;
}
}
}
}
// selectDHosts
if (!is_null($options['selectDHosts'])) {
$objParams = array('nodeids' => $nodeids, 'dserviceids' => $dserviceids, 'preservekeys' => 1);
if (is_array($options['selectDHosts']) || str_in_array($options['selectDHosts'], $subselectsAllowedOutputs)) {
$objParams['output'] = $options['selectDHosts'];
$dhosts = API::DHost()->get($objParams);
if (!is_null($options['limitSelects'])) {
order_result($dhosts, 'dhostid');
}
foreach ($dhosts as $dhostid => $dhost) {
unset($dhosts[$dhostid]['dservices']);
foreach ($dhost['dservices'] as $snum => $dservice) {
if (!is_null($options['limitSelects'])) {
if (!isset($count[$dservice['dserviceid']])) {
$count[$dservice['dserviceid']] = 0;
}
$count[$dservice['dserviceid']]++;
if ($count[$dservice['dserviceid']] > $options['limitSelects']) {
continue;
}
}
$result[$dservice['dserviceid']]['dhosts'][] =& $dhosts[$dhostid];
}
开发者ID:quanta-computing, 项目名称:debian-packages, 代码行数:67, 代码来源:CDService.php
示例12: navigation_bar_calc
}
if (getRequest('favobj') === 'timeline' && hasRequest('elementid') && hasRequest('period')) {
navigation_bar_calc('web.hostscreen', getRequest('elementid'), true);
}
if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) {
require_once dirname(__FILE__) . '/include/page_footer.php';
exit;
}
/*
* Display
*/
$data = array('hostid' => getRequest('hostid', 0), 'fullscreen' => $_REQUEST['fullscreen'], 'screenid' => getRequest('screenid', CProfile::get('web.hostscreen.screenid', null)), 'period' => getRequest('period'), 'stime' => getRequest('stime'));
CProfile::update('web.hostscreen.screenid', $data['screenid'], PROFILE_TYPE_ID);
// get screen list
$data['screens'] = API::TemplateScreen()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND));
$data['screens'] = zbx_toHash($data['screens'], 'screenid');
order_result($data['screens'], 'name');
// get screen
$screenid = null;
if (!empty($data['screens'])) {
$screen = !isset($data['screens'][$data['screenid']]) ? reset($data['screens']) : $data['screens'][$data['screenid']];
if (!empty($screen['screenid'])) {
$screenid = $screen['screenid'];
}
}
$data['screen'] = API::TemplateScreen()->get(array('screenids' => $screenid, 'hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND));
$data['screen'] = reset($data['screen']);
// get host
if (!empty($data['screen']['hostid'])) {
$data['host'] = get_host_by_hostid($data['screen']['hostid']);
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:31, 代码来源:host_screen.php
示例13: massUpdate
//.........这里部分代码省略.........
$data['templates_clear'] = isset($data['templates_clear']) ? zbx_toArray($data['templates_clear']) : array();
$cleared_templateids = array();
foreach ($hostids as $hostid) {
foreach ($data['templates_clear'] as $tpl) {
$result = unlink_template($hostid, $tpl['templateid'], false);
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot unlink template [ ' . $tpl['templateid'] . ' ]');
}
$cleared_templateids[] = $tpl['templateid'];
}
}
// UPDATE TEMPLATE LINKAGE {{{
if (isset($data['templates']) && !is_null($data['templates'])) {
$opt = array('hostids' => $hostids, 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => true);
$host_templates = CTemplate::get($opt);
$host_templateids = array_keys($host_templates);
$new_templateids = zbx_objectValues($data['templates'], 'templateid');
$templates_to_del = array_diff($host_templateids, $new_templateids);
$templates_to_del = array_diff($templates_to_del, $cleared_templateids);
if (!empty($templates_to_del)) {
$result = self::massRemove(array('hostids' => $hostids, 'templateids' => $templates_to_del));
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_UNLINK_TEMPLATE);
}
}
$result = self::massAdd(array('hosts' => $hosts, 'templates' => $data['templates']));
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, S_CANNOT_LINK_TEMPLATE);
}
}
// }}} UPDATE TEMPLATE LINKAGE
// UPDATE MACROS {{{
if (isset($data['macros']) && !is_null($data['macros'])) {
$macrosToAdd = zbx_toHash($data['macros'], 'macro');
$hostMacros = CUserMacro::get(array('hostids' => $hostids, 'output' => API_OUTPUT_EXTEND));
$hostMacros = zbx_toHash($hostMacros, 'macro');
// Delete
$macrosToDelete = array();
foreach ($hostMacros as $hmnum => $hmacro) {
if (!isset($macrosToAdd[$hmacro['macro']])) {
$macrosToDelete[] = $hmacro['macro'];
}
}
// Update
$macrosToUpdate = array();
foreach ($macrosToAdd as $nhmnum => $nhmacro) {
if (isset($hostMacros[$nhmacro['macro']])) {
$macrosToUpdate[] = $nhmacro;
unset($macrosToAdd[$nhmnum]);
}
}
//----
if (!empty($macrosToDelete)) {
$result = self::massRemove(array('hostids' => $hostids, 'macros' => $macrosToDelete));
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Can\'t remove macro');
}
}
if (!empty($macrosToUpdate)) {
$result = CUsermacro::massUpdate(array('hosts' => $hosts, 'macros' => $macrosToUpdate));
if (!$result) {
self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot update macro');
}
}
if (!empty($macrosToAdd)) {
$result = self::massAdd(array('hosts' => $hosts, 'macros' => $macrosToAdd));
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:67, 代码来源:class.chost.php
示例14: validateUpdate
/**
* Validates the input parameters for the update() method.
*
* @throws APIException if the input is invalid
*
* @param array $scripts
*/
protected function validateUpdate(array $scripts)
{
if (self::$userData['type'] != USER_TYPE_SUPER_ADMIN) {
self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
}
foreach ($scripts as $script) {
if (empty($script['scriptid'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Invalid method parameters.'));
}
}
$scripts = zbx_toHash($scripts, 'scriptid');
$scriptIds = array_keys($scripts);
$names = array();
$dbScripts = $this->get(array('scriptids' => $scriptIds, 'output' => array('scriptid'), 'preservekeys' => true));
foreach ($scripts as $script) {
if (!isset($dbScripts[$script['scriptid']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Script with scriptid "%1$s" does not exist.', $script['scriptid']));
}
if (isset($script['name'])) {
if (zbx_empty($script['name'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty name for script.'));
}
if (isset($names[$script['name']])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Duplicate script name "%1$s".', $script['name']));
}
$names[$script['name']] = $script['name'];
}
}
if ($names) {
$dbScripts = $this->get(array('output' => array('scriptid', 'name'), 'filter' => array('name' => $names), 'nopermissions' => true, 'preservekeys' => true));
foreach ($dbScripts as $dbScript) {
if (!isset($scripts[$dbScript['scriptid']]) || bccomp($scripts[$dbScript['scriptid']]['scriptid'], $dbScript['scriptid']) != 0) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Script "%1$s" already exists.', $dbScript['name']));
}
}
}
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:44, 代码来源:CScript.php
示例15: addRelatedObjects
public function addRelatedObjects(array $options, array $result)
{
$result = parent::addRelatedObjects($options, $result);
$itemids = array_keys($result);
// adding applications
if ($options['selectApplications'] !== null && $options['selectApplications'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'itemid', 'applicationid', 'items_applications');
$applications = API::Application()->get(array('output' => $options['selectApplications'], 'applicationids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
$result = $relationMap->mapMany($result, $applications, 'applications');
}
// adding interfaces
if ($options['selectInterfaces'] !== null && $options['selectInterfaces'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'itemid', 'interfaceid');
$interfaces = API::HostInterface()->get(array('output' => $options['selectInterfaces'], 'interfaceids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
$result = $relationMap->mapMany($result, $interfaces, 'interfaces');
}
// adding triggers
if (!is_null($options['selectTriggers'])) {
if ($options['selectTriggers'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'itemid', 'triggerid', 'functions');
$triggers = API::Trigger()->get(array('output' => $options['selectTriggers'], 'triggerids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
if (!is_null($options['limitSelects'])) {
order_result($triggers, 'description');
}
$result = $relationMap->mapMany($result, $triggers, 'triggers', $options['limitSelects']);
} else {
$triggers = API::Trigger()->get(array('countOutput' => true, 'groupCount' => true, 'itemids' => $itemids));
$triggers = zbx_toHash($triggers, 'itemid');
foreach ($result as $itemid => $item) {
if (isset($triggers[$itemid])) {
$result[$itemid]['triggers'] = $triggers[$itemid]['rowscount'];
} else {
$result[$itemid]['triggers'] = 0;
}
}
}
}
// adding graphs
if (!is_null($options['selectGraphs'])) {
if ($options['selectGraphs'] != API_OUTPUT_COUNT) {
$relationMap = $this->createRelationMap($result, 'itemid', 'graphid', 'graphs_items');
$graphs = API::Graph()->get(array('output' => $options['selectGraphs'], 'graphids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
if (!is_null($options['limitSelects'])) {
order_result($graphs, 'name');
}
$result = $relationMap->mapMany($result, $graphs, 'graphs', $options['limitSelects']);
} else {
$graphs = API::Graph()->get(array('countOutput' => true, 'groupCount' => true, 'itemids' => $itemids));
$graphs = zbx_toHash($graphs, 'itemid');
foreach ($result as $itemid => $item) {
if (isset($graphs[$itemid])) {
$result[$itemid]['graphs'] = $graphs[$itemid]['rowscount'];
} else {
$result[$itemid]['graphs'] = 0;
}
}
}
}
// adding discoveryrule
if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) {
$relationMap = new CRelationMap();
// discovered items
$dbRules = DBselect('SELECT id1.itemid,id2.parent_itemid' . ' FROM item_discovery id1,item_discovery id2,items i' . ' WHERE ' . dbConditionInt('id1.itemid', $itemids) . ' AND id1.parent_itemid=id2.itemid' . ' AND i.itemid=id1.itemid' . ' AND i.flags=' . ZBX_FLAG_DISCOVERY_CREATED);
while ($rule = DBfetch($dbRules)) {
$relationMap->addRelation($rule['itemid'], $rule['parent_itemid']);
}
// item prototypes
// TODO: this should not be in the item API
$dbRules = DBselect('SELECT id.parent_itemid,id.itemid' . ' FROM item_discovery id,items i' . ' WHERE ' . dbConditionInt('id.itemid', $itemids) . ' AND i.itemid=id.itemid' . ' AND i.flags=' . ZBX_FLAG_DISCOVERY_PROTOTYPE);
while ($rule = DBfetch($dbRules)) {
$relationMap->addRelation($rule['itemid'], $rule['parent_itemid']);
}
$discoveryRules = API::DiscoveryRule()->get(array('output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
$result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
}
// adding item discovery
if ($options['selectItemDiscovery'] !== null) {
$itemDiscoveries = API::getApiService()->select('item_discovery', array('output' => $this->outputExtend($options['selectItemDiscovery'], array('itemdiscoveryid', 'itemid')), 'filter' => array('itemid' => array_keys($result)), 'preservekeys' => true));
$relationMap = $this->createRelationMap($itemDiscoveries, 'itemid', 'itemdiscoveryid');
$itemDiscoveries = $this->unsetExtraFields($itemDiscoveries, array('itemid', 'itemdiscoveryid'), $options['selectItemDiscovery']);
$result = $relationMap->mapOne($result, $itemDiscoveries, 'itemDiscovery');
}
// adding history data
$requestedOutput = array();
if ($this->outputIsRequested('lastclock', $options['output'])) {
$requestedOutput['lastclock'] = true;
}
if ($this->outputIsRequested('lastns', $options['output'])) {
$requestedOutput['lastns'] = true;
}
if ($this->outputIsRequested('lastvalue', $options['output'])) {
$requestedOutput['lastvalue'] = true;
}
if ($this->outputIsRequested('prevvalue', $options['output'])) {
$requestedOutput['prevvalue'] = true;
}
if ($requestedOutput) {
$history = Manager::History()->getLast($result, 2, ZBX_HISTORY_PERIOD);
foreach ($result as &$item) {
$lastHistory = isset($history[$item['itemid']][0]) ? $history[$item['itemid']][0] : null;
//.........这里部分代码省略.........
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:101, 代码来源:CItem.php
示例16: array
** 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();
}
$graph->showLegend($legend);
unset($host);
开发者ID:songyuanjie, 项目名称:zabbix-stats, 代码行数:31, 代码来源:chart7.php
示例17: make_screen_submenu
function make_screen_submenu()
{
$favScreens = array();
$fav_screens = CFavorite::get('web.favorite.screenids');
if (!$fav_screens) {
return $favScreens;
}
$screenids = array();
foreach ($fav_screens as $favorite) {
if ('screenid' == $favorite['source']) {
$screenids[$favorite['value']] = $favorite['value'];
}
}
$options = array('screenids' => $screenids, 'output' => array('screenid', 'name'));
$screens = API::Screen()->get($options);
$screens = zbx_toHash($screens, 'screenid');
foreach ($fav_screens as $favorite) {
$source = $favorite['source'];
$sourceid = $favorite['value'];
if ('slideshowid' == $source) {
if (!slideshow_accessible($sourceid, PERM_READ)) {
continue;
}
if (!($slide = get_slideshow_by_slideshowid($sourceid))) {
continue;
}
$slide_added = true;
$favScreens[] = array('name' => $slide['name'], 'favobj' => 'slideshowid', 'favid' => $slide['slideshowid'], 'favaction' => 'remove');
} else {
if (!isset($screens[$sourceid])) {
continue;
}
$screen = $screens[$sourceid];
$screen_added = true;
$favScreens[] = array('name' => $screen['name'], 'favobj' => 'screenid', 'favid' => $screen['screenid'], 'favaction' => 'remove');
}
}
if (isset($screen_added)) {
$favScreens[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Screens'), 'favobj' => 'screenid', 'favid' => 0, 'favaction' => 'remove');
}
if (isset($slide_added)) {
$favScreens[] = array('name' => _('Remove') . ' ' . _('All') . ' ' . _('Slides'), 'favobj' => 'slideshowid', 'favid' => 0, 'favaction' => 'remove');
}
return $favScreens;
}
开发者ID:SandipSingh14, 项目名称:Zabbix_, 代码行数:45, 代码来源:blocks.inc.php
示例18: resolveTriggerExpressionUserMacro
/**
* Resolve user macros in trigger expression.
*
* @static
*
* @param array $trigger
* @param array $trigger['triggerid']
* @param array $trigger['expression']
*
* @return string
*/
public static function resolveTriggerExpressionUserMacro(array $trigger)
{
if (zbx_empty($trigger['expression'])) {
return $trigger['expression'];
}
self::init();
$triggers = self::$macrosResolver->resolve(array('config' => 'triggerExpressionUser', 'data' => zbx_toHash(array($trigger), 'triggerid')));
$trigger = reset($triggers);
return $trigger['expression'];
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:21, 代码来源:CMacrosResolverHelper.php
GitbookIO/gitbook:
阅读:959| 2022-08-17
juleswhite/mobile-cloud-asgn1
阅读:1032| 2022-08-30
kyamagu/matlab-json: Use official API: https://mathworks.com/help/matlab/json-fo
阅读:927| 2022-08-17
书名:墙壁眼睛膝盖 作者:温柔一刀 类别:欲望丛林,饮食男女。 簡介:Wall(我)Eye(爱)Kn
阅读:657| 2022-11-06
sevenjay/cpp-markdown: Cpp-Markdown is a freely-available Markdown text-to-HTML
阅读:583| 2022-08-18
第一步、准备邮箱 如果只是个人想体验一下小程序,直接用自己的QQ邮箱就行,但是这样
阅读:1023| 2022-07-18
1.icon 图标组件,可自定义其类型、大小和颜色。
type 图标类型
size
阅读:545| 2022-07-18
Out-of-bounds Read in GitHub repository vim/vim prior to 9.0.
阅读:685| 2022-07-08
mathjax/MathJax-i18n: MathJax localization
阅读:389| 2022-08-16
google/guava: Google core libraries for Java
阅读:527| 2022-08-14
请发表评论