Add vendor to IP Inventory report (#714)
* request on mailing list by Adrian Sevcenco, 08.04.20, "[Netdisco] how to modify report: add column to ip inventory"
This commit is contained in:
committed by
GitHub
parent
b155be832d
commit
48996661ce
@@ -77,31 +77,37 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
'dns',
|
'dns',
|
||||||
\'true AS active',
|
\'true AS active',
|
||||||
\'false AS node',
|
\'false AS node',
|
||||||
\qq/replace( date_trunc( 'minute', age( now(), device.last_discover ) ) ::text, 'mon', 'month') AS age/
|
\qq/replace( date_trunc( 'minute', age( now(), device.last_discover ) ) ::text, 'mon', 'month') AS age/,
|
||||||
|
'device.vendor',
|
||||||
|
|
||||||
],
|
],
|
||||||
as => [qw( ip mac time_first time_last dns active node age)],
|
as => [qw( ip mac time_first time_last dns active node age vendor)],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
||||||
undef,
|
undef,
|
||||||
{ columns => [qw( ip mac time_first time_last dns active)],
|
{ join => ['oui'],
|
||||||
|
columns => [qw( ip mac time_first time_last dns active)],
|
||||||
'+select' => [ \'true AS node',
|
'+select' => [ \'true AS node',
|
||||||
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/,
|
||||||
|
\'oui.company || oui.abbrev'
|
||||||
],
|
],
|
||||||
'+as' => [ 'node', 'age' ],
|
'+as' => [ 'node', 'age', 'vendor' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
my $rs3 = schema('netdisco')->resultset('NodeNbt')->search(
|
my $rs3 = schema('netdisco')->resultset('NodeNbt')->search(
|
||||||
undef,
|
undef,
|
||||||
{ columns => [qw( ip mac time_first time_last )],
|
{ join => ['oui'],
|
||||||
|
columns => [qw( ip mac time_first time_last )],
|
||||||
'+select' => [
|
'+select' => [
|
||||||
'nbname AS dns', 'active',
|
'nbname AS dns', 'active',
|
||||||
\'true AS node',
|
\'true AS node',
|
||||||
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/,
|
||||||
|
'oui.company'
|
||||||
],
|
],
|
||||||
'+as' => [ 'dns', 'active', 'node', 'age' ],
|
'+as' => [ 'dns', 'active', 'node', 'age', 'vendor' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
@@ -115,9 +121,10 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
{ bind => [ $subnet->cidr ],
|
{ bind => [ $subnet->cidr ],
|
||||||
columns => [qw( ip mac time_first time_last dns active)],
|
columns => [qw( ip mac time_first time_last dns active)],
|
||||||
'+select' => [ \'false AS node',
|
'+select' => [ \'false AS node',
|
||||||
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/
|
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/,
|
||||||
|
\'null as vendor'
|
||||||
],
|
],
|
||||||
'+as' => [ 'node', 'age' ],
|
'+as' => [ 'node', 'age', 'vendor' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
@@ -134,11 +141,12 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
\qq/date_trunc('second', time_first) AS time_first/,
|
\qq/date_trunc('second', time_first) AS time_first/,
|
||||||
'active',
|
'active',
|
||||||
'node',
|
'node',
|
||||||
'age'
|
'age',
|
||||||
|
'vendor'
|
||||||
],
|
],
|
||||||
as => [
|
as => [
|
||||||
'ip', 'mac', 'dns', 'time_last', 'time_first',
|
'ip', 'mac', 'dns', 'time_last', 'time_first',
|
||||||
'active', 'node', 'age'
|
'active', 'node', 'age', 'vendor'
|
||||||
],
|
],
|
||||||
order_by => [{-asc => 'ip'}, {-desc => 'active'}, {-asc => 'node'}],
|
order_by => [{-asc => 'ip'}, {-desc => 'active'}, {-asc => 'node'}],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>IP Address</th>
|
<th>IP Address</th>
|
||||||
<th>MAC Address</th>
|
<th>MAC Address</th>
|
||||||
|
<th>Vendor</th>
|
||||||
<th class="nd_center-cell">DNS</th>
|
<th class="nd_center-cell">DNS</th>
|
||||||
<th>Last Used</th>
|
<th>Last Used</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -42,6 +43,12 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
return cell_str;
|
return cell_str;
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"data": 'vendor',
|
||||||
|
"className": "nd_nowrap nd_center-cell",
|
||||||
|
"render": function(data, type, row, meta) {
|
||||||
|
return he.encode(data || '');
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'dns',
|
"data": 'dns',
|
||||||
"className": "nd_nowrap nd_center-cell",
|
"className": "nd_nowrap nd_center-cell",
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
[% USE CSV %]
|
[% USE CSV %]
|
||||||
[% CSV.dump([ 'Node' 'MAC Address' 'DNS' 'Last Used' ]) %]
|
[% CSV.dump([ 'Node' 'MAC Address' 'Vendor' 'DNS' 'Last Used' ]) %]
|
||||||
|
|
||||||
[% FOREACH row IN results %]
|
[% FOREACH row IN results %]
|
||||||
[% mylist = [] %]
|
[% mylist = [] %]
|
||||||
[% mylist.push(row.ip) %]
|
[% mylist.push(row.ip) %]
|
||||||
[% mylist.push(row.mac) %]
|
[% mylist.push(row.mac) %]
|
||||||
|
[% mylist.push(row.vendor) %]
|
||||||
[% mylist.push(row.dns) %]
|
[% mylist.push(row.dns) %]
|
||||||
[% mylist.push(row.time_last) %]
|
[% mylist.push(row.time_last) %]
|
||||||
[% CSV.dump(mylist) %]
|
[% CSV.dump(mylist) %]
|
||||||
|
|||||||
Reference in New Issue
Block a user