Пример #1
0
/**
 * Get action messages.
 *
 * @param array  $alerts
 * @param string $alerts[n]['alertid']
 * @param string $alerts[n]['userid']
 * @param int    $alerts[n]['alerttype']
 * @param array  $alerts[n]['mediatypes']
 * @param string $alerts[n]['clock']
 * @param int    $alerts[n]['esc_step']
 * @param int    $alerts[n]['status']
 * @param int    $alerts[n]['retries']
 * @param string $alerts[n]['subject']
 * @param string $alerts[n]['sendto']
 * @param string $alerts[n]['message']
 * @param string $alerts[n]['error']
 *
 * @return CTableInfo
 */
function getActionMessages(array $alerts)
{
    $dbUsers = API::User()->get(array('output' => array('userid', 'alias', 'name', 'surname'), 'userids' => zbx_objectValues($alerts, 'userid'), 'preservekeys' => true));
    $table = new CTableInfo(_('No actions found.'));
    $table->setHeader(array(_('Time'), _('Type'), _('Status'), _('Retries left'), _('Recipient(s)'), _('Message'), _('Info')));
    foreach ($alerts as $alert) {
        if ($alert['alerttype'] != ALERT_TYPE_MESSAGE) {
            continue;
        }
        $mediaType = array_pop($alert['mediatypes']);
        $time = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']);
        if ($alert['esc_step'] > 0) {
            $time = array(bold(_('Step') . NAME_DELIMITER), $alert['esc_step'], br(), bold(_('Time') . NAME_DELIMITER), br(), $time);
        }
        if ($alert['status'] == ALERT_STATUS_SENT) {
            $status = new CSpan(_('sent'), 'green');
            $retries = new CSpan(SPACE, 'green');
        } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) {
            $status = new CSpan(_('In progress'), 'orange');
            $retries = new CSpan(ALERT_MAX_RETRIES - $alert['retries'], 'orange');
        } else {
            $status = new CSpan(_('not sent'), 'red');
            $retries = new CSpan(0, 'red');
        }
        $recipient = $alert['userid'] ? array(bold(getUserFullname($dbUsers[$alert['userid']])), BR(), $alert['sendto']) : $alert['sendto'];
        $message = array(bold(_('Subject') . NAME_DELIMITER), br(), $alert['subject'], br(), br(), bold(_('Message') . NAME_DELIMITER));
        array_push($message, BR(), zbx_nl2br($alert['message']));
        if (zbx_empty($alert['error'])) {
            $info = '';
        } else {
            $info = new CDiv(SPACE, 'status_icon iconerror');
            $info->setHint($alert['error'], 'on');
        }
        $table->addRow(array(new CCol($time, 'top'), new CCol(isset($mediaType['description']) ? $mediaType['description'] : '', 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($recipient, 'top'), new CCol($message, 'wraptext top'), new CCol($info, 'wraptext top')));
    }
    return $table;
}
    if ($discovery['templateid']) {
        $template_host = get_realhost_by_itemid($discovery['templateid']);
        $description[] = new CLink($template_host['name'], '?hostid=' . $template_host['hostid'], 'unknown');
        $description[] = NAME_DELIMITER;
    }
    $discovery['name_expanded'] = itemName($discovery);
    $description[] = new CLink($discovery['name_expanded'], '?form=update&itemid=' . $discovery['itemid']);
    $status = new CLink(itemIndicator($discovery['status'], $discovery['state']), '?hostid=' . $_REQUEST['hostid'] . '&g_hostdruleid=' . $discovery['itemid'] . '&go=' . ($discovery['status'] ? 'activate' : 'disable'), itemIndicatorStyle($discovery['status'], $discovery['state']));
    if ($data['showErrorColumn']) {
        $error = '';
        if ($discovery['status'] == ITEM_STATUS_ACTIVE) {
            if (zbx_empty($discovery['error'])) {
                $error = new CDiv(SPACE, 'status_icon iconok');
            } else {
                $error = new CDiv(SPACE, 'status_icon iconerror');
                $error->setHint($discovery['error'], '', 'on');
            }
        }
    }
    // host prototype link
    $hostPrototypeLink = null;
    if ($data['host']['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostPrototypeLink = array(new CLink(_('Host prototypes'), 'host_prototypes.php?parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['hostPrototypes'] . ')');
    }
    $discoveryTable->addRow(array(new CCheckBox('g_hostdruleid[' . $discovery['itemid'] . ']', null, null, $discovery['itemid']), $description, array(new CLink(_('Item prototypes'), 'disc_prototypes.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['items'] . ')'), array(new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['triggers'] . ')'), array(new CLink(_('Graph prototypes'), 'graphs.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['graphs'] . ')'), $hostPrototypeLink, $discovery['key_'], $discovery['delay'], item_type2str($discovery['type']), $status, $data['showErrorColumn'] ? $error : null));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected discovery rules?'));
