Add Device addresses with DNS entries report
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
[NEW FEATURES]
|
[NEW FEATURES]
|
||||||
* Add Device PoE status report
|
* Add Device PoE status report
|
||||||
* Add Nodes with multiple IP addresses report
|
* Add Nodes with multiple IP addresses report
|
||||||
|
* Add Device addresses with DNS entries report
|
||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
|
|||||||
@@ -665,4 +665,62 @@ sub with_poestats_as_hashref {
|
|||||||
return \@return;
|
return \@return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
=head2 address_nodns_as_hashref
|
||||||
|
|
||||||
|
This is a modifier for C<search()> which returns a list of hash references
|
||||||
|
for devices addresses without a corresponding DNS entry.
|
||||||
|
|
||||||
|
Note: The DNS resolver checks both reverse and forward entries of the
|
||||||
|
address. Verify reverse and forward DNS entries if it appears an address
|
||||||
|
was included erroneously.
|
||||||
|
|
||||||
|
Returned hash keys:
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item ip
|
||||||
|
|
||||||
|
The primary IP address of the device.
|
||||||
|
|
||||||
|
=item dns
|
||||||
|
|
||||||
|
DNS entry of primary IP address of the device.
|
||||||
|
|
||||||
|
=item name
|
||||||
|
|
||||||
|
C<sysName> of the device.
|
||||||
|
|
||||||
|
=item location
|
||||||
|
|
||||||
|
C<sysLocation> of the device.
|
||||||
|
|
||||||
|
=item contact
|
||||||
|
|
||||||
|
C<sysContact> of the device.
|
||||||
|
|
||||||
|
=item alias
|
||||||
|
|
||||||
|
IP address belonging to the device without a corresponding DNS
|
||||||
|
entry.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub address_nodns_as_hashref {
|
||||||
|
my ( $rs, $cond, $attrs ) = @_;
|
||||||
|
|
||||||
|
my @return = $rs->search(
|
||||||
|
{ 'device_ips.dns' => undef },
|
||||||
|
{ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
|
||||||
|
select => [ 'ip', 'dns', 'name', 'location', 'contact' ],
|
||||||
|
join => [qw/device_ips/],
|
||||||
|
'+columns' => [ { 'alias' => 'device_ips.alias' }, ],
|
||||||
|
order_by => { -asc => [qw/me.ip device_ips.alias/] },
|
||||||
|
}
|
||||||
|
)->all;
|
||||||
|
|
||||||
|
return \@return;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package App::Netdisco::Web::Plugin::Report::DeviceAddrNoDNS;
|
||||||
|
|
||||||
|
use Dancer ':syntax';
|
||||||
|
use Dancer::Plugin::DBIC;
|
||||||
|
use Dancer::Plugin::Auth::Extensible;
|
||||||
|
|
||||||
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
|
register_report(
|
||||||
|
{ category => 'Device',
|
||||||
|
tag => 'deviceaddrnodns',
|
||||||
|
label => 'Addresses without DNS Entries',
|
||||||
|
provides_csv => 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
||||||
|
my $results = schema('netdisco')->resultset('Device')
|
||||||
|
->address_nodns_as_hashref;
|
||||||
|
|
||||||
|
return unless scalar $results;
|
||||||
|
|
||||||
|
if ( request->is_ajax ) {
|
||||||
|
template 'ajax/report/deviceaddrnodns.tt', { results => $results, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||||
|
template 'ajax/report/deviceaddrnodns_csv.tt',
|
||||||
|
{ results => $results, },
|
||||||
|
{ layout => undef };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -37,6 +37,7 @@ web_plugins:
|
|||||||
- Report::ApChannelDist
|
- Report::ApChannelDist
|
||||||
- Report::ApRadioChannelPower
|
- Report::ApRadioChannelPower
|
||||||
- Report::HalfDuplex
|
- Report::HalfDuplex
|
||||||
|
- Report::DeviceAddrNoDNS
|
||||||
- Report::DeviceByLocation
|
- Report::DeviceByLocation
|
||||||
- Report::DevicePoeStatus
|
- Report::DevicePoeStatus
|
||||||
- Report::DuplexMismatch
|
- Report::DuplexMismatch
|
||||||
|
|||||||
21
Netdisco/share/views/ajax/report/deviceaddrnodns.tt
Normal file
21
Netdisco/share/views/ajax/report/deviceaddrnodns.tt
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="nd_center-cell">Device</th>
|
||||||
|
<th class="nd_center-cell">Address</th>
|
||||||
|
<th class="nd_center-cell">Contact</th>
|
||||||
|
<th class="nd_center-cell">Location</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</tbody>
|
||||||
|
[% FOREACH row IN results %]
|
||||||
|
<tr>
|
||||||
|
<td class="nd_center-cell"><a href="[% search_device %]&q=[% row.dns || row.ip | uri %]">
|
||||||
|
[% row.dns || row.name || row.ip | html_entity %]</a>
|
||||||
|
<td class="nd_center-cell">[% row.alias | html_entity %]</td>
|
||||||
|
<td class="nd_center-cell">[% row.contact | html_entity %]</td>
|
||||||
|
<td class="nd_center-cell">[% row.location | html_entity %]</td>
|
||||||
|
</tr>
|
||||||
|
[% END %]
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
12
Netdisco/share/views/ajax/report/deviceaddrnodns_csv.tt
Normal file
12
Netdisco/share/views/ajax/report/deviceaddrnodns_csv.tt
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[% USE CSV -%]
|
||||||
|
[% CSV.dump([ 'Device' 'Address' 'Contact' 'Location' ]) %]
|
||||||
|
|
||||||
|
[% FOREACH row IN results %]
|
||||||
|
[% mylist = [] %]
|
||||||
|
[% mylist.push(row.dns || row.name || row.ip) %]
|
||||||
|
[% mylist.push(row.alias) %]
|
||||||
|
[% mylist.push(row.contact) %]
|
||||||
|
[% mylist.push(row.location) %]
|
||||||
|
[% CSV.dump(mylist) %]
|
||||||
|
|
||||||
|
[% END %]
|
||||||
Reference in New Issue
Block a user