Provide NetBIOS information when available in Node and Port views

This commit is contained in:
Eric A. Miller
2014-02-08 20:50:35 -05:00
parent 79cc9622b2
commit 1739108717
8 changed files with 97 additions and 1 deletions

View File

@@ -112,6 +112,16 @@ the current Node's.
__PACKAGE__->has_many( ips => 'App::Netdisco::DB::Result::NodeIp',
{ 'foreign.mac' => 'self.mac', 'foreign.active' => 'self.active' } );
=head2 netbios
Returns the C<node_nbt> entry associated with this Node if one exists. That
is, the NetBIOS information of this MAC address at the time of discovery.
=cut
__PACKAGE__->might_have( netbios => 'App::Netdisco::DB::Result::NodeNbt',
{ 'foreign.mac' => 'self.mac' } );
=head2 wireless
Returns the set of C<node_wireless> entries associated with this Node. That

View File

@@ -48,6 +48,7 @@ hook 'before' => sub {
var('connected_properties' => [
{ name => 'n_age', label => 'Age Stamp', default => '' },
{ name => 'n_ip', label => 'IP Address', default => 'on' },
{ name => 'n_netbios', label => 'NetBIOS', default => 'on' },
{ name => 'n_ssid', label => 'SSID', default => 'on' },
{ name => 'n_vendor', label => 'Vendor', default => '' },
{ name => 'n_archived', label => 'Archived Data', default => '' },

View File

@@ -141,6 +141,10 @@ get '/ajax/content/device/ports' => require_login sub {
$set = $set->search_rs({}, { prefetch => [{$nodes_name => 'wireless'}] })
if param('c_nodes') && param('n_ssid');
# retrieve NetBIOS, if asked for
$set = $set->search_rs({}, { prefetch => [{$nodes_name => 'netbios'}] })
if param('c_nodes') && param('n_netbios');
# retrieve vendor, if asked for
$set = $set->search_rs({}, { prefetch => [{$nodes_name => 'oui'}] })
if param('c_nodes') && param('n_vendor');

View File

@@ -62,6 +62,17 @@ ajax '/ajax/content/search/node' => require_login sub {
}
);
my $netbios = schema('netdisco')->resultset('NodeNbt')->search(
{ mac => $mac->as_IEEE },
{ order_by => { '-desc' => 'time_last' },
'+columns' => [
{
time_first_stamp => \"to_char(time_first, 'YYYY-MM-DD HH24:MI')",
time_last_stamp => \"to_char(time_last, 'YYYY-MM-DD HH24:MI')"
}]
}
);
return unless $sightings->count
or $ips->count
or $ports->count;
@@ -71,6 +82,7 @@ ajax '/ajax/content/search/node' => require_login sub {
sightings => $sightings,
ports => $ports,
wireless => $wireless,
netbios => $netbios,
}, { layout => undef };
}
else {