Wireless AP Reports (jeneric)
Squashed commit of the following: commit 567df500f45bca6ead1a1f8b7698253450ad1cb5 Author: Oliver Gorwits <oliver@cpan.org> Date: Tue Sep 10 22:26:48 2013 +0100 collapse list if more than 10 APs commit 9dddb2432c1a44d19f4cacc75d64e91feb71e665 Author: Eric A. Miller <emiller@cpan.org> Date: Mon Sep 9 22:35:28 2013 -0400 add port descr commit eca417c46ab7dd07a66054ec0104e62b5099748b Author: Oliver Gorwits <oliver@cpan.org> Date: Mon Sep 9 21:55:49 2013 +0100 use real port description, and link to filtered ports view commit e4a43e78ffefa3cd3ad528ac7414dcd959beceaa Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 23:43:42 2013 -0400 add access point channel distribution report commit b6c803446d2bd02712910535c10a8ea3950ecd62 Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 22:06:37 2013 -0400 sync module and file name commit c70d251a17a791fd34a3d58ce5373c97c7d7eba1 Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 21:51:45 2013 -0400 perl tidy commit be8bc48d1ea9751164e167f155312f80ca0cf2d9 Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 21:49:55 2013 -0400 report ap radio power in both mW and dBm commit 54a88054ab15ee8d0e884e919e040f9f8092824b Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 15:47:18 2013 -0400 access point radios channel and power report
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package App::Netdisco::DB::Result::Virtual::ApRadioChannelPower;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('ap_radio_channel_power');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT distinct d.name as device_name, d.ip, d.dns, d.model, d.location,
|
||||
dp.port, dp.name as port_name, dp.descr, w.channel, w.power
|
||||
FROM device AS d, device_port_wireless AS w, device_port AS dp
|
||||
WHERE dp.port = w.port AND d.ip = w.ip
|
||||
ORDER BY d.name
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
'device_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'ip' => {
|
||||
data_type => 'inet',
|
||||
},
|
||||
'dns' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'model' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'location' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'port' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'port_name' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'descr' => {
|
||||
data_type => 'text',
|
||||
},
|
||||
'channel' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
'power' => {
|
||||
data_type => 'integer',
|
||||
},
|
||||
);
|
||||
|
||||
1;
|
||||
34
Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApChannelDist.pm
Normal file
34
Netdisco/lib/App/Netdisco/Web/Plugin/Report/ApChannelDist.pm
Normal file
@@ -0,0 +1,34 @@
|
||||
package App::Netdisco::Web::Plugin::Report::ApChannelDist;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_report(
|
||||
{ category => 'Wireless',
|
||||
tag => 'apchanneldist',
|
||||
label => 'Access Point Channel Distribution',
|
||||
}
|
||||
);
|
||||
|
||||
ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
||||
my $set = schema('netdisco')->resultset('DevicePortWireless')->search(
|
||||
{ channel => { '!=', '0' } },
|
||||
{ select => [ 'channel', { count => 'channel' } ],
|
||||
as => [qw/ channel ch_count /],
|
||||
group_by => [qw/channel/],
|
||||
order_by => { -desc => [qw/count/] },
|
||||
},
|
||||
);
|
||||
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/apchanneldist.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
};
|
||||
|
||||
true;
|
||||
@@ -0,0 +1,62 @@
|
||||
package App::Netdisco::Web::Plugin::Report::ApRadioChannelPower;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_report(
|
||||
{ category => 'Wireless',
|
||||
tag => 'apradiochannelpower',
|
||||
label => 'Access Point Radios Channel and Power',
|
||||
}
|
||||
);
|
||||
|
||||
sub port_tree {
|
||||
my $devices = shift;
|
||||
|
||||
my %ports;
|
||||
|
||||
foreach my $device (@$devices) {
|
||||
my $power2;
|
||||
|
||||
if ( defined( $device->power ) && $device->power ) {
|
||||
$power2 = sprintf( "%.1f",
|
||||
10.0 * CORE::log( $device->power ) / CORE::log(10) );
|
||||
}
|
||||
|
||||
$ports{ $device->device_name }{device} = {
|
||||
name => $device->device_name,
|
||||
ip => $device->ip,
|
||||
dns => $device->dns,
|
||||
model => $device->model,
|
||||
location => $device->location
|
||||
};
|
||||
push @{ $ports{ $device->device_name }{ports} },
|
||||
{
|
||||
port => $device->port,
|
||||
name => $device->port_name,
|
||||
descr => $device->descr,
|
||||
channel => $device->channel,
|
||||
power => $device->power,
|
||||
power2 => $power2
|
||||
};
|
||||
}
|
||||
return \%ports;
|
||||
}
|
||||
|
||||
ajax '/ajax/content/report/apradiochannelpower' => require_login sub {
|
||||
my @set
|
||||
= schema('netdisco')->resultset('Virtual::ApRadioChannelPower')->all;
|
||||
|
||||
my $results = port_tree( \@set );
|
||||
return unless scalar %$results;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/apradiochannelpower.tt', { results => $results, },
|
||||
{ layout => undef };
|
||||
};
|
||||
|
||||
true;
|
||||
Reference in New Issue
Block a user