#410 improvements to Undiscovered Neighbors report
This commit is contained in:
1
Changes
1
Changes
@@ -3,6 +3,7 @@
|
|||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
* #408 improvements to MakeRancidConf (earendilfr)
|
* #408 improvements to MakeRancidConf (earendilfr)
|
||||||
|
* #410 improvements to Undiscovered Neighbors report
|
||||||
|
|
||||||
2.039028 - 2018-05-05
|
2.039028 - 2018-05-05
|
||||||
|
|
||||||
|
|||||||
@@ -11,28 +11,32 @@ __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
|||||||
__PACKAGE__->table('undiscovered_neighbors');
|
__PACKAGE__->table('undiscovered_neighbors');
|
||||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||||
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
__PACKAGE__->result_source_instance->view_definition(<<'ENDSQL');
|
||||||
SELECT DISTINCT ON (p.remote_ip) d.ip,
|
SELECT DISTINCT ON (p.remote_ip, p.port)
|
||||||
d.name,
|
d.ip, d.name, d.dns,
|
||||||
d.dns,
|
p.port, p.name AS port_description,
|
||||||
p.port,
|
p.remote_ip, p.remote_id, p.remote_type, p.remote_port,
|
||||||
p.remote_ip,
|
l.log AS comment,
|
||||||
p.remote_id,
|
a.log, a.finished
|
||||||
p.remote_type,
|
|
||||||
p.remote_port,
|
FROM device_port p
|
||||||
a.log,
|
|
||||||
a.finished
|
INNER JOIN device d USING (ip)
|
||||||
FROM device_port p
|
LEFT OUTER JOIN device_skip ds
|
||||||
JOIN device d
|
ON ('discover' = ANY(ds.actionset) AND p.remote_ip = ds.device)
|
||||||
ON d.ip = p.ip
|
LEFT OUTER JOIN device_port_log l USING (ip, port)
|
||||||
LEFT JOIN admin a
|
LEFT OUTER JOIN admin a
|
||||||
ON (p.remote_ip = a.device AND a.action = 'discover')
|
ON (p.remote_ip = a.device AND a.action = 'discover')
|
||||||
WHERE
|
|
||||||
(p.remote_ip NOT IN (SELECT alias FROM device_ip))
|
WHERE
|
||||||
OR
|
ds.device IS NULL
|
||||||
((p.remote_ip IS NULL) AND p.is_uplink)
|
AND ((p.remote_ip NOT IN (SELECT alias FROM device_ip))
|
||||||
ORDER BY
|
OR ((p.remote_ip IS NULL) AND p.is_uplink))
|
||||||
p.remote_ip ASC,
|
|
||||||
a.finished DESC
|
ORDER BY
|
||||||
|
p.remote_ip ASC,
|
||||||
|
p.port ASC,
|
||||||
|
l.creation DESC,
|
||||||
|
a.finished DESC
|
||||||
ENDSQL
|
ENDSQL
|
||||||
|
|
||||||
__PACKAGE__->add_columns(
|
__PACKAGE__->add_columns(
|
||||||
@@ -44,6 +48,8 @@ __PACKAGE__->add_columns(
|
|||||||
{ data_type => "text", is_nullable => 1 },
|
{ data_type => "text", is_nullable => 1 },
|
||||||
"port",
|
"port",
|
||||||
{ data_type => "text", is_nullable => 0 },
|
{ data_type => "text", is_nullable => 0 },
|
||||||
|
"port_description",
|
||||||
|
{ data_type => "text", is_nullable => 0 },
|
||||||
"remote_ip",
|
"remote_ip",
|
||||||
{ data_type => "inet", is_nullable => 1 },
|
{ data_type => "inet", is_nullable => 1 },
|
||||||
"remote_port",
|
"remote_port",
|
||||||
@@ -52,6 +58,8 @@ __PACKAGE__->add_columns(
|
|||||||
{ data_type => "text", is_nullable => 1 },
|
{ data_type => "text", is_nullable => 1 },
|
||||||
"remote_id",
|
"remote_id",
|
||||||
{ data_type => "text", is_nullable => 1 },
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"comment",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
"log",
|
"log",
|
||||||
{ data_type => "text", is_nullable => 1 },
|
{ data_type => "text", is_nullable => 1 },
|
||||||
"finished",
|
"finished",
|
||||||
|
|||||||
@@ -18,29 +18,28 @@ register_admin_task(
|
|||||||
|
|
||||||
get '/ajax/content/admin/undiscoveredneighbors' => require_role admin => sub {
|
get '/ajax/content/admin/undiscoveredneighbors' => require_role admin => sub {
|
||||||
my @results
|
my @results
|
||||||
= schema('netdisco')->resultset('Virtual::UndiscoveredNeighbors')
|
= schema('netdisco')->resultset('Virtual::UndiscoveredNeighbors')->hri->all;
|
||||||
->order_by('ip')->hri->all;
|
|
||||||
return unless scalar @results;
|
return unless scalar @results;
|
||||||
|
|
||||||
# Don't include devices excluded from discovery by config
|
# Don't include devices excluded from discovery by config
|
||||||
# but only if the number of devices is small, as it triggers a
|
my @discoverable_results = ();
|
||||||
# SELECT per device to check.
|
foreach my $r (@results) {
|
||||||
if (scalar @results < 50) {
|
# create a new row object to avoid hitting the DB in get_device()
|
||||||
@results
|
my $dev = schema('netdisco')->resultset('Device')->new({ip => $r->{remote_ip}});
|
||||||
= grep { is_discoverable( $_->{'remote_ip'}, $_->{'remote_type'} ) }
|
next unless is_discoverable( $dev, $r->{remote_type} );
|
||||||
@results;
|
push @discoverable_results, $r;
|
||||||
}
|
}
|
||||||
return unless scalar @results;
|
return unless scalar @discoverable_results;
|
||||||
|
|
||||||
if ( request->is_ajax ) {
|
if ( request->is_ajax ) {
|
||||||
template 'ajax/admintask/undiscoveredneighbors.tt',
|
template 'ajax/admintask/undiscoveredneighbors.tt',
|
||||||
{ results => \@results, },
|
{ results => \@discoverable_results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
template 'ajax/admintask/undiscoveredneighbors_csv.tt',
|
template 'ajax/admintask/undiscoveredneighbors_csv.tt',
|
||||||
{ results => \@results, },
|
{ results => \@discoverable_results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,31 +1,29 @@
|
|||||||
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Observing Device</th>
|
<th>Observing Interface</th>
|
||||||
<th>Undiscovered Neighbor</th>
|
<th>Undiscovered Neighbor</th>
|
||||||
<th class="nd_center-cell">Last Discovery Attempt</th>
|
<th>Neighbor ID</th>
|
||||||
<th class="nd_center-cell">Last Discovery Log</th>
|
<th nowrap>Last Discovery</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</tbody>
|
</tbody>
|
||||||
[% FOREACH row IN results %]
|
[% FOREACH row IN results %]
|
||||||
|
[% NEXT IF NOT row.remote_ip %]
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
<td nowrap><a href="[% device_ports %]&q=[% row.ip | uri %]">
|
||||||
[% row.dns || row.name || row.ip | html_entity %] ( [% row.port | html_entity %] ) </a></td>
|
[% row.dns || row.name || row.ip | html_entity %]</a><br>
|
||||||
<td>
|
<a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
||||||
[% IF row.remote_ip %]
|
[% row.port | html_entity %]</a>
|
||||||
<a href="[% search_node %]&q=[% row.remote_ip | uri %]">
|
[% IF row.port_description %]<br>[% row.port_description | html_entity %][% END %]
|
||||||
[% row.remote_ip | html_entity %]
|
[% IF row.comment %]<br>"<em>[% row.comment | html_entity %]</em>"[% END %]
|
||||||
</a> ([% row.remote_port | html_entity %])
|
|
||||||
[% '<br />' IF row.remote_id or row.remote_type %]
|
|
||||||
[% ' id: '_ row.remote_id IF row.remote_id %]
|
|
||||||
[% ' type: '_ row.remote_type IF row.remote_type %]
|
|
||||||
[% ELSE %]
|
|
||||||
Known Device's MAC Address seen on this Port during Macsuck
|
|
||||||
[% END %]
|
|
||||||
</td>
|
</td>
|
||||||
<td class="nd_center-cell">[% row.finished | html_entity %]</td>
|
<td nowrap><a href="[% search_node %]&q=[% row.remote_ip | uri %]">
|
||||||
<td class="nd_center-cell">[% row.log | html_entity %]</td>
|
[% row.remote_ip | html_entity %]</a><br>
|
||||||
|
[% row.remote_port | html_entity %]</td>
|
||||||
|
<td>[% row.remote_id | html_entity %]<br>
|
||||||
|
[% row.remote_type | remove('(?:(?:C|c)opyright\s+)?\(c\).*') | remove('Technical Support: http://.*') | html_entity | html_line_break %]</td>
|
||||||
|
<td nowrap>[% row.finished | html_entity %]<br>[% row.log | html_entity %]</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user