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

@@ -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]

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 {

View File

@@ -301,6 +301,12 @@
[% END %]
[% END %]
[% END %]
[% IF params.n_netbios %]
[% FOREACH nbt IN node.netbios %]
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\\<a href="ip_search.html?domain=[% nbt.domain | uri %]&cmd=nbt" title="Devices in this Domain">[% nbt.domain | html %]</a>\<a href="[% search_node %]&q=[% nbt.nbname | uri %]">[% nbt.nbname | html_entity %]</a>
<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[% nbt.nbuser || '[No User]' | html %]@<a href="[% search_node %]&q=[% nbt.ip | uri %]">[% nbt.ip | html_entity %]</a>
[% END %]
[% END %]
[% END %]
[% END %]
</td>

View File

@@ -1,3 +1,4 @@
[% USE date(format = '%Y-%m-%d %H:%M') %]
<table class="table table-bordered table-hover nd_floatinghead">
<thead>
<tr>
@@ -52,6 +53,41 @@
<td>[% node.time_last_stamp | html_entity %]</td>
[% END %]
</tr>
[% FOREACH nbt IN node.netbios %]
<tr>
<td>&nbsp;</td>
[% IF params.show_vendor %]
<td>&nbsp;</td>
[% END %]
<td>NetBIOS</td>
<td class="nd_linkcell">\\<a href="[% uri_for('report/netbios') %]?domain=[% nbt.domain | uri %]" title="Devices in this Domain">[% nbt.domain | html %]</a>\<a href="[% search_node %]&q=[% nbt.nbname | uri %]">[% nbt.nbname | html_entity %]</a>
<br>[% nbt.nbuser || '[No User]' | html %]@<a href="[% search_node %]&q=[% nbt.ip | uri %]">[% nbt.ip | html_entity %]</a>
</td>
[% IF params.stamps %]
<td>[% date.format(nbt.time_first) | html_entity %]</td>
<td>[% date.format(nbt.time_last) | html_entity %]</td>
[% END %]
</tr>
[% END %]
[% FOREACH wlan IN node.wireless %]
<tr>
<td>&nbsp;</td>
[% IF params.show_vendor %]
<td>&nbsp;</td>
[% END %]
<td>Wireless Info</td>
<td class="nd_center-cell">SSID: [% wlan.ssid | html_entity %]<br>
MaxRate: [% wlan.maxrate | html_entity %]Mbps TxRate: [% wlan.txrate | html_entity %]Mbps<br>
SigStr: [% wlan.sigstrength | html_entity %] SigQual: [% wlan.sigqual | html_entity %]<br>
Rx: [% wlan.rxpkt | format_number %] pkts, [% wlan.rxbyte | format_number %] bytes<br>
Tx: [% wlan.txpkt | format_number %] pkts, [% wlan.txbyte | format_number %] bytes<br>
</td>
[% IF params.stamps %]
<td> &nbsp; </td>
<td>[% date.format(wlan.time_last) | html_entity %]</td>
[% END %]
</tr>
[% END %]
[% END %]
[% FOREACH nodeip IN row.ip_aliases(archive_filter) %]
<tr>

View File

@@ -118,6 +118,32 @@
</tr>
[% SET first_row = 0 %]
[% END %]
[% WHILE (nbt = netbios.next) %]
<tr>
<td>
[% IF first_row %]
<a class="nd_linkcell"
href="[% search_node %]&q=[% nbt.mac | uri %]">[% nbt.mac | html_entity %]</a>
[% ELSE %]
&nbsp;
[% END %]
</td>
[% IF params.show_vendor %]
<td>
&nbsp;
</td>
[% END %]
<td>NetBIOS</td>
<td class="nd_linkcell">\\<a href="[% uri_for('report/netbios') %]?domain=[% nbt.domain | uri %]" title="Devices in this Domain">[% nbt.domain | html %]</a>\<a href="[% search_node %]&q=[% nbt.nbname | uri %]">[% nbt.nbname | html_entity %]</a>
<br>[% nbt.nbuser || '[No User]' | html %]@<a href="[% search_node %]&q=[% nbt.ip | uri %]">[% nbt.ip | html_entity %]</a>
</td>
[% IF params.stamps %]
<td>[% nbt.get_column('time_first_stamp') | html_entity %]</td>
<td>[% nbt.get_column('time_last_stamp') | html_entity %]</td>
[% END %]
</tr>
[% SET first_row = 0 %]
[% END %]
[% WHILE (wlan = wireless.next) %]
<tr>
<td>