mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
feature: Add last changed, connected, and mtu to all ports data
Thanks to sysvival on reddit for the idea and help with the calculations
This commit is contained in:
@@ -102,6 +102,8 @@ if (isset($sort) && !empty($sort)) {
|
||||
$sql .= " ORDER BY `D`.`hostname` $sort_order";
|
||||
} elseif ($sort_column == 'port') {
|
||||
$sql .= " ORDER BY `ifDescr` $sort_order";
|
||||
} elseif ($sort_column == 'ifLastChange') {
|
||||
$sql .= " ORDER BY `secondsIfLastChange` $sort_order";
|
||||
} else {
|
||||
$sql .= " ORDER BY `$sort_column` $sort_order";
|
||||
}
|
||||
@@ -116,9 +118,12 @@ if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
$sql = "SELECT DISTINCT(`ports`.`port_id`),`ports`.* $sql";
|
||||
$query = 'SELECT DISTINCT(`ports`.`port_id`),`ports`.*';
|
||||
// calculate ifLastChange as seconds ago
|
||||
$query .= ',`D`.`uptime` - `ports`.`ifLastChange` / 100 as secondsIfLastChange ';
|
||||
$query .= $sql;
|
||||
|
||||
foreach (dbFetchRows($sql, $param) as $port) {
|
||||
foreach (dbFetchRows($query, $param) as $port) {
|
||||
$device = device_by_id_cache($port['device_id']);
|
||||
|
||||
// FIXME what actions should we have?
|
||||
@@ -138,7 +143,10 @@ foreach (dbFetchRows($sql, $param) as $port) {
|
||||
$response[] = array(
|
||||
'device' => generate_device_link($device),
|
||||
'port' => generate_port_link($port),
|
||||
'ifLastChange' => ceil($port['secondsIfLastChange']),
|
||||
'ifConnectorPresent' => ($port['ifConnectorPresent'] == 'true') ? 'yes' : 'no',
|
||||
'ifSpeed' => $port['ifSpeed'],
|
||||
'ifMtu' => $port['ifMtu'],
|
||||
'ifInOctets_rate' => $port['ifInOctets_rate'] * 8,
|
||||
'ifOutOctets_rate' => $port['ifOutOctets_rate'] * 8,
|
||||
'ifInUcastPkts_rate' => $port['ifInUcastPkts_rate'],
|
||||
|
||||
@@ -18,11 +18,14 @@ if ($vars['errors']) {
|
||||
<tr>
|
||||
<th data-column-id="device">Device</th>
|
||||
<th data-column-id="port"<?php echo $sort ?>>Port</th>
|
||||
<th data-column-id="ifSpeed" data-formatter="human-bps">Speed</th>
|
||||
<th data-column-id="ifInOctets_rate" data-searchable="false" data-css-class="green" data-formatter="human-bps">Down</th>
|
||||
<th data-column-id="ifOutOctets_rate" data-searchable="false" data-css-class="blue" data-formatter="human-bps">Up</th>
|
||||
<th data-column-id="ifInUcastPkts_rate" data-searchable="false" data-visible="<?php echo $details_visible ?>" data-css-class="green" data-formatter="human-pps">Packets In</th>
|
||||
<th data-column-id="ifOutUcastPkts_rate" data-searchable="false" data-visible="<?php echo $details_visible ?>" data-css-class="blue" data-formatter="human-pps">Packets Out</th>
|
||||
<th data-column-id="ifLastChange" data-converter="duration">Status Changed</th>
|
||||
<th data-column-id="ifConnectorPresent" data-visible="false">Connected</th>
|
||||
<th data-column-id="ifSpeed" data-converter="human-bps">Speed</th>
|
||||
<th data-column-id="ifMtu" data-visible="false">MTU</th>
|
||||
<th data-column-id="ifInOctets_rate" data-searchable="false" data-css-class="green" data-converter="human-bps">Down</th>
|
||||
<th data-column-id="ifOutOctets_rate" data-searchable="false" data-css-class="blue" data-converter="human-bps">Up</th>
|
||||
<th data-column-id="ifInUcastPkts_rate" data-searchable="false" data-visible="<?php echo $details_visible ?>" data-css-class="green" data-converter="human-pps">Packets In</th>
|
||||
<th data-column-id="ifOutUcastPkts_rate" data-searchable="false" data-visible="<?php echo $details_visible ?>" data-css-class="blue" data-converter="human-pps">Packets Out</th>
|
||||
<th data-column-id="ifInErrors" data-searchable="false" data-visible="<?php echo $errors_visible ?>" data-css-class="red"<?php echo $error_sort ?>>Errors In</th>
|
||||
<th data-column-id="ifOutErrors" data-searchable="false" data-visible="<?php echo $errors_visible ?>" data-css-class="red">Errors Out</th>
|
||||
<th data-column-id="ifType">Media</th>
|
||||
@@ -47,17 +50,22 @@ function formatUnits(units,decimals,display,base) {
|
||||
|
||||
var grid = $("#ports").bootgrid({
|
||||
ajax: true,
|
||||
rowCount: [25, 50,100,250,-1],
|
||||
formatters: {
|
||||
'human-bps': function(column, row) {
|
||||
return formatUnits(row[column.id]);
|
||||
rowCount: [25, 50, 100, 250, -1],
|
||||
converters: {
|
||||
'duration': {
|
||||
to: function (value) { return moment.duration(value, 'seconds').humanize(); }
|
||||
},
|
||||
'human-pps': function(column, row) {
|
||||
return formatUnits(row[column.id], 2, ['pps', 'Kpps', 'Mpps', 'Gpps', 'Tpps', 'Ppps', 'Epps', 'Zpps', 'Ypps']);
|
||||
'human-bps': {
|
||||
to: function (value) { return formatUnits(value); }
|
||||
},
|
||||
'human-pps': {
|
||||
to: function (value) {
|
||||
return formatUnits(value, 2, ['pps', 'Kpps', 'Mpps', 'Gpps', 'Tpps', 'Ppps', 'Epps', 'Zpps', 'Ypps']);
|
||||
}
|
||||
}
|
||||
},
|
||||
templates: {
|
||||
search: ""
|
||||
search: "" // hide the generic search
|
||||
},
|
||||
post: function ()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user