本文整理汇总了PHP中API::Service方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Service方法的具体用法?PHP API::Service怎么用?PHP API::Service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API::Service方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
$period_start = $period_end - $period * 3600;
break;
}
// fetch services
$services = API::Service()->get(array('output' => array('name', 'serviceid', 'showsla', 'goodsla', 'algorithm'), 'selectParent' => array('serviceid'), 'selectDependencies' => array('servicedownid', 'soft', 'linkid'), 'selectTrigger' => array('description', 'triggerid', 'expression'), 'preservekeys' => true, 'sortfield' => 'sortorder', 'sortorder' => ZBX_SORT_UP));
// expand trigger descriptions
$triggers = zbx_objectValues($services, 'trigger');
$triggers = CMacrosResolverHelper::resolveTriggerNames($triggers);
foreach ($services as &$service) {
if ($service['trigger']) {
$service['trigger'] = $triggers[$service['trigger']['triggerid']];
}
}
unset($service);
// fetch sla
$slaData = API::Service()->getSla(array('intervals' => array(array('from' => $period_start, 'to' => $period_end))));
// expand problem trigger descriptions
foreach ($slaData as &$serviceSla) {
foreach ($serviceSla['problems'] as &$problemTrigger) {
$problemTrigger['description'] = $triggers[$problemTrigger['triggerid']]['description'];
}
unset($problemTrigger);
}
unset($serviceSla);
$treeData = array();
createServiceMonitoringTree($services, $slaData, $period, $treeData);
$tree = new CServiceTree('service_status_tree', $treeData, array('caption' => _('Service'), 'status' => _('Status'), 'reason' => _('Reason'), 'sla' => _('Problem time'), 'sla2' => nbsp(_('SLA') . ' / ' . _('Acceptable SLA'))));
if ($tree) {
// creates form for choosing a preset interval
$r_form = new CForm();
$r_form->setAttribute('class', 'nowrap');
示例2: zbx_date2str
{
return zbx_date2str(DATE_TIME_FORMAT, $t);
}
function format_time2($t)
{
return format_time($t);
}
break;
}
$table->setHeader($header);
$intervals = array();
for ($t = $from; $t <= $to; $t++) {
if (($start = get_time($t)) > time()) {
break;
}
if (($end = get_time($t + 1)) > time()) {
$end = time();
}
$intervals[] = array('from' => $start, 'to' => $end);
}
$sla = API::Service()->getSla(array('serviceids' => $service['serviceid'], 'intervals' => $intervals));
$sla = reset($sla);
foreach ($sla['sla'] as $intervalSla) {
$ok = new CSpan(sprintf('%dd %dh %dm', $intervalSla['okTime'] / SEC_PER_DAY, $intervalSla['okTime'] % SEC_PER_DAY / SEC_PER_HOUR, $intervalSla['okTime'] % SEC_PER_HOUR / SEC_PER_MIN), 'off');
$problems = new CSpan(sprintf('%dd %dh %dm', $intervalSla['problemTime'] / SEC_PER_DAY, $intervalSla['problemTime'] % SEC_PER_DAY / SEC_PER_HOUR, $intervalSla['problemTime'] % SEC_PER_HOUR / SEC_PER_MIN), 'on');
$downtime = sprintf('%dd %dh %dm', $intervalSla['downtimeTime'] / SEC_PER_DAY, $intervalSla['downtimeTime'] % SEC_PER_DAY / SEC_PER_HOUR, $intervalSla['downtimeTime'] % SEC_PER_HOUR / SEC_PER_MIN);
$percentage = new CSpan(sprintf('%2.4f', $intervalSla['sla']), $intervalSla['sla'] >= $service['goodsla'] ? 'off' : 'on');
$table->addRow(array(format_time($intervalSla['from']), format_time2($intervalSla['to']), $ok, $problems, $downtime, $service['showsla'] ? $percentage : '-', $service['showsla'] ? new CSpan($service['goodsla']) : '-'));
}
$table->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
示例3: array
// get trigger
if ($data['triggerid'] > 0) {
$trigger = API::Trigger()->get(array('triggerids' => $data['triggerid'], 'output' => array('description'), 'selectHosts' => array('name'), 'expandDescription' => true));
$trigger = reset($trigger);
$host = reset($trigger['hosts']);
$data['trigger'] = $host['name'] . NAME_DELIMITER . $trigger['description'];
} else {
$data['trigger'] = '';
}
// render view
$servicesView = new CView('configuration.services.edit', $data);
$servicesView->render();
$servicesView->show();
} else {
// services
$services = API::Service()->get(array('output' => array('name', 'serviceid', 'algorithm'), 'selectParent' => array('serviceid'), 'selectDependencies' => array('servicedownid', 'soft', 'linkid'), 'selectTrigger' => array('description', 'triggerid', 'expression'), 'preservekeys' => true, 'sortfield' => 'sortorder', 'sortorder' => ZBX_SORT_UP));
// triggers
$triggers = zbx_objectValues($services, 'trigger');
$triggers = CMacrosResolverHelper::resolveTriggerNames($triggers);
foreach ($services as &$service) {
if ($service['trigger']) {
$service['trigger'] = $triggers[$service['trigger']['triggerid']];
}
}
unset($service);
$treeData = array();
createServiceConfigurationTree($services, $treeData);
$tree = new CServiceTree('service_conf_tree', $treeData, array('caption' => _('Service'), 'algorithm' => _('Status calculation'), 'description' => _('Trigger')));
if (empty($tree)) {
error(_('Cannot format tree.'));
}
示例4: date
if ($wday == 0) {
$wday = 7;
}
$start = $start - ($wday - 1) * 24 * 3600;
$weeks = (int) date('W') + ($wday ? 1 : 0);
$intervals = [];
for ($i = 0; $i < 52; $i++) {
if (($period_start = $start + 7 * 24 * 3600 * $i) > time()) {
break;
}
if (($period_end = $start + 7 * 24 * 3600 * ($i + 1)) > time()) {
$period_end = time();
}
$intervals[] = ['from' => $period_start, 'to' => $period_end];
}
$sla = API::Service()->getSla(['serviceids' => $service['serviceid'], 'intervals' => $intervals]);
$sla = reset($sla);
foreach ($sla['sla'] as $i => $intervalSla) {
$problem[$i] = 100 - $intervalSla['problemTime'];
$ok[$i] = $intervalSla['sla'];
$count_now[$i] = 1;
}
for ($i = 0; $i <= $sizeY; $i += $sizeY / 10) {
dashedLine($im, $shiftX, $i + $shiftYup, $sizeX + $shiftX, $i + $shiftYup, $gridcolor);
}
for ($i = 0, $period_start = $start; $i <= $sizeX; $i += $sizeX / 52) {
dashedLine($im, $i + $shiftX, $shiftYup, $i + $shiftX, $sizeY + $shiftYup, $gridcolor);
imageText($im, 6, 90, $i + $shiftX + 4, $sizeY + $shiftYup + 35, $textcolor, zbx_date2str(_('d.M'), $period_start));
$period_start += 7 * 24 * 3600;
}
$maxY = max(max($problem), 100);
示例5: doAction
protected function doAction()
{
// default values
$data = ['fullscreen' => $this->getInput('fullscreen', 0), 'period' => $this->getInput('period', 'yearly'), 'service' => $this->service, 'year' => $this->getInput('year', date('Y')), 'YEAR_LEFT_SHIFT' => self::YEAR_LEFT_SHIFT];
switch ($data['period']) {
case 'yearly':
$from = date('Y') - self::YEAR_LEFT_SHIFT;
$to = date('Y');
function get_time($year, $y)
{
return mktime(0, 0, 0, 1, 1, $y);
}
break;
case 'monthly':
$from = 1;
$to = 12;
function get_time($year, $m)
{
return mktime(0, 0, 0, $m, 1, $year);
}
break;
case 'weekly':
$from = 0;
$to = 52;
function get_time($year, $w)
{
$time = mktime(0, 0, 0, 1, 1, $year);
$wd = date('w', $time);
$wd = $wd == 0 ? 6 : $wd - 1;
$beg = $time - $wd * SEC_PER_DAY;
return strtotime("+{$w} week", $beg);
}
break;
case 'daily':
$from = 1;
$to = DAY_IN_YEAR;
function get_time($year, $d)
{
return mktime(0, 0, 0, 1, $d, $year);
}
break;
}
$now = time();
$intervals = [];
for ($t = $from; $t <= $to; $t++) {
if (($start = get_time($data['year'], $t)) > $now) {
break;
}
if (($end = get_time($data['year'], $t + 1)) > $now) {
$end = $now;
}
$intervals[] = ['from' => $start, 'to' => $end];
}
$sla = API::Service()->getSla(['serviceids' => [$this->service['serviceid']], 'intervals' => $intervals]);
$data['sla'] = reset($sla);
$response = new CControllerResponseData($data);
$response->setTitle(_('IT services availability report'));
$this->setResponse($response);
}
示例6: zbx_objectValues
}
// fetch services
$services = API::Service()->get(['output' => ['name', 'serviceid', 'showsla', 'goodsla', 'algorithm'], 'selectParent' => ['serviceid'], 'selectDependencies' => ['servicedownid', 'soft', 'linkid'], 'selectTrigger' => ['description', 'triggerid', 'expression'], 'preservekeys' => true, 'sortfield' => 'sortorder', 'sortorder' => ZBX_SORT_UP]);
// expand trigger descriptions
$triggers = zbx_objectValues(array_filter($services, function ($service) {
return (bool) $service['trigger'];
}), 'trigger');
$triggers = CMacrosResolverHelper::resolveTriggerNames(zbx_toHash($triggers, 'triggerid'));
foreach ($services as &$service) {
if ($service['trigger']) {
$service['trigger'] = $triggers[$service['trigger']['triggerid']];
}
}
unset($service);
// fetch sla
$slaData = API::Service()->getSla(['intervals' => [['from' => $period_start, 'to' => $period_end]]]);
// expand problem trigger descriptions
foreach ($slaData as &$serviceSla) {
foreach ($serviceSla['problems'] as &$problemTrigger) {
$problemTrigger['description'] = $triggers[$problemTrigger['triggerid']]['description'];
}
unset($problemTrigger);
}
unset($serviceSla);
$treeData = [];
createServiceMonitoringTree($services, $slaData, $period, $treeData);
$tree = new CServiceTree('service_status_tree', $treeData, ['caption' => _('Service'), 'status' => _('Status'), 'reason' => _('Reason'), 'sla' => (new CColHeader(_('Problem time')))->setColSpan(2), 'sla2' => null, 'sla3' => nbsp(_('SLA') . ' / ' . _('Acceptable SLA'))]);
if ($tree) {
// creates form for choosing a preset interval
$r_form = (new CForm('get'))->setAttribute('name', 'period_choice')->addVar('fullscreen', $_REQUEST['fullscreen']);
$period_combo = new CComboBox('period', $period, 'javascript: submit();');