/** * Get acknowledgement table. * * @param array $acknowledges * @param array $acknowledges['clock'] * @param array $acknowledges['alias'] * @param array $acknowledges['name'] * @param array $acknowledges['surname'] * @param array $acknowledges['message'] * * @return CTableInfo */ function makeAckTab($acknowledges) { $table = (new CTableInfo())->setHeader([_('Time'), _('User'), _('Message')]); foreach ($acknowledges as $acknowledge) { $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $acknowledge['clock']), getUserFullname($acknowledge), zbx_nl2br($acknowledge['message'])]); } return $table; }
function make_acktab_by_eventid($eventid) { $table = new CTableInfo(); $table->SetHeader(array(S_TIME, S_USER, S_COMMENTS)); $acks = get_acknowledges_by_eventid($eventid); while ($ack = DBfetch($acks)) { $user = get_user_by_userid($ack['userid']); $table->AddRow(array(date('d-m-Y h:i:s A', $ack['clock']), $user['alias'], new CCol(zbx_nl2br($ack['message']), 'wraptext'))); } return $table; }
/** * Generate acknowledgement table * * @param array $event * @param array $event['acknowledges'] * @param array $event['acknowledges']['clock'] * @param array $event['acknowledges']['alias'] * @param array $event['acknowledges']['message'] * * @return CTableInfo */ function makeAckTab($event) { $table = new CTableInfo(_('No acknowledges defined.')); $table->setHeader(array(_('Time'), _('User'), _('Comments'))); if (!empty($event['acknowledges']) && is_array($event['acknowledges'])) { foreach ($event['acknowledges'] as $ack) { $table->addRow(array(zbx_date2str(_('d M Y H:i:s'), $ack['clock']), $ack['alias'], new CCol(zbx_nl2br($ack['message']), 'wraptext'))); } } return $table; }
/** * Get acknowledgement table. * * @param array $event * @param array $event['acknowledges'] * @param array $event['acknowledges']['clock'] * @param array $event['acknowledges']['alias'] * @param array $event['acknowledges']['message'] * * @return CTableInfo */ function makeAckTab($event) { $acknowledgeTable = new CTableInfo(_('No acknowledges found.')); $acknowledgeTable->setHeader(array(_('Time'), _('User'), _('Comments'))); if (!empty($event['acknowledges']) && is_array($event['acknowledges'])) { foreach ($event['acknowledges'] as $acknowledge) { $acknowledgeTable->addRow(array(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $acknowledge['clock']), getUserFullname($acknowledge), new CCol(zbx_nl2br($acknowledge['message']), 'wraptext'))); } } return $acknowledgeTable; }
function make_acktab_by_eventid($eventid) { $table = new CTableInfo(); $table->SetHeader(array(S_TIME, S_USER, S_COMMENTS)); $acks = get_acknowledges_by_eventid($eventid); while ($ack = DBfetch($acks)) { //$users = CUser::get(array('userids' => $ack['userid'], 'output' => API_OUTPUT_EXTEND)); //$user = reset($users); $table->addRow(array(zbx_date2str(S_ACKNOWINC_BY_EVENTS_DATE_FORMAT, $ack['clock']), $ack['alias'], new CCol(zbx_nl2br($ack['message']), 'wraptext'))); } return $table; }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $output = array(); $stime = zbxDateToTime($this->timeline['stime']); $iv_string = array(ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1); $iv_numeric = array(ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1); if ($this->action == 'showvalues' || $this->action == 'showlatest') { $options = array('history' => $this->item['value_type'], 'itemids' => array_keys($this->items), 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN); if ($this->action == 'showlatest') { $options['limit'] = 500; } elseif ($this->action == 'showvalues') { $config = select_config(); $options['time_from'] = $stime - 10; // some seconds to allow script to execute $options['time_till'] = $stime + $this->timeline['period']; $options['limit'] = $config['search_limit']; } // text log if (isset($iv_string[$this->item['value_type']])) { $isManyItems = count($this->items) > 1; $useLogItem = $this->item['value_type'] == ITEM_VALUE_TYPE_LOG; $useEventLogItem = strpos($this->item['key_'], 'eventlog[') === 0; if (empty($this->plaintext)) { $historyTable = new CTableInfo(_('No values found.')); $historyTable->setHeader(array(_('Timestamp'), $isManyItems ? _('Item') : null, $useLogItem ? _('Local time') : null, $useEventLogItem && $useLogItem ? _('Source') : null, $useEventLogItem && $useLogItem ? _('Severity') : null, $useEventLogItem && $useLogItem ? _('Event ID') : null, _('Value')), 'header'); } if (!zbx_empty($this->filter) && in_array($this->filterTask, array(FILTER_TASK_SHOW, FILTER_TASK_HIDE))) { $options['search'] = array('value' => $this->filter); if ($this->filterTask == FILTER_TASK_HIDE) { $options['excludeSearch'] = 1; } } $options['sortfield'] = 'id'; $historyData = API::History()->get($options); foreach ($historyData as $data) { $data['value'] = encode_log(trim($data['value'], "\r\n")); if (empty($this->plaintext)) { $item = $this->items[$data['itemid']]; $host = reset($item['hosts']); $color = null; if (isset($this->filter) && !zbx_empty($this->filter)) { $contain = zbx_stristr($data['value'], $this->filter); if ($contain && $this->filterTask == FILTER_TASK_MARK) { $color = $this->markColor; } if (!$contain && $this->filterTask == FILTER_TASK_INVERT_MARK) { $color = $this->markColor; } switch ($color) { case MARK_COLOR_RED: $color = 'red'; break; case MARK_COLOR_GREEN: $color = 'green'; break; case MARK_COLOR_BLUE: $color = 'blue'; break; } } $row = array(nbsp(zbx_date2str(_('Y.M.d H:i:s'), $data['clock']))); if ($isManyItems) { $row[] = $host['name'] . NAME_DELIMITER . $item['name_expanded']; } if ($useLogItem) { $row[] = $data['timestamp'] == 0 ? '-' : zbx_date2str(HISTORY_LOG_LOCALTIME_DATE_FORMAT, $data['timestamp']); // if this is a eventLog item, showing additional info if ($useEventLogItem) { $row[] = zbx_empty($data['source']) ? '-' : $data['source']; $row[] = $data['severity'] == 0 ? '-' : new CCol(get_item_logtype_description($data['severity']), get_item_logtype_style($data['severity'])); $row[] = $data['logeventid'] == 0 ? '-' : $data['logeventid']; } } $row[] = new CCol($data['value'], 'pre'); $newRow = new CRow($row); if (!is_null($color)) { $newRow->setAttribute('class', $color); } $historyTable->addRow($newRow); } else { $output[] = zbx_date2str(HISTORY_LOG_ITEM_PLAINTEXT, $data['clock']); $output[] = "\t" . $data['clock'] . "\t" . htmlspecialchars($data['value']) . "\n"; } } if (empty($this->plaintext)) { $output[] = $historyTable; } } else { if (empty($this->plaintext)) { $historyTable = new CTableInfo(_('No values found.')); $historyTable->setHeader(array(_('Timestamp'), _('Value'))); } $options['sortfield'] = array('itemid', 'clock'); $historyData = API::History()->get($options); foreach ($historyData as $data) { $item = $this->items[$data['itemid']]; $value = $data['value']; // format the value as float if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) { sscanf($data['value'], '%f', $value); } // html table if (empty($this->plaintext)) { if ($item['valuemapid']) { $value = applyValueMap($value, $item['valuemapid']); } $historyTable->addRow(array(zbx_date2str(HISTORY_ITEM_DATE_FORMAT, $data['clock']), zbx_nl2br($value))); } else { $output[] = zbx_date2str(HISTORY_PLAINTEXT_DATE_FORMAT, $data['clock']); $output[] = "\t" . $data['clock'] . "\t" . htmlspecialchars($value) . "\n"; } } if (empty($this->plaintext)) { $output[] = $historyTable; } } } if ($this->action == 'showgraph' && !isset($iv_string[$this->item['value_type']])) { $this->dataId = 'historyGraph'; $containerId = 'graph_cont1'; $src = 'chart.php?itemid=' . $this->item['itemid'] . '&period=' . $this->timeline['period'] . '&stime=' . $this->timeline['stime'] . $this->getProfileUrlParams(); $output[] = new CDiv(null, 'center', $containerId); } // time control if (!$this->plaintext && str_in_array($this->action, array('showvalues', 'showgraph'))) { $graphDims = getGraphDims(); $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($this->item['itemid'])); $timeControlData = array('periodFixed' => CProfile::get('web.history.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); if (!empty($this->dataId)) { $timeControlData['id'] = $this->getDataId(); $timeControlData['containerid'] = $containerId; $timeControlData['src'] = $src; $timeControlData['objDims'] = $graphDims; $timeControlData['loadSBox'] = 1; $timeControlData['loadImage'] = 1; $timeControlData['dynamic'] = 1; } else { $this->dataId = 'historyGraph'; $timeControlData['id'] = $this->getDataId(); $timeControlData['mainObject'] = 1; } if ($this->mode == SCREEN_MODE_JS) { $timeControlData['dynamic'] = 0; return 'timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'; } else { zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . zbx_jsvalue($this->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); } } if (!empty($this->plaintext)) { return $output; } else { if ($this->mode != SCREEN_MODE_JS) { $flickerfreeData = array('itemids' => $this->itemids, 'action' => $this->action, 'filter' => $this->filter, 'filterTask' => $this->filterTask, 'markColor' => $this->markColor); return $this->getOutput($output, true, $flickerfreeData); } } }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $output = []; $items = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'], 'selectHosts' => ['name'], 'itemids' => $this->itemids, 'webitems' => true, 'preservekeys' => true]); $items = CMacrosResolverHelper::resolveItemNames($items); $stime = zbxDateToTime($this->timeline['stime']); $firstItem = reset($items); $iv_string = [ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1]; $iv_numeric = [ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1]; if ($this->action == HISTORY_VALUES || $this->action == HISTORY_LATEST) { $options = ['history' => $firstItem['value_type'], 'itemids' => $this->itemids, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN]; if ($this->action == HISTORY_LATEST) { $options['limit'] = 500; } elseif ($this->action == HISTORY_VALUES) { $config = select_config(); // interval start value is non-inclusive, hence the + 1 second $options['time_from'] = $stime + 1; $options['time_till'] = $stime + $this->timeline['period']; $options['limit'] = $config['search_limit']; } // text log if (isset($iv_string[$firstItem['value_type']])) { $isManyItems = count($items) > 1; $useLogItem = $firstItem['value_type'] == ITEM_VALUE_TYPE_LOG; $useEventLogItem = strpos($firstItem['key_'], 'eventlog[') === 0; if (empty($this->plaintext)) { $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), $isManyItems ? _('Item') : null, $useLogItem ? (new CColHeader(_('Local time')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Source')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Severity')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Event ID')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Value')]); } if ($this->filter !== '' && in_array($this->filterTask, [FILTER_TASK_SHOW, FILTER_TASK_HIDE])) { $options['search'] = ['value' => $this->filter]; if ($this->filterTask == FILTER_TASK_HIDE) { $options['excludeSearch'] = 1; } } $options['sortfield'] = 'id'; $historyData = API::History()->get($options); foreach ($historyData as $data) { $data['value'] = rtrim($data['value'], " \t\r\n"); if (empty($this->plaintext)) { $item = $items[$data['itemid']]; $host = reset($item['hosts']); $color = null; if ($this->filter !== '') { $haystack = mb_strtolower($data['value']); $needle = mb_strtolower($this->filter); $pos = mb_strpos($haystack, $needle); if ($pos !== false && $this->filterTask == FILTER_TASK_MARK) { $color = $this->markColor; } elseif ($pos === false && $this->filterTask == FILTER_TASK_INVERT_MARK) { $color = $this->markColor; } switch ($color) { case MARK_COLOR_RED: $color = ZBX_STYLE_RED; break; case MARK_COLOR_GREEN: $color = ZBX_STYLE_GREEN; break; case MARK_COLOR_BLUE: $color = ZBX_STYLE_BLUE; break; } } $row = []; $row[] = (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color); if ($isManyItems) { $row[] = (new CCol($host['name'] . NAME_DELIMITER . $item['name_expanded']))->addClass($color); } if ($useLogItem) { $row[] = $data['timestamp'] != 0 ? (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['timestamp'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : ''; // if this is a eventLog item, showing additional info if ($useEventLogItem) { $row[] = (new CCol($data['source']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color); $row[] = $data['severity'] != 0 ? (new CCol(get_item_logtype_description($data['severity'])))->addClass(ZBX_STYLE_NOWRAP)->addClass(get_item_logtype_style($data['severity'])) : ''; $row[] = $data['logeventid'] != 0 ? (new CCol($data['logeventid']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : ''; } } $row[] = (new CCol(new CPre(zbx_nl2br($data['value']))))->addClass($color); $historyTable->addRow($row); } else { $output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($data['value']); } } if (empty($this->plaintext)) { $output[] = $historyTable; } } else { if (empty($this->plaintext)) { $historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), _('Value')]); } $options['sortfield'] = ['itemid', 'clock']; $historyData = API::History()->get($options); foreach ($historyData as $data) { $item = $items[$data['itemid']]; $value = rtrim($data['value'], " \t\r\n"); // format the value as float if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) { sscanf($data['value'], '%f', $value); } // html table if (empty($this->plaintext)) { if ($item['valuemapid']) { $value = applyValueMap($value, $item['valuemapid']); } $historyTable->addRow([(new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP), new CPre(zbx_nl2br($value))]); } else { $output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($value); } } if (empty($this->plaintext)) { $output[] = $historyTable; } } } // time control if (!$this->plaintext && str_in_array($this->action, [HISTORY_VALUES, HISTORY_GRAPH, HISTORY_BATCH_GRAPH])) { $graphDims = getGraphDims(); $this->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($firstItem['itemid'])); $this->dataId = 'historyGraph'; $timeControlData = ['periodFixed' => CProfile::get('web.history.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD]; if (($this->action == HISTORY_GRAPH || $this->action == HISTORY_BATCH_GRAPH) && !isset($iv_string[$firstItem['value_type']])) { $containerId = 'graph_cont1'; $output[] = (new CDiv())->addClass('center')->setId($containerId); $timeControlData['id'] = $this->getDataId(); $timeControlData['containerid'] = $containerId; $timeControlData['src'] = $this->getGraphUrl($this->itemids); $timeControlData['objDims'] = $graphDims; $timeControlData['loadSBox'] = 1; $timeControlData['loadImage'] = 1; $timeControlData['dynamic'] = 1; } else { $timeControlData['id'] = $this->getDataId(); $timeControlData['mainObject'] = 1; } if ($this->mode == SCREEN_MODE_JS) { $timeControlData['dynamic'] = 0; return 'timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');'; } else { zbx_add_post_js('timeControl.addObject("' . $this->getDataId() . '", ' . CJs::encodeJson($this->timeline) . ', ' . CJs::encodeJson($timeControlData) . ');'); } } if (!empty($this->plaintext)) { return $output; } else { if ($this->mode != SCREEN_MODE_JS) { $flickerfreeData = ['itemids' => $this->itemids, 'action' => $this->action == HISTORY_BATCH_GRAPH ? HISTORY_GRAPH : $this->action, 'filter' => $this->filter, 'filterTask' => $this->filterTask, 'markColor' => $this->markColor]; return $this->getOutput($output, true, $flickerfreeData); } } }
if ($alert['status'] == ALERT_STATUS_SENT) { if ($alert['alerttype'] == ALERT_TYPE_MESSAGE) { $status = new CSpan(_('sent'), 'green'); } else { $status = new CSpan(_('executed'), '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'); } if ($alert['alerttype'] == ALERT_TYPE_MESSAGE) { $message = array(bold(_('Subject') . ': '), br(), $alert['subject'], br(), br(), bold(_('Message') . ': '), br(), zbx_nl2br($alert['message'])); } else { $message = array(bold(_('Command') . ': '), br(), zbx_nl2br($alert['message'])); } $error = empty($alert['error']) ? new CSpan(SPACE, 'off') : new CSpan($alert['error'], 'on'); $auditTable->addRow(array(get_node_name_by_elid($alert['alertid']), new CCol(zbx_date2str(_('d M Y H:i:s'), $alert['clock']), 'top'), new CCol($mediatype['description'], 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($alert['sendto'], 'top'), new CCol($message, 'wraptext top'), new CCol($error, 'wraptext 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;
/* * Display */ show_table_header(array(_('ALARM ACKNOWLEDGES') . NAME_DELIMITER, $bulk ? ' BULK ACKNOWLEDGE ' : $eventTriggerName)); echo SBR; if ($bulk) { $title = _('Acknowledge alarm by'); $saveAndReturnLabel = _('Acknowledge and return'); } else { $acknowledges = DBselect('SELECT a.*,u.alias,u.name,u.surname' . ' FROM acknowledges a' . ' LEFT JOIN users u ON u.userid=a.userid' . ' WHERE a.eventid=' . zbx_dbstr($_REQUEST['eventid'])); if ($acknowledges) { $acknowledgesTable = new CTable(null, 'ack_msgs'); $acknowledgesTable->setAlign('center'); while ($acknowledge = DBfetch($acknowledges)) { $acknowledgesTable->addRow(array(new CCol(getUserFullname($acknowledge), 'user'), new CCol(zbx_date2str(_('d M Y H:i:s'), $acknowledge['clock']), 'time')), 'title'); $acknowledgesTable->addRow(new CCol(zbx_nl2br($acknowledge['message']), null, 2), 'msg'); } $acknowledgesTable->show(); } if ($eventAcknowledged) { $title = _('Add comment by'); $saveLabel = _('Save'); $saveAndReturnLabel = _('Save and return'); } else { $title = _('Acknowledge alarm by'); $saveLabel = _('Acknowledge'); $saveAndReturnLabel = _('Acknowledge and return'); } } $messageTable = new CFormTable($title . ' "' . getUserFullname(CWebUser::$data) . '"'); $messageTable->addVar('backurl', $_REQUEST['backurl']);
foreach ($scripts as $script) { $description = new CLink($script['name'], 'javascript:void(0);'); if ($multiselect) { $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($script['scriptid']) . ');'; } else { $values = [$dstfld1 => $script[$srcfld1], $dstfld2 => $script[$srcfld2]]; $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;'; } $description->onClick($js_action . ' jQuery(this).removeAttr("onclick");'); if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT: $scriptExecuteOn = _('Agent'); break; case ZBX_SCRIPT_EXECUTE_ON_SERVER: $scriptExecuteOn = _('Server'); break; } } else { $scriptExecuteOn = ''; } $table->addRow([$multiselect ? new CCheckBox('scripts[' . zbx_jsValue($script[$srcfld1]) . ']', $script['scriptid']) : null, $description, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8'))]); } if ($multiselect) { $table->setFooter(new CCol((new CButton('select', _('Select')))->onClick("javascript: addSelectedValues('scripts', " . zbx_jsvalue($reference) . ');'))); insert_js('var popupReference = ' . zbx_jsvalue($scripts, true) . ';'); } $form->addItem($table); $widget->addItem($form)->show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
function get_screen_plaintext($itemid, $elements, $style = 0) { if ($itemid == 0) { $table = new CTableInfo(S_ITEM_DOES_NOT_EXIST); $table->setHeader(array(S_TIMESTAMP, S_ITEM)); return $table; } global $DB; $item = get_item_by_itemid($itemid); switch ($item['value_type']) { case ITEM_VALUE_TYPE_FLOAT: $history_table = 'history'; $order_field = 'clock'; break; case ITEM_VALUE_TYPE_UINT64: $history_table = 'history_uint'; $order_field = 'clock'; break; case ITEM_VALUE_TYPE_TEXT: $history_table = 'history_text'; $order_field = 'id'; break; case ITEM_VALUE_TYPE_LOG: $history_table = 'history_log'; $order_field = 'id'; break; default: $history_table = 'history_str'; $order_field = 'clock'; break; } $sql = 'SELECT h.clock,h.value,i.valuemapid ' . ' FROM ' . $history_table . ' h, items i ' . ' WHERE h.itemid=i.itemid ' . ' AND i.itemid=' . $itemid . ' ORDER BY h.' . $order_field . ' DESC'; $result = DBselect($sql, $elements); $host = get_host_by_itemid($itemid); $table = new CTableInfo(); $table->setHeader(array(S_TIMESTAMP, $host['host'] . ': ' . item_description($item))); while ($row = DBfetch($result)) { switch ($item['value_type']) { case ITEM_VALUE_TYPE_TEXT: if ($DB['TYPE'] == 'ORACLE') { if (isset($row['value'])) { $row['value'] = $row['value']->load(); } else { $row['value'] = ''; } } /* do not use break */ /* do not use break */ case ITEM_VALUE_TYPE_STR: if ($style) { $value = new CScript($row['value']); } else { $value = nbsp(htmlspecialchars($row['value'])); $value = zbx_nl2br($value); } break; case ITEM_VALUE_TYPE_LOG: if ($style) { $value = new CScript($row['value']); } else { $value = nbsp(htmlspecialchars($row['value'])); $value = zbx_nl2br($value); } break; default: $value = $row['value']; break; } if ($row['valuemapid'] > 0) { $value = replace_value_by_map($value, $row['valuemapid']); } $table->AddRow(array(date(S_DATE_FORMAT_YMDHMS, $row['clock']), $value)); } return $table; }
function stage1() { $LICENCE_FILE = 'conf/COPYING'; $this->DISABLE_NEXT_BUTTON = true; $license = 'Missing licence file. See GPL licence.'; if (file_exists($LICENCE_FILE)) { $license = zbx_nl2br(nbsp(file_get_contents($LICENCE_FILE))); } $action = <<<JS if(this.checked) \$("next[1]").writeAttribute('disabled', false); else \$("next[1]").writeAttribute('disabled', 'disabled'); JS; return array(new CDiv(new CSpan($license), 'licence'), BR(), new CDiv(array(new CCheckBox('agree', 'no', $action), new CLabel('I agree', 'agree')), 'center')); }
} $widget = (new CWidget())->setTitle(_('Scripts'))->setControls((new CForm())->cleanItems()->addItem((new CList())->addItem(new CRedirectButton(_('Create script'), 'zabbix.php?action=script.edit')))); $scriptsForm = (new CForm())->setName('scriptsForm')->setId('scripts'); $scriptsTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_scripts'))->onClick("checkAll('" . $scriptsForm->getName() . "', 'all_scripts', 'scriptids');")))->addClass(ZBX_STYLE_CELL_WIDTH), make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder']), _('Type'), _('Execute on'), make_sorting_header(_('Commands'), 'command', $data['sort'], $data['sortorder']), _('User group'), _('Host group'), _('Host access')]); foreach ($data['scripts'] as $script) { switch ($script['type']) { case ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT: $scriptType = _('Script'); break; case ZBX_SCRIPT_TYPE_IPMI: $scriptType = _('IPMI'); break; } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT: $scriptExecuteOn = _('Agent'); break; case ZBX_SCRIPT_EXECUTE_ON_SERVER: $scriptExecuteOn = _('Server'); break; } } else { $scriptExecuteOn = ''; } $scriptsTable->addRow([new CCheckBox('scriptids[' . $script['scriptid'] . ']', $script['scriptid']), (new CCol(new CLink($script['name'], 'zabbix.php?action=script.edit&scriptid=' . $script['scriptid'])))->addClass(ZBX_STYLE_NOWRAP), $scriptType, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8')), $script['userGroupName'] === null ? _('All') : $script['userGroupName'], $script['hostGroupName'] === null ? _('All') : $script['hostGroupName'], $script['host_access'] == PERM_READ_WRITE ? _('Write') : _('Read')]); } // append table to form $scriptsForm->addItem([$scriptsTable, $data['paging'], new CActionButtonList('action', 'scriptids', ['script.delete' => ['name' => _('Delete'), 'confirm' => _('Delete selected scripts?')]])]); // append form to widget $widget->addItem($scriptsForm)->show();
} redirect($last_page['url']); exit; } } } $msg = $bulk ? ' BULK ACKNOWLEDGE ' : array('"' . expand_trigger_description_by_data($db_data) . '"', BR(), explode_exp($db_data["expression"], 1)); show_table_header(array(S_ALARM_ACKNOWLEDGES_BIG, ' : ', $msg)); echo SBR; if (!$bulk) { $table = new CTable(NULL, "ack_msgs"); $table->SetAlign("center"); $db_acks = get_acknowledges_by_eventid($db_data["eventid"]); while ($db_ack = DBfetch($db_acks)) { $db_user = get_user_by_userid($db_ack["userid"]); $table->AddRow(array(new CCol($db_user["alias"], "user"), new CCol(date("d-m-Y h:i:s A", $db_ack["clock"]), "time")), "title"); $msgCol = new CCol(zbx_nl2br($db_ack['message'])); $msgCol->SetColspan(2); $table->AddRow($msgCol, "msg"); } /**/ if ($table->GetNumRows() > 0) { $table->Show(); echo SBR; } } insert_new_message_form($events, $bulk); ?> <?php include_once "include/page_footer.php";
} if ($row['source'] == '') { array_push($new_row, new CCol(' - ')); } else { array_push($new_row, $row['source']); } array_push($new_row, new CCol(get_severity_description($row['severity']), get_severity_style($row['severity']))); if ($row['source'] == '' && $row['logeventid'] == '0') { array_push($new_row, new CCol(' - ')); } else { array_push($new_row, $row['logeventid']); } $row['value'] = trim($row['value'], "\r\n"); $row['value'] = encode_log($row['value']); // array_push($new_row,htmlspecialchars($row['value'])); array_push($new_row, zbx_nl2br($row['value'])); if (!isset($_REQUEST['plaintext'])) { $crow = new CRow($new_row); if (is_null($color_style) && is_array($_REQUEST['itemid'])) { $min_color = 0x98; $max_color = 0xf8; $int_color = ($max_color - $min_color) / count($_REQUEST['itemid']); $int_color *= array_search($row['itemid'], $_REQUEST['itemid']); $int_color += $min_color; $crow->setAttribute('style', 'background-color: ' . sprintf("#%X%X%X", $int_color, $int_color, $int_color)); } else { $crow->setClass($color_style); } $crow->Show(); // to solve memory leak we call 'Show' method for each element } else {
function get_action_cmds_for_event($event) { $table = new CTableInfo(_('No actions found.')); $table->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, _('Time'), _('Status'), _('Command'), _('Error'))); $alerts = $event['alerts']; foreach ($alerts as $alert) { if ($alert['alerttype'] != ALERT_TYPE_COMMAND) { continue; } $time = zbx_date2str(EVENT_ACTION_CMDS_DATE_FORMAT, $alert['clock']); if ($alert['esc_step'] > 0) { $time = array(bold(_('Step') . NAME_DELIMITER), $alert['esc_step'], br(), bold(_('Time') . NAME_DELIMITER), br(), $time); } switch ($alert['status']) { case ALERT_STATUS_SENT: $status = new CSpan(_('executed'), 'green'); break; case ALERT_STATUS_NOT_SENT: $status = new CSpan(_('In progress'), 'orange'); break; default: $status = new CSpan(_('not sent'), 'red'); break; } $message = array(bold(_('Command') . NAME_DELIMITER)); array_push($message, BR(), zbx_nl2br($alert['message'])); $error = empty($alert['error']) ? new CSpan(SPACE, 'off') : new CSpan($alert['error'], 'on'); $table->addRow(array(get_node_name_by_elid($alert['alertid']), new CCol($time, 'top'), new CCol($status, 'top'), new CCol($message, 'wraptext top'), new CCol($error, 'wraptext top'))); } return $table; }
$filterForm->addNavigator(); $auditWidget->addItem($filterForm); // create form $auditForm = (new CForm('get'))->setName('auditForm'); // create table $auditTable = (new CTableInfo())->setHeader([_('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')))->addClass(ZBX_STYLE_GREEN) : (new CSpan(_('Executed')))->addClass(ZBX_STYLE_GREEN); } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) { $status = (new CSpan([_('In progress') . ':', BR(), _n('%1$s retry left', '%1$s retries left', ALERT_MAX_RETRIES - $alert['retries'])]))->addClass(ZBX_STYLE_YELLOW); } else { $status = (new CSpan(_('Not sent')))->addClass(ZBX_STYLE_RED); } $message = $alert['alerttype'] == ALERT_TYPE_MESSAGE ? [bold(_('Subject') . ':'), BR(), $alert['subject'], BR(), BR(), bold(_('Message') . ':'), BR(), zbx_nl2br($alert['message'])] : [bold(_('Command') . ':'), BR(), zbx_nl2br($alert['message'])]; if (zbx_empty($alert['error'])) { $info = ''; } else { $info = makeErrorIcon($alert['error']); } $recipient = isset($alert['userid']) && $alert['userid'] ? [bold(getUserFullname($this->data['users'][$alert['userid']])), BR(), $alert['sendto']] : $alert['sendto']; $auditTable->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']), $this->data['actions'][$alert['actionid']]['name'], $mediatype ? $mediatype['description'] : '', $recipient, $message, $status, $info]); } // append table to form $auditForm->addItem([$auditTable, $this->data['paging']]); // append navigation bar js $objData = ['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
$mediatype = array_pop($alert['mediatypes']); if ($mediatype['mediatypeid'] == 0) { $mediatype = array('description' => ''); } if ($alert['status'] == ALERT_STATUS_SENT) { if ($alert['alerttype'] == ALERT_TYPE_MESSAGE) { $status = new CSpan(_('sent'), 'green'); } else { $status = new CSpan(_('executed'), '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'); } $message = $alert['alerttype'] == ALERT_TYPE_MESSAGE ? array(bold(_('Subject') . NAME_DELIMITER), BR(), $alert['subject'], BR(), BR(), bold(_('Message') . NAME_DELIMITER), BR(), zbx_nl2br($alert['message'])) : array(bold(_('Command') . NAME_DELIMITER), BR(), zbx_nl2br($alert['message'])); $error = empty($alert['error']) ? new CSpan(SPACE, 'off') : new CSpan($alert['error'], 'on'); $auditTable->addRow(array(get_node_name_by_elid($alert['alertid']), new CCol(zbx_date2str(_('d M Y H:i:s'), $alert['clock']), 'top'), new CCol($mediatype['description'], 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($alert['sendto'], 'top'), new CCol($message, 'wraptext top'), new CCol($error, 'wraptext 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;
$item = $items[$data['itemid']]; $host = reset($item['hosts']); if (!isset($data['value'])) { $data['value'] = ''; } if ($item['valuemapid'] > 0) { $value = replace_value_by_map($data['value'], $item['valuemapid']); $value_mapped = true; } else { $value = $data['value']; $value_mapped = false; } if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT && !$value_mapped) { sscanf($data['value'], '%f', $value); } $table->addRow(array(zbx_date2str(S_HISTORY_ITEM_DATE_FORMAT, $data['clock']), zbx_nl2br($value))); // Plaintext if (!isset($_REQUEST['plaintext'])) { continue; } if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT) { sscanf($data['value'], '%f', $value); } else { $value = $data['value']; } $ptData['body'][] = zbx_date2str(S_HISTORY_PLAINTEXT_DATE_FORMAT, $data['clock']); $ptData['body'][] = "\t" . $data['clock'] . "\t" . htmlspecialchars($value) . "\n"; } } } if ($_REQUEST['action'] == 'showgraph' && !isset($iv_string[$item['value_type']])) {
default: $scriptType = ''; break; } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT: $scriptExecuteOn = _('Agent'); break; case ZBX_SCRIPT_EXECUTE_ON_SERVER: $scriptExecuteOn = _('Server'); break; } } else { $scriptExecuteOn = ''; } $scriptsTable->addRow(array(new CCheckBox('scripts[' . $script['scriptid'] . ']', 'no', null, $script['scriptid']), new CLink($script['name'], 'scripts.php?form=1&scriptid=' . $script['scriptid']), $scriptType, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8')), $script['userGroupName'] ? $script['userGroupName'] : _('All'), $script['hostGroupName'] ? $script['hostGroupName'] : _('All'), $script['host_access'] == PERM_READ_WRITE ? _('Write') : _('Read'))); } // create go buttons $goComboBox = new CComboBox('action'); $goOption = new CComboItem('script.massdelete', _('Delete selected')); $goOption->setAttribute('confirm', _('Delete selected scripts?')); $goComboBox->addItem($goOption); $goButton = new CSubmit('goButton', _('Go') . ' (0)'); $goButton->setAttribute('id', 'goButton'); zbx_add_post_js('chkbxRange.pageGoName = "scripts";'); // append table to form $scriptsForm->addItem(array($this->data['paging'], $scriptsTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton)))); // append form to widget $scriptsWidget->addItem($scriptsForm); return $scriptsWidget;
/** * Get action remote commands. * * @param array $alerts * @param string $alerts[n]['alertid'] * @param int $alerts[n]['alerttype'] * @param string $alerts[n]['clock'] * @param int $alerts[n]['esc_step'] * @param int $alerts[n]['status'] * @param string $alerts[n]['message'] * @param string $alerts[n]['error'] * * @return CTableInfo */ function getActionCommands(array $alerts) { $table = new CTableInfo(_('No actions found.')); $table->setHeader(array(_('Time'), _('Status'), _('Command'), _('Error'))); foreach ($alerts as $alert) { if ($alert['alerttype'] != ALERT_TYPE_COMMAND) { continue; } $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); } switch ($alert['status']) { case ALERT_STATUS_SENT: $status = new CSpan(_('executed'), 'green'); break; case ALERT_STATUS_NOT_SENT: $status = new CSpan(_('In progress'), 'orange'); break; default: $status = new CSpan(_('not sent'), 'red'); break; } $error = $alert['error'] ? new CSpan($alert['error'], 'on') : new CSpan(SPACE, 'off'); $table->addRow(array(new CCol($time, 'top'), new CCol($status, 'top'), new CCol(array(bold(_('Command') . NAME_DELIMITER), BR(), zbx_nl2br($alert['message'])), 'wraptext top'), new CCol($error, 'wraptext top'))); } return $table; }
$values = array($dstfld1 => $script[$srcfld1], $dstfld2 => $script[$srcfld2]); $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); close_window(); return false;'; } $description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");'); if ($multiselect) { $description = new CCol(array(new CCheckBox('scripts[' . zbx_jsValue($script[$srcfld1]) . ']', null, null, $script['scriptid']), $description)); } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) { switch ($script['execute_on']) { case ZBX_SCRIPT_EXECUTE_ON_AGENT: $scriptExecuteOn = _('Agent'); break; case ZBX_SCRIPT_EXECUTE_ON_SERVER: $scriptExecuteOn = _('Server'); break; } } else { $scriptExecuteOn = ''; } $table->addRow(array($description, $scriptExecuteOn, zbx_nl2br(htmlspecialchars($script['command'], ENT_COMPAT, 'UTF-8')))); } if ($multiselect) { $button = new CButton('select', _('Select'), "javascript: addSelectedValues('scripts', " . zbx_jsvalue($reference) . ');'); $table->setFooter(new CCol($button, 'right')); insert_js('var popupReference = ' . zbx_jsvalue($scripts, true) . ';'); } zbx_add_post_js('chkbxRange.pageGoName = "scripts";'); $form->addItem($table); $form->show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $sortfield = 'clock'; $sortorder = ZBX_SORT_DOWN; switch ($this->screenitem['sort_triggers']) { case SCREEN_SORT_TRIGGERS_TIME_ASC: $sortfield = 'clock'; $sortorder = ZBX_SORT_UP; break; case SCREEN_SORT_TRIGGERS_TIME_DESC: $sortfield = 'clock'; $sortorder = ZBX_SORT_DOWN; break; case SCREEN_SORT_TRIGGERS_TYPE_ASC: $sortfield = 'description'; $sortorder = ZBX_SORT_UP; break; case SCREEN_SORT_TRIGGERS_TYPE_DESC: $sortfield = 'description'; $sortorder = ZBX_SORT_DOWN; break; case SCREEN_SORT_TRIGGERS_STATUS_ASC: $sortfield = 'status'; $sortorder = ZBX_SORT_UP; break; case SCREEN_SORT_TRIGGERS_STATUS_DESC: $sortfield = 'status'; $sortorder = ZBX_SORT_DOWN; break; case SCREEN_SORT_TRIGGERS_RECIPIENT_ASC: $sortfield = 'sendto'; $sortorder = ZBX_SORT_UP; break; case SCREEN_SORT_TRIGGERS_RECIPIENT_DESC: $sortfield = 'sendto'; $sortorder = ZBX_SORT_DOWN; 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); $userids = []; foreach ($alerts as $alert) { if ($alert['userid'] != 0) { $userids[$alert['userid']] = true; } } if ($userids) { $dbUsers = API::User()->get(['output' => ['userid', 'alias', 'name', 'surname'], 'userids' => array_keys($userids), 'preservekeys' => true]); } // indicator of sort field $sort_div = (new CSpan())->addClass($sortorder === ZBX_SORT_DOWN ? ZBX_STYLE_ARROW_DOWN : ZBX_STYLE_ARROW_UP); // create alert table $table = (new CTableInfo())->setHeader([$sortfield === 'clock' ? ['Time', $sort_div] : _('Time'), _('Action'), $sortfield === 'description' ? [_('Type'), $sort_div] : _('Type'), $sortfield === 'sendto' ? [_('Recipient(s)'), $sort_div] : _('Recipient(s)'), _('Message'), $sortfield === 'status' ? [_('Status'), $sort_div] : _('Status'), _('Info')]); $actions = API::Action()->get(['output' => ['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')))->addClass(ZBX_STYLE_GREEN); } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) { $status = (new CSpan([_('In progress') . ':', BR(), _n('%1$s retry left', '%1$s retries left', ALERT_MAX_RETRIES - $alert['retries'])]))->addClass(ZBX_STYLE_YELLOW); } else { $status = (new CSpan(_('Not sent')))->addClass(ZBX_STYLE_RED); } $recipient = $alert['userid'] != 0 ? [bold(getUserFullname($dbUsers[$alert['userid']])), BR(), $alert['sendto']] : $alert['sendto']; $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']), $actions[$alert['actionid']]['name'], $alert['mediatypeid'] == 0 ? '' : $alert['description'], $recipient, [bold($alert['subject']), BR(), BR(), zbx_nl2br($alert['message'])], $status, $alert['error'] === '' ? '' : makeErrorIcon($alert['error'])]); } $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT); return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader(_('Action log'))); }
/* ** Zabbix ** Copyright (C) 2001-2016 Zabbix SIA ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $this->includeJSfile('app/views/monitoring.acknowledge.edit.js.php'); $form_list = (new CFormList())->addRow(_('Message'), (new CTextArea('message'))->setWidth(ZBX_TEXTAREA_BIG_WIDTH)->setMaxLength(255)->setAttribute('autofocus', 'autofocus')); if (array_key_exists('event', $data)) { $acknowledgesTable = (new CTable())->setAttribute('style', 'width: 100%;')->setHeader([_('Time'), _('User'), _('Message')]); foreach ($data['event']['acknowledges'] as $acknowledge) { $acknowledgesTable->addRow([(new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $acknowledge['clock'])))->addClass(ZBX_STYLE_NOWRAP), (new CCol(getUserFullname($acknowledge)))->addClass(ZBX_STYLE_NOWRAP), zbx_nl2br($acknowledge['message'])]); } $form_list->addRow(_('History'), (new CDiv($acknowledgesTable))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')); } $selected_events = count($data['eventids']); $form_list->addRow(_('Acknowledge'), (new CDiv((new CRadioButtonList('acknowledge_type', (int) $data['acknowledge_type']))->makeVertical()->addValue([_n('Only selected event', 'Only selected events', $selected_events), $selected_events > 1 ? (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN) : null, $selected_events > 1 ? new CSup(_n('%1$s event', '%1$s events', $selected_events)) : null], ZBX_ACKNOWLEDGE_SELECTED)->addValue([_('Selected and all unacknowledged PROBLEM events'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), new CSup(_n('%1$s event', '%1$s events', $data['unack_problem_events_count']))], ZBX_ACKNOWLEDGE_PROBLEM)->addValue([_('Selected and all unacknowledged events'), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), new CSup(_n('%1$s event', '%1$s events', $data['unack_events_count']))], ZBX_ACKNOWLEDGE_ALL)))->setAttribute('style', 'min-width: ' . ZBX_TEXTAREA_BIG_WIDTH . 'px;')->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)); $footer_buttons = makeFormFooter(new CSubmitButton(_('Acknowledge'), 'action', 'acknowledge.create'), [new CRedirectButton(_('Cancel'), $data['backurl'])]); (new CWidget())->setTitle(_('Alarm acknowledgements'))->addItem((new CForm())->setId('acknowledge_form')->addVar('eventids', $data['eventids'])->addVar('backurl', $data['backurl'])->addItem((new CTabView())->addTab('ackTab', null, $form_list)->setFooter($footer_buttons)))->show();
function makeActionHints($alerts, $mediatypes, $users, $status) { $table = (new CTableInfo())->setHeader([_('Time'), _('User'), _('Details'), _('Status'), _('Info')]); $popup_rows = 0; foreach ($alerts as $alert) { switch ($status) { case ALERT_STATUS_NOT_SENT: $status_str = (new CSpan(_('In progress')))->addClass(ZBX_STYLE_YELLOW); break; case ALERT_STATUS_SENT: $status_str = (new CSpan($alert['alerttype'] == ALERT_TYPE_COMMAND ? _('Executed') : _('Sent')))->addClass(ZBX_STYLE_GREEN); break; default: $status_str = (new CSpan(_('Not sent')))->addClass(ZBX_STYLE_RED); } switch ($alert['alerttype']) { case ALERT_TYPE_MESSAGE: $user = array_key_exists($alert['userid'], $users) ? getUserFullname($users[$alert['userid']]) : ''; $message = array_key_exists($alert['mediatypeid'], $mediatypes) ? $mediatypes[$alert['mediatypeid']]['description'] : ''; break; case ALERT_TYPE_COMMAND: $user = ''; $message = [bold(_('Command') . NAME_DELIMITER), BR(), zbx_nl2br($alert['message'])]; break; default: $user = ''; $message = ''; } $table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $alert['clock']), $user, $message, $status_str, $alert['error'] === '' ? '' : makeErrorIcon($alert['error'])]); if (++$popup_rows == ZBX_WIDGET_ROWS) { break; } } return $table; }