diff --git a/Netdisco/Changes b/Netdisco/Changes index a55b3233..02d1e58b 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -5,7 +5,8 @@ * [#86] Use Vendor abbrevs to enhance node display in device port view * [#74] Device Name / DNS mismatches report * [#71] Node search by date (but not time) - * [#73] NetBIOS Poller (nbtstat and nbtwalk), NetBIOS Node Report + * [#73] NetBIOS Poller (nbtstat and nbtwalk), NetBIOS Node Report, + and provide information when available in Node and Port views * [#56] Support API call to /login [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm index 9cd9aeca..36740d18 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/Node.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/Node.pm @@ -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 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 entries associated with this Node. That diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index add52c7c..06e0c521 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -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 => '' }, diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm index c26b9270..914f87be 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Device/Ports.pm @@ -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'); diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm index 33fcd2a6..fdef9530 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Search/Node.pm @@ -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 { diff --git a/Netdisco/share/views/ajax/device/ports.tt b/Netdisco/share/views/ajax/device/ports.tt index e6bc1f24..b46ddf1d 100644 --- a/Netdisco/share/views/ajax/device/ports.tt +++ b/Netdisco/share/views/ajax/device/ports.tt @@ -301,6 +301,12 @@ [% END %] [% END %] [% END %] + [% IF params.n_netbios %] + [% FOREACH nbt IN node.netbios %] +
     \\[% nbt.domain | html %]\[% nbt.nbname | html_entity %] +
     [% nbt.nbuser || '[No User]' | html %]@[% nbt.ip | html_entity %] + [% END %] + [% END %] [% END %] [% END %] diff --git a/Netdisco/share/views/ajax/search/node_by_ip.tt b/Netdisco/share/views/ajax/search/node_by_ip.tt index 5b84a8c3..c44ef163 100644 --- a/Netdisco/share/views/ajax/search/node_by_ip.tt +++ b/Netdisco/share/views/ajax/search/node_by_ip.tt @@ -1,3 +1,4 @@ +[% USE date(format = '%Y-%m-%d %H:%M') %] @@ -52,6 +53,41 @@ [% END %] + [% FOREACH nbt IN node.netbios %] + + + [% IF params.show_vendor %] + + [% END %] + + + [% IF params.stamps %] + + + [% END %] + + [% END %] + [% FOREACH wlan IN node.wireless %] + + + [% IF params.show_vendor %] + + [% END %] + + + [% IF params.stamps %] + + + [% END %] + + [% END %] [% END %] [% FOREACH nodeip IN row.ip_aliases(archive_filter) %] diff --git a/Netdisco/share/views/ajax/search/node_by_mac.tt b/Netdisco/share/views/ajax/search/node_by_mac.tt index 80fc0725..4cfce4fe 100644 --- a/Netdisco/share/views/ajax/search/node_by_mac.tt +++ b/Netdisco/share/views/ajax/search/node_by_mac.tt @@ -118,6 +118,32 @@ [% SET first_row = 0 %] [% END %] + [% WHILE (nbt = netbios.next) %] + + + [% IF params.show_vendor %] + + [% END %] + + + [% IF params.stamps %] + + + [% END %] + + [% SET first_row = 0 %] + [% END %] [% WHILE (wlan = wireless.next) %]
[% node.time_last_stamp | html_entity %]
  NetBIOS\\[% nbt.domain | html %]\[% nbt.nbname | html_entity %] +
[% nbt.nbuser || '[No User]' | html %]@[% nbt.ip | html_entity %] +
[% date.format(nbt.time_first) | html_entity %][% date.format(nbt.time_last) | html_entity %]
  Wireless InfoSSID: [% wlan.ssid | html_entity %]
+ MaxRate: [% wlan.maxrate | html_entity %]Mbps TxRate: [% wlan.txrate | html_entity %]Mbps
+ SigStr: [% wlan.sigstrength | html_entity %] SigQual: [% wlan.sigqual | html_entity %]
+ Rx: [% wlan.rxpkt | format_number %] pkts, [% wlan.rxbyte | format_number %] bytes
+ Tx: [% wlan.txpkt | format_number %] pkts, [% wlan.txbyte | format_number %] bytes
+
  [% date.format(wlan.time_last) | html_entity %]
+ [% IF first_row %] + [% nbt.mac | html_entity %] + [% ELSE %] +   + [% END %] + +   + NetBIOS\\[% nbt.domain | html %]\[% nbt.nbname | html_entity %] +
[% nbt.nbuser || '[No User]' | html %]@[% nbt.ip | html_entity %] +
[% nbt.get_column('time_first_stamp') | html_entity %][% nbt.get_column('time_last_stamp') | html_entity %]