Last active
October 3, 2019 07:28
-
-
Save CHERTS/4fa1fa47c8caab68e52c4de2216d4c84 to your computer and use it in GitHub Desktop.
Show problems and operational data in Zabbix 4.4.0-alfa3 as one line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ./frontends/php/include/blocks.inc.php.orig 2019-09-27 20:57:02.214919180 +0300 | |
+++ ./frontends/php/include/blocks.inc.php 2019-09-27 20:57:14.583818457 +0300 | |
@@ -732,7 +732,6 @@ | |
_('Info'), | |
_('Host'), | |
_('Problem'), | |
- $show_opdata ? _('Operational data') : null, | |
_('Duration'), | |
_('Ack'), | |
_('Actions'), | |
@@ -803,9 +802,8 @@ | |
// operational data | |
$opdata = null; | |
- if ($show_opdata) { | |
- $opdata = ($trigger['opdata'] !== '') | |
- ? (new CCol(CMacrosResolverHelper::resolveTriggerOpdata( | |
+ if ($show_opdata and $trigger['opdata'] !== '') { | |
+ $opdata = ' '.CMacrosResolverHelper::resolveTriggerOpdata( | |
[ | |
'triggerid' => $trigger['triggerid'], | |
'expression' => $trigger['expression'], | |
@@ -815,12 +813,9 @@ | |
], | |
[ | |
'events' => true, | |
- 'html' => true | |
+ 'html' => false | |
] | |
- ))) | |
- ->addClass('opdata') | |
- ->addClass(ZBX_STYLE_WORDWRAP) | |
- : (new CCol(CScreenProblem::getLatestValues($trigger['items'])))->addClass('latest-values'); | |
+ ); | |
} | |
// ack | |
@@ -837,8 +832,7 @@ | |
$table->addRow(array_merge($row, [ | |
makeInformationList($info_icons), | |
$triggers_hosts[$trigger['triggerid']], | |
- getSeverityCell($problem['severity'], null, $problem['name']), | |
- $opdata, | |
+ getSeverityCell($problem['severity'], null, $problem['name'].$opdata), | |
zbx_date2age($problem['clock']), | |
$ack, | |
makeEventActionsIcons($problem['eventid'], $actions['all_actions'], $actions['mediatypes'], | |
--- ./frontends/php/include/events.inc.php.orig 2019-09-27 20:57:02.211919205 +0300 | |
+++ ./frontends/php/include/events.inc.php 2019-09-27 20:57:14.582818465 +0300 | |
@@ -163,11 +163,7 @@ | |
$table = (new CTableInfo()) | |
->addRow([ | |
_('Event'), | |
- $event['name'] | |
- ]) | |
- ->addRow([ | |
- _('Operational data'), | |
- $event['opdata'] | |
+ $event['name'].$event['opdata'] | |
]) | |
->addRow([ | |
_('Severity'), | |
--- ./frontends/php/include/classes/screens/CScreenProblem.php.orig 2019-09-27 10:44:12.000000000 +0300 | |
+++ ./frontends/php/include/classes/screens/CScreenProblem.php 2019-09-27 20:57:14.582818465 +0300 | |
@@ -921,7 +921,6 @@ | |
_('Info'), | |
make_sorting_header(_('Host'), 'host', $this->data['sort'], $this->data['sortorder'], $link), | |
make_sorting_header(_('Problem'), 'name', $this->data['sort'], $this->data['sortorder'], $link), | |
- $this->data['filter']['show_opdata'] ? _('Operational data') : null, | |
_('Duration'), | |
_('Ack'), | |
_('Actions'), | |
@@ -1050,6 +1049,27 @@ | |
$description[] = (new CLinkAction($problem['name'])) | |
->setMenuPopup(CMenuPopupHelper::getTrigger($trigger['triggerid'], $problem['eventid'])); | |
+ $opdata = null; | |
+ if ($show_opdata and $trigger['opdata'] !== '') { | |
+ $description[] = ' '; | |
+ $opdata = (new CSpan(CMacrosResolverHelper::resolveTriggerOpdata( | |
+ [ | |
+ 'triggerid' => $trigger['triggerid'], | |
+ 'expression' => $trigger['expression'], | |
+ 'opdata' => $trigger['opdata'], | |
+ 'clock' => ($problem['r_eventid'] != 0) ? $problem['r_clock'] : $problem['clock'], | |
+ 'ns' => ($problem['r_eventid'] != 0) ? $problem['r_ns'] : $problem['ns'] | |
+ ], | |
+ [ | |
+ 'events' => true, | |
+ 'html' => true | |
+ ] | |
+ ))) | |
+ ->addClass('opdata') | |
+ ->addClass(ZBX_STYLE_NOWRAP); | |
+ $description[] = $opdata; | |
+ } | |
+ | |
if ($this->data['filter']['details'] == 1) { | |
$description[] = BR(); | |
@@ -1091,27 +1111,6 @@ | |
->addClass($acknowledged ? ZBX_STYLE_GREEN : ZBX_STYLE_RED) | |
->addClass(ZBX_STYLE_LINK_ALT); | |
- $opdata = null; | |
- if ($show_opdata) { | |
- $opdata = ($trigger['opdata'] !== '') | |
- ? (new CCol(CMacrosResolverHelper::resolveTriggerOpdata( | |
- [ | |
- 'triggerid' => $trigger['triggerid'], | |
- 'expression' => $trigger['expression'], | |
- 'opdata' => $trigger['opdata'], | |
- 'clock' => ($problem['r_eventid'] != 0) ? $problem['r_clock'] : $problem['clock'], | |
- 'ns' => ($problem['r_eventid'] != 0) ? $problem['r_ns'] : $problem['ns'] | |
- ], | |
- [ | |
- 'events' => true, | |
- 'html' => true | |
- ] | |
- ))) | |
- ->addClass('opdata') | |
- ->addClass(ZBX_STYLE_WORDWRAP) | |
- : (new CCol(self::getLatestValues($trigger['items'])))->addClass('latest-values'); | |
- } | |
- | |
// Add table row. | |
$table->addRow(array_merge($row, [ | |
new CCheckBox('eventids['.$problem['eventid'].']', $problem['eventid']), | |
@@ -1121,7 +1120,6 @@ | |
$cell_info, | |
$triggers_hosts[$trigger['triggerid']], | |
$description, | |
- $opdata, | |
($problem['r_eventid'] != 0) | |
? zbx_date2age($problem['clock'], $problem['r_clock']) | |
: zbx_date2age($problem['clock']), | |
@@ -1152,7 +1150,6 @@ | |
_('Status'), | |
_('Host'), | |
_('Problem'), | |
- $show_opdata ? _('Operational data') : null, | |
_('Duration'), | |
_('Ack'), | |
_('Actions'), | |
@@ -1187,9 +1184,10 @@ | |
// operational data | |
$opdata = null; | |
- if ($show_opdata) { | |
- $opdata = ($trigger['opdata'] !== '') | |
- ? CMacrosResolverHelper::resolveTriggerOpdata( | |
+ $opdata_sp = null; | |
+ if ($show_opdata and $trigger['opdata'] !== '') { | |
+ $opdata_sp = ' '; | |
+ $opdata = CMacrosResolverHelper::resolveTriggerOpdata( | |
[ | |
'triggerid' => $trigger['triggerid'], | |
'expression' => $trigger['expression'], | |
@@ -1198,8 +1196,7 @@ | |
'ns' => ($problem['r_eventid'] != 0) ? $problem['r_ns'] : $problem['ns'] | |
], | |
['events' => true] | |
- ) | |
- : self::getLatestValues($trigger['items'], false); | |
+ ); | |
} | |
$actions_performed = []; | |
@@ -1222,8 +1219,7 @@ | |
: '', | |
$value_str, | |
implode(', ', $hosts), | |
- $problem['name'], | |
- $opdata, | |
+ $problem['name'].$opdata_sp.$opdata, | |
($problem['r_eventid'] != 0) | |
? zbx_date2age($problem['clock'], $problem['r_clock']) | |
: zbx_date2age($problem['clock']), | |
--- ./frontends/php/app/views/monitoring.widget.problems.view.php.orig 2019-09-27 10:44:12.000000000 +0300 | |
+++ ./frontends/php/app/views/monitoring.widget.problems.view.php 2019-09-27 20:57:14.582818465 +0300 | |
@@ -57,7 +57,6 @@ | |
' • ', | |
($data['sortfield'] === 'severity') ? [_('Severity'), $sort_div] : _('Severity') | |
], | |
- $data['fields']['show_opdata'] ? _('Operational data') : null, | |
_('Duration'), | |
_('Ack'), | |
_('Actions'), | |
@@ -149,8 +148,33 @@ | |
$info_icons[] = makeSuppressedProblemIcon($problem['suppression_data']); | |
} | |
+ // operational data | |
+ $opdata = null; | |
+ $opdata_sp = null; | |
+ if ($data['fields']['show_opdata'] and $trigger['opdata'] !== '') { | |
+ $opdata_sp = ' '; | |
+ $opdata = (CMacrosResolverHelper::resolveTriggerOpdata( | |
+ [ | |
+ 'triggerid' => $trigger['triggerid'], | |
+ 'expression' => $trigger['expression'], | |
+ 'opdata' => $trigger['opdata'], | |
+ 'clock' => ($problem['r_eventid'] != 0) ? $problem['r_clock'] : $problem['clock'], | |
+ 'ns' => ($problem['r_eventid'] != 0) ? $problem['r_ns'] : $problem['ns'] | |
+ ], | |
+ [ | |
+ 'events' => true, | |
+ 'html' => false | |
+ ] | |
+ )); | |
+ } | |
+ | |
+ /*$description = (new CCol($problem['name'].$opdata_sp.$opdata)) | |
+ ->setAttribute('aria-label', _xs('%1$s, Severity, %2$s', 'screen reader', | |
+ $problem['name'], getSeverityName($problem['severity'], $data['config']) | |
+ ));*/ | |
+ | |
$description = (new CCol([ | |
- (new CLinkAction($problem['name'])) | |
+ (new CLinkAction($problem['name'].$opdata_sp.$opdata)) | |
->setHint( | |
make_popup_eventlist(['comments' => $problem['comments'], 'url' => $problem['url'], | |
'triggerid' => $trigger['triggerid']], $eventid, $backurl, $show_timeline, | |
@@ -203,28 +227,6 @@ | |
]; | |
} | |
- // operational data | |
- $opdata = null; | |
- if ($data['fields']['show_opdata']) { | |
- $opdata = ($trigger['opdata'] !== '') | |
- ? (new CCol(CMacrosResolverHelper::resolveTriggerOpdata( | |
- [ | |
- 'triggerid' => $trigger['triggerid'], | |
- 'expression' => $trigger['expression'], | |
- 'opdata' => $trigger['opdata'], | |
- 'clock' => ($problem['r_eventid'] != 0) ? $problem['r_clock'] : $problem['clock'], | |
- 'ns' => ($problem['r_eventid'] != 0) ? $problem['r_ns'] : $problem['ns'] | |
- ], | |
- [ | |
- 'events' => true, | |
- 'html' => true | |
- ] | |
- ))) | |
- ->addClass('opdata') | |
- ->addClass(ZBX_STYLE_WORDWRAP) | |
- : (new CCol(CScreenProblem::getLatestValues($trigger['items'])))->addClass('latest-values'); | |
- } | |
- | |
// Create acknowledge url. | |
$problem_update_url = (new CUrl('zabbix.php')) | |
->setArgument('action', 'acknowledge.edit') | |
@@ -238,7 +240,6 @@ | |
makeInformationList($info_icons), | |
$triggers_hosts[$trigger['triggerid']], | |
$description, | |
- $opdata, | |
(new CCol(zbx_date2age($problem['clock'], ($problem['r_eventid'] != 0) ? $problem['r_clock'] : 0))) | |
->addClass(ZBX_STYLE_NOWRAP), | |
(new CLink($problem['acknowledged'] == EVENT_ACKNOWLEDGED ? _('Yes') : _('No'), $problem_update_url)) | |
--- ./frontends/php/tr_events.php.orig 2019-09-27 20:57:02.213919188 +0300 | |
+++ ./frontends/php/tr_events.php 2019-09-27 20:57:14.583818457 +0300 | |
@@ -104,8 +104,9 @@ | |
} | |
} | |
+$event['opdata'] = null; | |
if ($trigger['opdata'] !== '') { | |
- $event['opdata'] = (new CCol(CMacrosResolverHelper::resolveTriggerOpdata( | |
+ $event['opdata'] = ' '.CMacrosResolverHelper::resolveTriggerOpdata( | |
[ | |
'triggerid' => $trigger['triggerid'], | |
'expression' => $trigger['expression'], | |
@@ -115,19 +116,9 @@ | |
], | |
[ | |
'events' => true, | |
- 'html' => true | |
+ 'html' => false | |
] | |
- ))) | |
- ->addClass('opdata') | |
- ->addClass(ZBX_STYLE_WORDWRAP); | |
-} | |
-else { | |
- $db_items = API::Item()->get([ | |
- 'output' => ['itemid', 'hostid', 'name', 'key_', 'value_type', 'units', 'valuemapid'], | |
- 'triggerids' => $event['objectid'] | |
- ]); | |
- $db_items = CMacrosResolverHelper::resolveItemNames($db_items); | |
- $event['opdata'] = (new CCol(CScreenProblem::getLatestValues($db_items)))->addClass('latest-values'); | |
+ ); | |
} | |
$config = select_config(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment