NetBIOS Node Report
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
* [#86] Use Vendor abbrevs to enhance node display in device port view
|
* [#86] Use Vendor abbrevs to enhance node display in device port view
|
||||||
* [#74] Device Name / DNS mismatches report
|
* [#74] Device Name / DNS mismatches report
|
||||||
* [#71] Node search by date (but not time)
|
* [#71] Node search by date (but not time)
|
||||||
* [#73] NetBIOS Poller - nbtstat and nbtwalk
|
* [#73] NetBIOS Poller (nbtstat and nbtwalk), NetBIOS Node Report
|
||||||
* [#56] Support API call to /login
|
* [#56] Support API call to /login
|
||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|||||||
75
Netdisco/lib/App/Netdisco/Web/Plugin/Report/Netbios.pm
Normal file
75
Netdisco/lib/App/Netdisco/Web/Plugin/Report/Netbios.pm
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
package App::Netdisco::Web::Plugin::Report::Netbios;
|
||||||
|
|
||||||
|
use Dancer ':syntax';
|
||||||
|
use Dancer::Plugin::DBIC;
|
||||||
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
|
register_report(
|
||||||
|
{ category => 'Node',
|
||||||
|
tag => 'netbios',
|
||||||
|
label => 'NetBIOS Inventory',
|
||||||
|
provides_csv => 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
hook 'before_template' => sub {
|
||||||
|
my $tokens = shift;
|
||||||
|
|
||||||
|
return
|
||||||
|
unless ( request->path eq uri_for('/report/netbios')->path
|
||||||
|
or
|
||||||
|
index( request->path, uri_for('/ajax/content/report/netbios')->path )
|
||||||
|
== 0 );
|
||||||
|
|
||||||
|
# used in the search sidebar template to set selected items
|
||||||
|
foreach my $opt (qw/domain/) {
|
||||||
|
my $p = (
|
||||||
|
ref [] eq ref param($opt)
|
||||||
|
? param($opt)
|
||||||
|
: ( param($opt) ? [ param($opt) ] : [] )
|
||||||
|
);
|
||||||
|
$tokens->{"${opt}_lkp"} = { map { $_ => 1 } @$p };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
get '/ajax/content/report/netbios' => require_login sub {
|
||||||
|
|
||||||
|
my $domain = param('domain');
|
||||||
|
|
||||||
|
my $rs = schema('netdisco')->resultset('NodeNbt');
|
||||||
|
|
||||||
|
if ( defined $domain ) {
|
||||||
|
$domain = '' if $domain eq 'blank';
|
||||||
|
$rs = $rs->search( { domain => $domain } )->order_by(
|
||||||
|
[ { -asc => 'domain' },
|
||||||
|
{ -desc => 'time_last' }
|
||||||
|
]
|
||||||
|
)->hri;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$rs = $rs->search(
|
||||||
|
{},
|
||||||
|
{ select => [ 'domain', { count => 'domain' } ],
|
||||||
|
as => [qw/ domain count /],
|
||||||
|
group_by => [qw/ domain /]
|
||||||
|
}
|
||||||
|
)->order_by( { -desc => 'count' } )->hri;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return unless $rs->has_rows;
|
||||||
|
|
||||||
|
if ( request->is_ajax ) {
|
||||||
|
template 'ajax/report/netbios.tt', { results => $rs, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
|
template 'ajax/report/netbios_csv.tt', { results => $rs, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -1,18 +1,27 @@
|
|||||||
package App::Netdisco::Web::Report;
|
package App::Netdisco::Web::Report;
|
||||||
|
|
||||||
use Dancer ':syntax';
|
use Dancer ':syntax';
|
||||||
|
use Dancer::Plugin::DBIC;
|
||||||
use Dancer::Plugin::Auth::Extensible;
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
get '/report/*' => require_login sub {
|
get '/report/*' => require_login sub {
|
||||||
my ($tag) = splat;
|
my ($tag) = splat;
|
||||||
|
|
||||||
|
# used in the report search sidebar to populate select inputs
|
||||||
|
my $domain_list
|
||||||
|
= [
|
||||||
|
schema('netdisco')->resultset('NodeNbt')->get_distinct_col('domain')
|
||||||
|
];
|
||||||
|
|
||||||
# trick the ajax into working as if this were a tabbed page
|
# trick the ajax into working as if this were a tabbed page
|
||||||
params->{tab} = $tag;
|
params->{tab} = $tag;
|
||||||
|
|
||||||
var(nav => 'reports');
|
var( nav => 'reports' );
|
||||||
template 'report', {
|
template 'report',
|
||||||
report => setting('_reports')->{ $tag },
|
{
|
||||||
};
|
report => setting('_reports')->{$tag},
|
||||||
|
domain_list => $domain_list,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ web_plugins:
|
|||||||
- Report::DevicePoeStatus
|
- Report::DevicePoeStatus
|
||||||
- Report::DuplexMismatch
|
- Report::DuplexMismatch
|
||||||
- Report::IpInventory
|
- Report::IpInventory
|
||||||
|
- Report::Netbios
|
||||||
- Report::NodeMultiIPs
|
- Report::NodeMultiIPs
|
||||||
- Report::PhonesDiscovered
|
- Report::PhonesDiscovered
|
||||||
- Report::SsidInventory
|
- Report::SsidInventory
|
||||||
|
|||||||
48
Netdisco/share/views/ajax/report/netbios.tt
Normal file
48
Netdisco/share/views/ajax/report/netbios.tt
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
[% USE date(format = '%Y-%m-%d %H:%M') %]
|
||||||
|
[% USE Number.Format %]
|
||||||
|
[% first = results.first %]
|
||||||
|
[% IF results.first.mac %]
|
||||||
|
[% row = results.reset %]
|
||||||
|
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Domain</th>
|
||||||
|
<th>Node</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>User</th>
|
||||||
|
<th>First Seen</th>
|
||||||
|
<th>Last Seen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
<tr>
|
||||||
|
<td>[% row.domain | html_entity %]</td>
|
||||||
|
<td><a href="[% search_node %]&q=[% row.mac | uri %]">[% row.mac.upper | html_entity %]</td>
|
||||||
|
<td>[% IF row.domain %]\\[% row.domain | html %]\[% END %]<a href="[% search_node %]&q=[% row.nbname | uri %]">[% row.nbname | html_entity %]</a></td>
|
||||||
|
<td>[% row.nbuser || '[No User]' | html %]@<a href="[% search_node %]&q=[% row.ip | uri %]">[% row.ip | html_entity %]</a></td>
|
||||||
|
<td>[% date.format(row.time_first) | html_entity %]</td>
|
||||||
|
<td>[% date.format(row.time_last) | html_entity %]</td>
|
||||||
|
</tr>
|
||||||
|
[% END %]
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
[% ELSE %]
|
||||||
|
[% row = results.reset %]
|
||||||
|
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Domain</th>
|
||||||
|
<th>Count</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
[% WHILE (row = results.next) %]
|
||||||
|
<tr>
|
||||||
|
<td class="nd_linkcell"><a href="[% uri_for('report/netbios') %]?domain=[% row.domain || 'blank' | uri %]">[% row.domain || '(Blank Domain)' | html %]</a></td>
|
||||||
|
<td>[% row.count | format_number %]</td>
|
||||||
|
</tr>
|
||||||
|
[% END %]
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
[% END %]
|
||||||
19
Netdisco/share/views/sidebar/report/netbios.tt
Normal file
19
Netdisco/share/views/sidebar/report/netbios.tt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
|
||||||
|
<p class="nd_sidebar-title"><em>NetBIOS Search Options</em></p>
|
||||||
|
<div class="clearfix">
|
||||||
|
<select class="nd_side-select" size="[% domain_list.size > 8 ? 8 : domain_list.size %]"
|
||||||
|
multiple="on" name="domain"
|
||||||
|
rel="tooltip" data-placement="left" data-offset="5" data-title="Domain"/>
|
||||||
|
[% FOREACH opt IN domain_list %]
|
||||||
|
[% UNLESS opt == '' %]
|
||||||
|
<option[% ' selected="selected"' IF domain_lkp.exists(opt) %]>[% opt | html_entity %]</option>
|
||||||
|
[% ELSE %]
|
||||||
|
<option value="blank"[% ' selected="selected"' IF domain_lkp.exists('blank') %]>[% '(Blank Domain)' | html_entity %]</option>
|
||||||
|
[% END %]
|
||||||
|
[% END %]
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="[% report.tag %]_submit" type="submit" class="btn btn-info">
|
||||||
|
<i class="icon-search icon-large pull-left nd_navbar-icon"></i> Search NetBIOS</button>
|
||||||
|
|
||||||
Reference in New Issue
Block a user