[ZBXNEXT-4987] Items page Last Value Created: 2019 Jan 30  Updated: 2023 Sep 02

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F)
Affects Version/s: None
Fix Version/s: None

Type: Change Request Priority: Minor
Reporter: Carl Slaughter Assignee: Valdis Murzins
Resolution: Unresolved Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File items-update.png     PNG File screenshot-1.png    

 Description   

Adding additional columns to the items page that display the last time and last value for each item. 

It's VERY useful for administering new agents and configuring new metrics.

 

the changes to items.php

/*
 * Display
 */
if (isset($_REQUEST['form']) && str_in_array($_REQUEST['form'], ['create', 'update', 'clone'])) {
 $master_item_options = [];
 $has_errors = false;
if (hasRequest('itemid')) {
 $items = API::Item()->get([
 'output' => ['itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history',
 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'snmpv3_securityname',
 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'logtimefmt', 'templateid',
 'valuemapid', 'params', 'ipmi_sensor', 'authtype', 'username', 'password', 'publickey', 'privatekey',
 'flags', 'interfaceid', 'port', 'description', 'inventory_link', 'lifetime', 'snmpv3_authprotocol',
 'snmpv3_privprotocol', 'snmpv3_contextname', 'jmx_endpoint', 'master_itemid', 'url', 'query_fields',
 'timeout', 'posts', 'status_codes', 'follow_redirects', 'post_type', 'http_proxy', 'headers',
 'retrieve_mode', 'request_method', 'output_format', 'ssl_cert_file', 'ssl_key_file', 'ssl_key_password',
 'verify_peer', 'verify_host', 'allow_traps', 'units', 'valuemapid'```
Carl Slaughter [9:17 AM]
 in that same file, there is a second update starting at line 1648
 ```// items
 // Carl: Adding 'lastvalue', 'lastclock', 'units', 'valuemapid' to $options['output']
 $options = [
 'hostids' => $data['hostid'],
 'search' => [],
 'output' => [
 'itemid', 'type', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'error',
 'templateid', 'flags', 'state', 'master_itemid', 'lastvalue', 'lastclock', 'units', 'valuemapid'

 

2 additional changes in file /var/www/html/include/views/configuration.item.list.php

Starting at line 55

// create table
// Carl: Adding "_('Last Check'), _('Last Value')" to this section
// Carl: Companion File is Items.php
$itemTable = (new CTableInfo())
 ->setHeader([
 (new CColHeader(
 (new CCheckBox('all_items'))->onClick("checkAll('".$itemForm->getName()."', 'all_items', 'group_itemid');")
 ))->addClass(ZBX_STYLE_CELL_WIDTH),
 _('Wizard'),
 empty($this->data['filter_hostid']) ? _('Host') : null,
 make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'], $url),
 _('Triggers'),
 make_sorting_header(_('Key'), 'key_', $data['sort'], $data['sortorder'], $url),
 make_sorting_header(_('Interval'), 'delay', $data['sort'], $data['sortorder'], $url),
 make_sorting_header(_('History'), 'history', $data['sort'], $data['sortorder'], $url),
 make_sorting_header(_('Trends'), 'trends', $data['sort'], $data['sortorder'], $url),
 make_sorting_header(_('Type'), 'type', $data['sort'], $data['sortorder'], $url),
 _('Applications'),
 make_sorting_header(_('Status'), 'status', $data['sort'], $data['sortorder'], $url),
 $data['showInfoColumn'] ? _('Info') : null,
 _('Last Check'),
 _('Last Value')
 ]);

And at line 262

$itemTable->addRow([
 new CCheckBox('group_itemid['.$item['itemid'].']', $item['itemid']),
 $wizard,
 empty($this->data['filter_hostid']) ? $item['host'] : null,
 $description,
 $triggerInfo,
 CHtml::encode($item['key_']),
 $item['delay'],
 $item['history'],
 $item['trends'],
 item_type2str($item['type']),
 CHtml::encode($item['applications_list']),
 $status,
 $data['showInfoColumn'] ? makeInformationList($info_icons) : null,
 zbx_date2str(DATE_TIME_FORMAT_SECONDS, $item['lastclock']),
 formatHistoryValue($item['lastvalue'], $item, false)
 ]);

 



 Comments   
Comment by Alexey Pustovalov [ 2019 Jan 30 ]

I suppose it is better to have dynamic column set instead of hardcoded so many columns. What do you think?

Comment by Carl Slaughter [ 2019 Jan 30 ]

I have thought that it could use some flexibility..

Comment by Carl Slaughter [ 2019 Feb 07 ]

There are a number of options I could think of. With the above mentioned change. On web checks, a column with a link for the page that was returned would be handy for troubleshooting web scenarios.

I think just adding the first two and then waiting on community feedback on that change to see what people think and suggest and go from there..

Comment by Carl Slaughter [ 2019 Sep 25 ]

Example of what I have in place using this code

Comment by Ryan Eberly [ 2023 Sep 02 ]

I like the idea of customization of the tables. This is on the roadmap for 7.0 for the problems page and should be extensible for use in other areas of the UI (configuration, latest data)

Generated at Fri Apr 26 08:53:30 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.