$goComboBox->addItem($goOption);
foreach ($data['discoveries'] as $discovery) {
    // description
    $description = array();
    if ($discovery['templateid']) {
        $dbTemplate = get_realhost_by_itemid($discovery['templateid']);
        $description[] = new CLink($dbTemplate['name'], '?hostid=' . $dbTemplate['hostid'], 'unknown');
        $description[] = NAME_DELIMITER;
    }
    $description[] = new CLink($discovery['name_expanded'], '?form=update&itemid=' . $discovery['itemid']);
    // status
    $status = new CLink(itemIndicator($discovery['status'], $discovery['state']), '?hostid=' . $_REQUEST['hostid'] . '&g_hostdruleid=' . $discovery['itemid'] . '&action=' . ($discovery['status'] == ITEM_STATUS_DISABLED ? 'discoveryrule.massenable' : 'discoveryrule.massdisable'), itemIndicatorStyle($discovery['status'], $discovery['state']));
    // info
    if ($data['showInfoColumn']) {
        if ($discovery['status'] == ITEM_STATUS_ACTIVE && !zbx_empty($discovery['error'])) {
            $info = new CDiv(SPACE, 'status_icon iconerror');
            $info->setHint($discovery['error'], 'on');
        } else {
            $info = '';
        }
    } else {
        $info = null;
    }
    // host prototype link
    $hostPrototypeLink = null;
    if ($data['host']['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostPrototypeLink = array(new CLink(_('Host prototypes'), 'host_prototypes.php?parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['hostPrototypes'] . ')');
    }
    $discoveryTable->addRow(array(new CCheckBox('g_hostdruleid[' . $discovery['itemid'] . ']', null, null, $discovery['itemid']), $description, array(new CLink(_('Item prototypes'), 'disc_prototypes.php?hostid=' . getRequest('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['items'] . ')'), array(new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?hostid=' . getRequest('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['triggers'] . ')'), array(new CLink(_('Graph prototypes'), 'graphs.php?hostid=' . getRequest('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['graphs'] . ')'), $hostPrototypeLink, $discovery['key_'], $discovery['delay'], item_type2str($discovery['type']), $status, $info));
}
// create go buttons
$goComboBox = new CComboBox('action');
Пример #4
0
 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $sortfield = 'clock';
     $sortorder = ZBX_SORT_DOWN;
     $sorttitle = _('Time');
     switch ($this->screenitem['sort_triggers']) {
         case SCREEN_SORT_TRIGGERS_TIME_ASC:
             $sortfield = 'clock';
             $sortorder = ZBX_SORT_UP;
             $sorttitle = _('Time');
             break;
         case SCREEN_SORT_TRIGGERS_TIME_DESC:
             $sortfield = 'clock';
             $sortorder = ZBX_SORT_DOWN;
             $sorttitle = _('Time');
             break;
         case SCREEN_SORT_TRIGGERS_TYPE_ASC:
             $sortfield = 'description';
             $sortorder = ZBX_SORT_UP;
             $sorttitle = _('Type');
             break;
         case SCREEN_SORT_TRIGGERS_TYPE_DESC:
             $sortfield = 'description';
             $sortorder = ZBX_SORT_DOWN;
             $sorttitle = _('Type');
             break;
         case SCREEN_SORT_TRIGGERS_STATUS_ASC:
             $sortfield = 'status';
             $sortorder = ZBX_SORT_UP;
             $sorttitle = _('Status');
             break;
         case SCREEN_SORT_TRIGGERS_STATUS_DESC:
             $sortfield = 'status';
             $sortorder = ZBX_SORT_DOWN;
             $sorttitle = _('Status');
             break;
         case SCREEN_SORT_TRIGGERS_RECIPIENT_ASC:
             $sortfield = 'sendto';
             $sortorder = ZBX_SORT_UP;
             $sorttitle = _('Recipient(s)');
             break;
         case SCREEN_SORT_TRIGGERS_RECIPIENT_DESC:
             $sortfield = 'sendto';
             $sortorder = ZBX_SORT_DOWN;
             $sorttitle = _('Recipient(s)');
             break;
     }
     $sql = 'SELECT a.alertid,a.clock,a.sendto,a.subject,a.message,a.status,a.retries,a.error,' . 'a.userid,a.actionid,a.mediatypeid,mt.description' . ' FROM events e,alerts a' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE e.eventid=a.eventid' . ' AND alerttype=' . ALERT_TYPE_MESSAGE;
     if (CWebUser::getType() != USER_TYPE_SUPER_ADMIN) {
         $userid = CWebUser::$data['userid'];
         $userGroups = getUserGroupsByUserId($userid);
         $sql .= ' AND EXISTS (' . 'SELECT NULL' . ' FROM functions f,items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE e.objectid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ' GROUP BY f.triggerid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ')';
     }
     $sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder;
     $alerts = DBfetchArray(DBselect($sql, $this->screenitem['elements']));
     order_result($alerts, $sortfield, $sortorder);
     if ($alerts) {
         $dbUsers = API::User()->get(array('output' => array('userid', 'alias', 'name', 'surname'), 'userids' => zbx_objectValues($alerts, 'userid'), 'preservekeys' => true));
     }
     // indicator of sort field
     $sortfieldSpan = new CSpan(array($sorttitle, SPACE));
     $sortorderSpan = new CSpan(SPACE, $sortorder === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
     // create alert table
     $actionTable = new CTableInfo(_('No action log entries found.'));
     $actionTable->setHeader(array($sortfield === 'clock' ? array($sortfieldSpan, $sortorderSpan) : _('Time'), _('Action'), $sortfield === 'description' ? array($sortfieldSpan, $sortorderSpan) : _('Type'), $sortfield === 'sendto' ? array($sortfieldSpan, $sortorderSpan) : _('Recipient(s)'), _('Message'), $sortfield === 'status' ? array($sortfieldSpan, $sortorderSpan) : _('Status'), _('Info')));
     $actions = API::Action()->get(array('output' => array('actionid', 'name'), 'actionids' => array_unique(zbx_objectValues($alerts, 'actionid')), 'preservekeys' => true));
     foreach ($alerts as $alert) {
         if ($alert['status'] == ALERT_STATUS_SENT) {
             $status = new CSpan(_('Sent'), 'green');
         } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) {
             $status = new CSpan(array(_('In progress') . ':', BR(), _n('%1$s retry left', '%1$s retries left', ALERT_MAX_RETRIES - $alert['retries'])), 'orange');
         } else {
             $status = new CSpan(_('Not sent'), 'red');
         }
         $recipient = $alert['userid'] ? array(bold(getUserFullname($dbUsers[$alert['userid']])), BR(), $alert['sendto']) : $alert['sendto'];
         $message = array(bold(_('Subject') . ':'), br(), $alert['subject'], br(), br(), bold(_('Message') . ':'), br(), $alert['message']);
         if (zbx_empty($alert['error'])) {
             $info = '';
         } else {
             $info = new CDiv(SPACE, 'status_icon iconerror');
             $info->setHint($alert['error'], 'on');
         }
         $actionTable->addRow(array(new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']), 'top'), new CCol($actions[$alert['actionid']]['name'], 'top'), new CCol($alert['mediatypeid'] == 0 ? '-' : $alert['description'], 'top'), new CCol($recipient, 'top'), new CCol($message, 'top pre'), new CCol($status, 'top'), new CCol($info, 'wraptext top')));
     }
     return $this->getOutput($actionTable);
 }
Пример #5
0
/**
 * Returns zbx, snmp, jmx, ipmi availability status icons.
 *
 * @param type $host
 *
 * @return CDiv
 */
function getAvailabilityTable($host)
{
    $arr = array('zbx', 'snmp', 'jmx', 'ipmi');
    // for consistency in foreach loop
    $host['zbx_available'] = $host['available'];
    $host['zbx_error'] = $host['error'];
    $ad = new CDiv(null, 'invisible');
    foreach ($arr as $val) {
        switch ($host[$val . '_available']) {
            case HOST_AVAILABLE_TRUE:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'available');
                break;
            case HOST_AVAILABLE_FALSE:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unavailable');
                $ai->setHint($host[$val . '_error'], '', 'on');
                break;
            case HOST_AVAILABLE_UNKNOWN:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unknown');
                break;
        }
        $ad->addItem($ai);
    }
    return $ad;
}
// create table
$auditTable = new CTableInfo(_('No action log entries found.'));
$auditTable->setHeader(array(_('Time'), _('Action'), _('Type'), _('Recipient(s)'), _('Message'), _('Status'), _('Info')));
foreach ($this->data['alerts'] as $alert) {
    $mediatype = array_pop($alert['mediatypes']);
    if ($alert['status'] == ALERT_STATUS_SENT) {
        $status = $alert['alerttype'] == ALERT_TYPE_MESSAGE ? new CSpan(_('Sent'), 'green') : new CSpan(_('Executed'), 'green');
    } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) {
        $status = new CSpan(array(_('In progress') . ':', BR(), _n('%1$s retry left', '%1$s retries left', ALERT_MAX_RETRIES - $alert['retries'])), 'orange');
    } else {
        $status = new CSpan(_('Not sent'), 'red');
    }
    $message = $alert['alerttype'] == ALERT_TYPE_MESSAGE ? array(bold(_('Subject') . ':'), BR(), $alert['subject'], BR(), BR(), bold(_('Message') . ':'), BR(), zbx_nl2br($alert['message'])) : array(bold(_('Command') . ':'), BR(), zbx_nl2br($alert['message']));
    if (zbx_empty($alert['error'])) {
        $info = '';
    } else {
        $info = new CDiv(SPACE, 'status_icon iconerror');
        $info->setHint($alert['error'], 'on');
    }
    $recipient = isset($alert['userid']) && $alert['userid'] ? array(bold(getUserFullname($this->data['users'][$alert['userid']])), BR(), $alert['sendto']) : $alert['sendto'];
    $auditTable->addRow(array(new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']), 'top'), new CCol($this->data['actions'][$alert['actionid']]['name'], 'top'), new CCol($mediatype ? $mediatype['description'] : '-', 'top'), new CCol($recipient, 'top'), new CCol($message, 'wraptext top'), new CCol($status, 'top'), new CCol($info, 'top')));
}
// append table to form
$auditForm->addItem(array($this->data['paging'], $auditTable, $this->data['paging']));
// append navigation bar js
$objData = array('id' => 'timeline_1', 'domid' => 'events', 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1, 'periodFixed' => CProfile::get('web.auditacts.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
zbx_add_post_js('timeControl.addObject("events", ' . zbx_jsvalue($data['timeline']) . ', ' . zbx_jsvalue($objData) . ');');
zbx_add_post_js('timeControl.processObjects();');
// append form to widget
$auditWidget->addItem($auditForm);
return $auditWidget;
Пример #7
0
         array_pop($description);
         $description[] = ' : ';
         $description[] = expand_trigger_description_by_data($dep_trigger);
     }
 }
 // } add dependencies
 if ($trigger['value'] != TRIGGER_VALUE_UNKNOWN) {
     $trigger['error'] = '';
 }
 $templated = false;
 foreach ($trigger['hosts'] as $hostid => $host) {
     $templated |= HOST_STATUS_TEMPLATE == $host['status'];
 }
 if (!zbx_empty($trigger['error']) && !$templated) {
     $error = new CDiv(SPACE, 'iconerror');
     $error->setHint($trigger['error'], '', 'on');
 } else {
     $error = new CDiv(SPACE, 'iconok');
 }
 switch ($trigger['priority']) {
     case 0:
         $priority = S_NOT_CLASSIFIED;
         break;
     case 1:
         $priority = new CCol(S_INFORMATION, 'information');
         break;
     case 2:
         $priority = new CCol(S_WARNING, 'warning');
         break;
     case 3:
         $priority = new CCol(S_AVERAGE, 'average');
 // status
 $status = new CCol(new CLink(itemIndicator($item['status'], $item['state']), '?group_itemid=' . $item['itemid'] . '&hostid=' . $item['hostid'] . '&action=' . ($item['status'] == ITEM_STATUS_DISABLED ? 'item.massenable' : 'item.massdisable'), itemIndicatorStyle($item['status'], $item['state'])));
 // info
 if ($data['showInfoColumn']) {
     $infoIcons = array();
     if ($item['status'] == ITEM_STATUS_ACTIVE && !zbx_empty($item['error'])) {
         $info = new CDiv(SPACE, 'status_icon iconerror');
         $info->setHint($item['error'], 'on');
         $infoIcons[] = $info;
     }
     // discovered item lifetime indicator
     if ($item['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $item['itemDiscovery']['ts_delete']) {
         $deleteError = new CDiv(SPACE, 'status_icon iconwarning');
         // Check if item should've been deleted in the past.
         if ($currentTime > $item['itemDiscovery']['ts_delete']) {
             $deleteError->setHint(_s('The item is not discovered anymore and will be deleted the next time discovery rule is processed.'));
         } else {
             $deleteError->setHint(_s('The item is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($item['itemDiscovery']['ts_delete']), zbx_date2str(DATE_FORMAT, $item['itemDiscovery']['ts_delete']), zbx_date2str(TIME_FORMAT, $item['itemDiscovery']['ts_delete'])));
         }
         $infoIcons[] = $deleteError;
     }
     if (!$infoIcons) {
         $infoIcons[] = '';
     }
 } else {
     $infoIcons = null;
 }
 // triggers info
 $triggerHintTable = new CTableInfo();
 $triggerHintTable->setHeader(array(_('Severity'), _('Name'), _('Expression'), _('Status')));
 foreach ($item['triggers'] as $num => &$trigger) {
Пример #9
0
            $class = null;
            $time = SPACE;
            $hint = new CDiv(SPACE, $class);
            $hintTable = new CTableInfo();
            $hintTable->setAttribute('style', 'width: auto;');
            if (isset($h_data['services'][$name])) {
                $class = $h_data['services'][$name]['class'];
                $time = $h_data['services'][$name]['time'];
                if ($class == 'active') {
                    $hintTable->setHeader(S_UP_TIME);
                } else {
                    if ($class == 'inactive') {
                        $hintTable->setHeader(S_DOWN_TIME);
                    }
                }
                $timeColumn = new CCol(zbx_date2age($h_data['services'][$name]['time']), $class);
                $hintTable->addRow($timeColumn);
                $hint->setHint($hintTable);
            }
            $table_row[] = new CCol($hint, $class);
        }
        $table->addRow($table_row);
        $row_count++;
    }
}
if (isset($row_count)) {
    zbx_add_post_js('insert_in_element("numrows","' . $row_count . '");');
}
$dscvry_wdgt->addItem($table);
$dscvry_wdgt->show();
include_once "include/page_footer.php";
$httpTests = $this->data['httpTests'];
foreach ($httpTests as $httpTestId => $httpTest) {
    $name = array();
    if (isset($this->data['parentTemplates'][$httpTestId])) {
        $template = $this->data['parentTemplates'][$httpTestId];
        $name[] = new CLink($template['name'], '?groupid=0&hostid=' . $template['id'], 'unknown');
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTestId . '&hostid=' . $httpTest['hostid']);
    if ($this->data['showInfoColumn']) {
        if ($httpTest['status'] == HTTPTEST_STATUS_ACTIVE && isset($httpTestsLastData[$httpTestId]) && $httpTestsLastData[$httpTestId]['lastfailedstep']) {
            $lastData = $httpTestsLastData[$httpTestId];
            $failedStep = $lastData['failedstep'];
            $errorMessage = $failedStep ? _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $failedStep['name'], $failedStep['no'], $httpTest['stepscnt'], $lastData['error'] === null ? _('Unknown error') : $lastData['error']) : _s('Unknown step failed: %1$s', $lastData['error']);
            $infoIcon = new CDiv(SPACE, 'status_icon iconerror');
            $infoIcon->setHint($errorMessage, 'on');
        } else {
            $infoIcon = '';
        }
    } else {
        $infoIcon = null;
    }
    $httpTable->addRow(array(new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', null, null, $httpTest['httptestid']), $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], $httpTest['delay'], $httpTest['retries'], httptest_authentications($httpTest['authentication']), $httpTest['http_proxy'] !== '' ? _('Yes') : _('No'), $httpTest['applicationid'] != 0 ? $httpTest['application_name'] : '-', new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&action=' . ($httpTest['status'] == HTTPTEST_STATUS_DISABLED ? 'httptest.massenable' : 'httptest.massdisable'), httptest_status2style($httpTest['status'])), $infoIcon));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('httptest.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected web scenarios?'));
Пример #11
0
             $status = S_UNKNOWN;
     }
     if ($row['available'] == HOST_AVAILABLE_TRUE) {
         $available = new CCol(S_AVAILABLE, 'off');
     } else {
         if ($row['available'] == HOST_AVAILABLE_FALSE) {
             $available = new CCol(S_NOT_AVAILABLE, 'on');
         } else {
             if ($row['available'] == HOST_AVAILABLE_UNKNOWN) {
                 $available = new CCol(S_UNKNOWN, 'unknown');
             }
         }
     }
     if (!zbx_empty($row['error'])) {
         $error = new CDiv(SPACE, 'error_icon');
         $error->setHint($row['error'], '', 'on');
     } else {
         $error = new CDiv(SPACE, 'ok_icon');
     }
     $templates = $row['templates'];
     $templates_linked = array();
     foreach ($templates as $templateid => $template) {
         $templates_linked[$templateid] = array(empty($templates_linked) ? '' : ', ', $template['host']);
     }
     $table->addRow(array(new CCheckBox('hosts[' . $row['hostid'] . ']', NULL, NULL, $row['hostid']), $description, $items, $triggers, $graphs, $dns, $ip, $port, empty($templates) ? '-' : $templates_linked, $status, $available, $error));
     $row_count++;
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('massupdate', S_MASS_UPDATE);
 $goBox->addItem('activate', S_ACTIVATE_SELECTED);
    }
    $hostCount = $this->data['groupCounts'][$group['groupid']]['hosts'];
    $templateCount = $this->data['groupCounts'][$group['groupid']]['templates'];
    // name
    $name = array();
    if ($group['discoveryRule']) {
        $name[] = new CLink($group['discoveryRule']['name'], 'host_prototypes.php?parent_discoveryid=' . $group['discoveryRule']['itemid'], 'parent-discovery');
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($group['name'], 'hostgroups.php?form=update&groupid=' . $group['groupid']);
    // info, discovered item lifetime indicator
    if ($group['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $group['groupDiscovery']['ts_delete']) {
        $info = new CDiv(SPACE, 'status_icon iconwarning');
        // Check if host group should've been deleted in the past.
        if ($currentTime > $group['groupDiscovery']['ts_delete']) {
            $info->setHint(_s('The host group is not discovered anymore and will be deleted the next time discovery rule is processed.'));
        } else {
            $info->setHint(_s('The host group is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($group['groupDiscovery']['ts_delete']), zbx_date2str(DATE_FORMAT, $group['groupDiscovery']['ts_delete']), zbx_date2str(TIME_FORMAT, $group['groupDiscovery']['ts_delete'])));
        }
    } else {
        $info = '';
    }
    $hostGroupTable->addRow(array(new CCheckBox('groups[' . $group['groupid'] . ']', null, null, $group['groupid']), $name, array(array(new CLink(_('Templates'), 'templates.php?groupid=' . $group['groupid'], 'unknown'), ' (' . $templateCount . ')'), BR(), array(new CLink(_('Hosts'), 'hosts.php?groupid=' . $group['groupid']), ' (' . $hostCount . ')')), new CCol(empty($hostsOutput) ? '-' : $hostsOutput, 'wraptext'), $info));
}
// create go button
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('hostgroup.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected hosts?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('hostgroup.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable hosts in the selected host groups?'));
Пример #13
0
 $db_items = DBselect($sql);
 while ($db_item = DBfetch($db_items)) {
     $description = array();
     $item_description = item_description($db_item);
     if (isset($_REQUEST['filter_description']) && !zbx_stristr($item_description, $_REQUEST['filter_description'])) {
         continue;
     }
     if ($db_item['templateid']) {
         $template_host = get_realhost_by_itemid($db_item['templateid']);
         array_push($description, new CLink($template_host['host'], '?' . 'hostid=' . $template_host['hostid'], 'unknown'), ':');
     }
     array_push($description, new CLink(item_description($db_item), '?form=update&itemid=' . $db_item['itemid'] . '&hostid=' . $db_item['hostid']));
     $status = new CCol(new CLink(item_status2str($db_item['status']), '?group_itemid%5B%5D=' . $db_item['itemid'] . '&go=' . ($db_item['status'] ? 'activate' : 'disable'), item_status2style($db_item['status'])));
     if (!zbx_empty($db_item['error'])) {
         $error = new CDiv(SPACE, 'error_icon');
         $error->setHint($db_item['error'], '', 'on');
     } else {
         $error = new CDiv(SPACE, 'ok_icon');
     }
     $applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item['itemid'], 'name')) : null;
     if (!is_null($applications) && empty($applications)) {
         $applications = ' - ';
     }
     $applications = new CCol($applications, 'wraptext');
     $table->addRow(array(new CCheckBox('group_itemid[' . $db_item['itemid'] . ']', null, null, $db_item['itemid']), $show_host ? $db_item['host'] : null, $description, $db_item['key_'], $db_item['delay'], $db_item['history'], $db_item['trends'], item_type2str($db_item['type']), $status, $applications, $error));
     $row_count++;
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('activate', S_ACTIVATE_SELECTED);
 $goBox->addItem('disable', S_DISABLE_SELECTED);
             } else {
                 $triggerDependencies[] = array($hostNames, NAME_DELIMITER, $depTrigger['description']);
             }
             $triggerDependencies[] = BR();
         }
         array_pop($triggerDependencies);
         $description = array_merge($description, array(new CDiv($triggerDependencies, 'dependencies')));
     }
 } else {
     $description[] = new CLink(CHtml::encode($trigger['description']), 'trigger_prototypes.php?' . 'form=update' . '&hostid=' . $this->data['hostid'] . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&triggerid=' . $triggerid);
 }
 // info
 if ($data['showInfoColumn']) {
     if ($trigger['status'] == TRIGGER_STATUS_ENABLED && !zbx_empty($trigger['error'])) {
         $info = new CDiv(SPACE, 'status_icon iconerror');
         $info->setHint($trigger['error'], 'on');
     } else {
         $info = '';
     }
 } else {
     $info = null;
 }
 // status
 $status = '';
 if (!empty($this->data['parent_discoveryid'])) {
     $status = new CLink(triggerIndicator($trigger['status']), 'trigger_prototypes.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'triggerprototype.massenable' : 'triggerprototype.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid . '&parent_discoveryid=' . $this->data['parent_discoveryid'], triggerIndicatorStyle($trigger['status']));
 } else {
     $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'trigger.massenable' : 'trigger.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
 }
 // hosts
 $hosts = null;
 $status = new CCol(new CLink(itemIndicator($item['status'], $item['state']), '?group_itemid=' . $item['itemid'] . '&hostid=' . $item['hostid'] . '&go=' . ($item['status'] ? 'activate' : 'disable'), itemIndicatorStyle($item['status'], $item['state'])));
 if ($data['showErrorColumn']) {
     $statusIcons = array();
     if ($item['status'] == ITEM_STATUS_ACTIVE) {
         if (zbx_empty($item['error'])) {
             $error = new CDiv(SPACE, 'status_icon iconok');
         } else {
             $error = new CDiv(SPACE, 'status_icon iconerror');
             $error->setHint($item['error'], '', 'on');
         }
         $statusIcons[] = $error;
     }
     // discovered item lifetime indicator
     if ($item['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $item['itemDiscovery']['ts_delete']) {
         $deleteError = new CDiv(SPACE, 'status_icon iconwarning');
         $deleteError->setHint(_s('The item is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($item['itemDiscovery']['ts_delete']), zbx_date2str(_('d M Y'), $item['itemDiscovery']['ts_delete']), zbx_date2str(_('H:i:s'), $item['itemDiscovery']['ts_delete'])));
         $statusIcons[] = $deleteError;
     }
 }
 $triggerHintTable = new CTableInfo();
 $triggerHintTable->setHeader(array(_('Severity'), _('Name'), _('Expression'), _('Status')));
 // triggers info
 foreach ($item['triggers'] as $num => &$trigger) {
     $trigger = $this->data['itemTriggers'][$trigger['triggerid']];
     $triggerDescription = array();
     if ($trigger['templateid'] > 0) {
         if (!isset($this->data['triggerRealHosts'][$trigger['triggerid']])) {
             $triggerDescription[] = new CSpan('HOST', 'unknown');
             $triggerDescription[] = ':';
         } else {
             $realHost = reset($this->data['triggerRealHosts'][$trigger['triggerid']]);
Пример #16
0
/**
 * Returns zbx, snmp, jmx, ipmi availability status icons and the discovered host lifetime indicator.
 *
 * @param type $host
 *
 * @return CDiv
 */
function getAvailabilityTable($host)
{
    $arr = array('zbx', 'snmp', 'jmx', 'ipmi');
    // for consistency in foreach loop
    $host['zbx_available'] = $host['available'];
    $host['zbx_error'] = $host['error'];
    $ad = new CDiv(null, 'invisible');
    foreach ($arr as $val) {
        switch ($host[$val . '_available']) {
            case HOST_AVAILABLE_TRUE:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'available');
                break;
            case HOST_AVAILABLE_FALSE:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unavailable');
                $ai->setHint($host[$val . '_error'], '', 'on');
                break;
            case HOST_AVAILABLE_UNKNOWN:
                $ai = new CDiv(SPACE, 'status_icon status_icon_extra icon' . $val . 'unknown');
                break;
        }
        $ad->addItem($ai);
    }
    // discovered host lifetime indicator
    if ($host['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $host['hostDiscovery']['ts_delete']) {
        $deleteError = new CDiv(SPACE, 'status_icon status_icon_extra iconwarning');
        $deleteError->setHint(_s('The host is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($host['hostDiscovery']['ts_delete']), zbx_date2str(_('d M Y'), $host['hostDiscovery']['ts_delete']), zbx_date2str(_('H:i:s'), $host['hostDiscovery']['ts_delete'])));
        $ad->addItem($deleteError);
    }
    return $ad;
}
    $hostCount = $this->data['groupCounts'][$group['groupid']]['hosts'];
    $templateCount = $this->data['groupCounts'][$group['groupid']]['templates'];
    // name
    $name = array();
    if ($group['discoveryRule']) {
        $name[] = new CLink($group['discoveryRule']['name'], 'host_prototypes.php?parent_discoveryid=' . $group['discoveryRule']['itemid'], 'parent-discovery');
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($group['name'], 'hostgroups.php?form=update&groupid=' . $group['groupid']);
    // status
    if ($showStatus) {
        $status = array();
        // discovered item lifetime indicator
        if ($group['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $group['groupDiscovery']['ts_delete']) {
            $deleteError = new CDiv(SPACE, 'status_icon iconwarning');
            $deleteError->setHint(_s('The host group is not discovered anymore and will be deleted in %1$s (on %2$s at %3$s).', zbx_date2age($group['groupDiscovery']['ts_delete']), zbx_date2str(_('d M Y'), $group['groupDiscovery']['ts_delete']), zbx_date2str(_('H:i:s'), $group['groupDiscovery']['ts_delete'])));
            $status[] = $deleteError;
        }
    }
    $hostGroupTable->addRow(array(new CCheckBox('groups[' . $group['groupid'] . ']', null, null, $group['groupid']), $this->data['displayNodes'] ? $group['nodename'] : null, $name, array(array(new CLink(_('Templates'), 'templates.php?groupid=' . $group['groupid'], 'unknown'), ' (' . $templateCount . ')'), BR(), array(new CLink(_('Hosts'), 'hosts.php?groupid=' . $group['groupid']), ' (' . $hostCount . ')')), new CCol(empty($hostsOutput) ? '-' : $hostsOutput, 'wraptext'), $showStatus ? $status : null));
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected hosts?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable hosts in the selected host groups?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected host groups?'));
Пример #18
0
 $checkbox->removeAttribute('id');
 if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('Graph'), 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $item['itemid']);
 } else {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('History'), 'history.php?action=' . HISTORY_VALUES . '&itemids[]=' . $item['itemid']);
     $checkbox->setEnabled(false);
 }
 $stateCss = $item['state'] == ITEM_STATE_NOTSUPPORTED ? 'unknown' : '';
 $host = $hosts[$item['hostid']];
 if ($filter['showDetails']) {
     // item key
     $itemKey = $item['type'] == ITEM_TYPE_HTTPTEST || $item['flags'] == ZBX_FLAG_DISCOVERY_CREATED ? new CSpan($item['key_expanded'], 'enabled') : new CLink($item['key_expanded'], 'items.php?form=update&itemid=' . $item['itemid'], 'enabled');
     // info
     if ($item['status'] == ITEM_STATUS_ACTIVE && $item['error'] !== '') {
         $info = new CDiv(null, 'status_icon iconerror');
         $info->setHint($item['error'], 'on');
     } else {
         $info = '';
     }
     // trend value
     if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
         $trendValue = $config['hk_trends_global'] ? $config['hk_trends'] : $item['trends'];
     } else {
         $trendValue = UNKNOWN_VALUE;
     }
     $row = new CRow(array('', $checkbox, $hostColumn, new CCol(new CDiv(array($item['name_expanded'], BR(), $itemKey), $stateCss . ' item')), new CCol(new CSpan($item['type'] == ITEM_TYPE_SNMPTRAP || $item['type'] == ITEM_TYPE_TRAPPER ? UNKNOWN_VALUE : $item['delay'], $stateCss)), new CCol(new CSpan($config['hk_history_global'] ? $config['hk_history'] : $item['history'], $stateCss)), new CCol(new CSpan($trendValue, $stateCss)), new CCol(new CSpan(item_type2str($item['type']), $stateCss)), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), new CCol($actions, $stateCss), $info));
 } else {
     $row = new CRow(array('', $checkbox, $hostColumn, new CCol(new CSpan($item['name_expanded'], $stateCss . ' item')), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), new CCol($actions, $stateCss)));
 }
 $hosts[$item['hostid']]['item_cnt']++;
 $tab_rows[$item['hostid']][] = $row;
Пример #19
0
     $openOrCloseDiv->setAttribute('data-switcherid', $trigger['triggerid']);
 } elseif ($showEvents == EVENTS_OPTION_NOEVENT) {
     $openOrCloseDiv = null;
 } else {
     $openOrCloseDiv = SPACE;
 }
 // severity
 $severityColumn = getSeverityCell($trigger['priority'], null, !$trigger['value']);
 if ($showEventColumn) {
     $severityColumn->setColSpan(2);
 }
 // unknown triggers
 $unknown = SPACE;
 if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
     $unknown = new CDiv(SPACE, 'status_icon iconunknown');
     $unknown->setHint($trigger['error'], '', 'on');
 }
 // comments
 if (isset($triggerEditable[$trigger['triggerid']])) {
     $comments = new CLink(zbx_empty($trigger['comments']) ? _('Add') : _('Show'), 'tr_comments.php?triggerid=' . $trigger['triggerid']);
 } else {
     $comments = zbx_empty($trigger['comments']) ? new CSpan('-') : new CLink(_('Show'), 'tr_comments.php?triggerid=' . $trigger['triggerid']);
 }
 $triggerTable->addRow(array($openOrCloseDiv, $config['event_ack_enable'] ? $showEventColumn ? null : new CCheckBox('triggers[' . $trigger['triggerid'] . ']', 'no', null, $trigger['triggerid']) : null, $severityColumn, $statusSpan, $unknown, $lastChange, empty($trigger['lastchange']) ? '-' : zbx_date2age($trigger['lastchange']), $showEventColumn ? SPACE : null, $ackColumn, $displayNodes ? get_node_name_by_elid($trigger['triggerid']) : null, $hostColumn, $triggerDescription, $comments), 'even_row');
 if ($showEvents != EVENTS_OPTION_NOEVENT && !empty($trigger['events'])) {
     $i = 1;
     foreach ($trigger['events'] as $enum => $event) {
         $i++;
         $eventStatusSpan = new CSpan(trigger_value2str($event['value']));
         // add colors and blinking to span depending on configuration and trigger parameters
         addTriggerValueStyle($eventStatusSpan, $event['value'], $event['clock'], $event['acknowledged']);
Пример #20
0
/**
 * Generate table for dashboard triggers popup.
 *
 * @see make_system_status
 *
 * @param array $triggers
 * @param array $ackParams
 * @param array $actions
 *
 * @return CTableInfo
 */
function makeTriggersPopup(array $triggers, array $ackParams, array $actions)
{
    $config = select_config();
    $popupTable = new CTableInfo();
    $popupTable->setAttribute('style', 'width: 400px;');
    $popupTable->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    CArrayHelper::sort($triggers, array(array('field' => 'lastchange', 'order' => ZBX_SORT_DOWN)));
    foreach ($triggers as $trigger) {
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // ack
        if ($config['event_ack_enable']) {
            $ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], true, true, $ackParams) : _('No events');
        } else {
            $ack = null;
        }
        // action
        $action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : _('-');
        $popupTable->addRow(array(get_node_name_by_elid($trigger['triggerid']), $trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $trigger['description']), zbx_date2age($trigger['lastchange']), $unknown, $ack, $action));
    }
    return $popupTable;
}
Пример #21
0
         break;
     case HOST_AVAILABLE_FALSE:
         $snmp_available = new CDiv(SPACE, 'iconsnmpunavailable');
         $snmp_available->setHint($host['snmp_error'], '', 'on');
         break;
     case HOST_AVAILABLE_UNKNOWN:
         $snmp_available = new CDiv(SPACE, 'iconsnmpunknown');
         break;
 }
 switch ($host['ipmi_available']) {
     case HOST_AVAILABLE_TRUE:
         $ipmi_available = new CDiv(SPACE, 'iconipmiavailable');
         break;
     case HOST_AVAILABLE_FALSE:
         $ipmi_available = new CDiv(SPACE, 'iconipmiunavailable');
         $ipmi_available->setHint($host['ipmi_error'], '', 'on');
         break;
     case HOST_AVAILABLE_UNKNOWN:
         $ipmi_available = new CDiv(SPACE, 'iconipmiunknown');
         break;
 }
 $av_table = new CTable(null, 'invisible');
 $av_table->addRow(array($zbx_available, $snmp_available, $ipmi_available));
 if (empty($host['parentTemplates'])) {
     $hostTemplates = '-';
 } else {
     $hostTemplates = array();
     order_result($host['parentTemplates'], 'host');
     foreach ($host['parentTemplates'] as $htnum => $template) {
         $caption = array();
         $caption[] = new CLink($template['host'], 'templates.php?form=update&templateid=' . $template['templateid'], 'unknown');