#872 separate column for NetBIOS name in IP Inventory
This commit is contained in:
@@ -13,10 +13,14 @@ __PACKAGE__->result_source_instance->is_virtual(1);
|
|||||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||||
SELECT host(network (prefix) + sub.int)::inet AS ip,
|
SELECT host(network (prefix) + sub.int)::inet AS ip,
|
||||||
NULL::macaddr AS mac,
|
NULL::macaddr AS mac,
|
||||||
NULL::text AS dns,
|
|
||||||
NULL::timestamp AS time_first,
|
NULL::timestamp AS time_first,
|
||||||
NULL::timestamp AS time_last,
|
NULL::timestamp AS time_last,
|
||||||
false::boolean AS active
|
NULL::text AS dns,
|
||||||
|
false::boolean AS active,
|
||||||
|
false::boolean AS node,
|
||||||
|
replace( date_trunc( 'minute', age( now(), NULL::timestamp ) ) ::text, 'mon', 'month') AS age,
|
||||||
|
NULL::text AS vendor,
|
||||||
|
NULL::text AS nbname
|
||||||
FROM (
|
FROM (
|
||||||
SELECT prefix,
|
SELECT prefix,
|
||||||
generate_series(1, (broadcast(prefix) - network(prefix) - 1)) AS int
|
generate_series(1, (broadcast(prefix) - network(prefix) - 1)) AS int
|
||||||
@@ -31,10 +35,6 @@ __PACKAGE__->add_columns(
|
|||||||
{ data_type => "inet", is_nullable => 0 },
|
{ data_type => "inet", is_nullable => 0 },
|
||||||
"mac",
|
"mac",
|
||||||
{ data_type => "macaddr", is_nullable => 1 },
|
{ data_type => "macaddr", is_nullable => 1 },
|
||||||
"dns",
|
|
||||||
{ data_type => "text", is_nullable => 1 },
|
|
||||||
"active",
|
|
||||||
{ data_type => "boolean", is_nullable => 1 },
|
|
||||||
"time_first",
|
"time_first",
|
||||||
{
|
{
|
||||||
data_type => "timestamp",
|
data_type => "timestamp",
|
||||||
@@ -45,6 +45,18 @@ __PACKAGE__->add_columns(
|
|||||||
data_type => "timestamp",
|
data_type => "timestamp",
|
||||||
is_nullable => 1,
|
is_nullable => 1,
|
||||||
},
|
},
|
||||||
|
"dns",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"active",
|
||||||
|
{ data_type => "boolean", is_nullable => 1 },
|
||||||
|
"node",
|
||||||
|
{ data_type => "boolean", is_nullable => 1 },
|
||||||
|
"age",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"vendor",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"nbname",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
);
|
);
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -79,21 +79,23 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
\'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',
|
'device.vendor',
|
||||||
|
\'null AS nbname',
|
||||||
|
|
||||||
],
|
],
|
||||||
as => [qw( ip mac time_first time_last dns active node age vendor)],
|
as => [qw( ip mac time_first time_last dns active node age vendor nbname)],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
my $rs2 = schema('netdisco')->resultset('NodeIp')->search(
|
||||||
undef,
|
undef,
|
||||||
{ join => ['oui'],
|
{ join => ['oui', 'netbios'],
|
||||||
columns => [qw( ip mac time_first time_last dns active)],
|
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(), me.time_last ) ) ::text, 'mon', 'month') AS age/,
|
||||||
'oui.company'
|
'oui.company',
|
||||||
|
'netbios.nbname',
|
||||||
],
|
],
|
||||||
'+as' => [ 'node', 'age', 'vendor' ],
|
'+as' => [ 'node', 'age', 'vendor', 'nbname' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
@@ -102,12 +104,14 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
{ join => ['oui'],
|
{ join => ['oui'],
|
||||||
columns => [qw( ip mac time_first time_last )],
|
columns => [qw( ip mac time_first time_last )],
|
||||||
'+select' => [
|
'+select' => [
|
||||||
'nbname AS dns', 'active',
|
\'null 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'
|
'oui.company',
|
||||||
|
'nbname'
|
||||||
],
|
],
|
||||||
'+as' => [ 'dns', 'active', 'node', 'age', 'vendor' ],
|
'+as' => [ 'dns', 'active', 'node', 'age', 'vendor', 'nbname' ],
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
@@ -119,12 +123,7 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
my $rs4 = schema('netdisco')->resultset('Virtual::CidrIps')->search(
|
my $rs4 = schema('netdisco')->resultset('Virtual::CidrIps')->search(
|
||||||
undef,
|
undef,
|
||||||
{ 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 node age vendor nbname )],
|
||||||
'+select' => [ \'false AS node',
|
|
||||||
\qq/replace( date_trunc( 'minute', age( now(), time_last ) ) ::text, 'mon', 'month') AS age/,
|
|
||||||
\'null as vendor'
|
|
||||||
],
|
|
||||||
'+as' => [ 'node', 'age', 'vendor' ],
|
|
||||||
}
|
}
|
||||||
)->hri;
|
)->hri;
|
||||||
|
|
||||||
@@ -142,13 +141,14 @@ get '/ajax/content/report/ipinventory' => require_login sub {
|
|||||||
'active',
|
'active',
|
||||||
'node',
|
'node',
|
||||||
'age',
|
'age',
|
||||||
'vendor'
|
'vendor',
|
||||||
|
'nbname'
|
||||||
],
|
],
|
||||||
as => [
|
as => [
|
||||||
'ip', 'mac', 'dns', 'time_last', 'time_first',
|
'ip', 'mac', 'dns', 'time_last', 'time_first',
|
||||||
'active', 'node', 'age', 'vendor'
|
'active', 'node', 'age', 'vendor', 'nbname'
|
||||||
],
|
],
|
||||||
order_by => [{-asc => 'ip'}, {-desc => 'active'}, {-asc => 'node'}],
|
order_by => [{-asc => 'ip'}, {-asc => 'dns'}, {-desc => 'active'}, {-asc => 'node'}],
|
||||||
}
|
}
|
||||||
)->as_query;
|
)->as_query;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<th>MAC Address</th>
|
<th>MAC Address</th>
|
||||||
<th>Vendor</th>
|
<th>Vendor</th>
|
||||||
<th class="nd_center-cell">DNS</th>
|
<th class="nd_center-cell">DNS</th>
|
||||||
|
<th class="nd_center-cell">NetBIOS</th>
|
||||||
<th>Last Used</th>
|
<th>Last Used</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -55,6 +56,12 @@ $(document).ready(function() {
|
|||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
return he.encode(data || '');
|
return he.encode(data || '');
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
"data": 'nbname',
|
||||||
|
"className": "nd_nowrap nd_center-cell",
|
||||||
|
"render": function(data, type, row, meta) {
|
||||||
|
return he.encode(data || '');
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
"data": 'age',
|
"data": 'age',
|
||||||
"render": function(data, type, row, meta) {
|
"render": function(data, type, row, meta) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[% USE CSV %]
|
[% USE CSV %]
|
||||||
[% CSV.dump([ 'Node' 'MAC Address' 'Vendor' 'DNS' 'Last Used' ]) %]
|
[% CSV.dump([ 'Node' 'MAC Address' 'Vendor' 'DNS' 'NetBIOS' 'Last Used' ]) %]
|
||||||
|
|
||||||
[% FOREACH row IN results %]
|
[% FOREACH row IN results %]
|
||||||
[% mylist = [] %]
|
[% mylist = [] %]
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
[% mylist.push(row.mac) %]
|
[% mylist.push(row.mac) %]
|
||||||
[% mylist.push(row.vendor) %]
|
[% mylist.push(row.vendor) %]
|
||||||
[% mylist.push(row.dns) %]
|
[% mylist.push(row.dns) %]
|
||||||
|
[% mylist.push(row.nbname) %]
|
||||||
[% mylist.push(row.time_last) %]
|
[% mylist.push(row.time_last) %]
|
||||||
[% CSV.dump(mylist) %]
|
[% CSV.dump(mylist) %]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user