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; | ||||
| @@ -34,6 +34,8 @@ path: '/' | ||||
| web_plugins: | ||||
|   - Inventory | ||||
|   - Report::PortUtilization | ||||
|   - Report::ApChannelDist | ||||
|   - Report::ApRadioChannelPower | ||||
|   - Report::HalfDuplex | ||||
|   - Report::DuplexMismatch | ||||
|   - AdminTask::PseudoDevice | ||||
|   | ||||
							
								
								
									
										17
									
								
								Netdisco/share/views/ajax/report/apchanneldist.tt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								Netdisco/share/views/ajax/report/apchanneldist.tt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| <table class="table table-bordered table-condensed table-striped nd_floatinghead"> | ||||
|   <thead> | ||||
|     <tr> | ||||
|       <th class="nd_center-cell">Channel</th> | ||||
|       <th class="nd_center-cell">Count</th> | ||||
|     </tr> | ||||
|   </thead> | ||||
|   </tbody> | ||||
|     [% WHILE (row = results.next) %] | ||||
|     <tr> | ||||
|       <td class="nd_center-cell">[% row.channel %]</td> | ||||
|       <td class="nd_center-cell">[% row.get_column('ch_count') %]</td> | ||||
|     </tr> | ||||
|     [% END %] | ||||
|   </tbody> | ||||
| </table> | ||||
|  | ||||
							
								
								
									
										52
									
								
								Netdisco/share/views/ajax/report/apradiochannelpower.tt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								Netdisco/share/views/ajax/report/apradiochannelpower.tt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| <div class="accordion" id="accordion-radio-pwr"> | ||||
| [% count = 0 %] | ||||
| [% FOREACH row IN results.keys.sort %] | ||||
|   [% count = count + 1 %] | ||||
|   <div class="accordion-group"> | ||||
|       <div class="accordion-heading">  | ||||
|           <a class="accordion-toggle" data-toggle="collapse" data-target="#collapse-[% count %]" href="#collapse-[% count %]"> | ||||
|             <i class="[% row.size < 10 ? 'icon-chevron-down' : 'icon-chevron-up' %]"></i>   | ||||
|             [% results.$row.device.dns || results.$row.device.name %]   | ||||
|             ( [% results.$row.device.model %] )   | ||||
|             [% IF results.$row.device.location %] | ||||
|               Location: [% results.$row.device.location %] | ||||
|             [% END %] | ||||
|           </a> | ||||
|       </div> | ||||
|     <div id="collapse-[% count %]" class="accordion-body collapse[% ' in' IF row.size < 10 %]"> | ||||
|       <div class="accordion-inner"> | ||||
|       <table class="table table-bordered table-condensed"> | ||||
|         <thead> | ||||
|           <tr> | ||||
|             <th>Port</th>             | ||||
|             <th>Name</th> | ||||
|             <th>Description</th> | ||||
|             <th class="nd_center-cell">Channel</th> | ||||
|             <th class="nd_center-cell">Tx Power (mW/dBm)</th> | ||||
|           </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|         [% FOREACH p IN results.$row.ports %] | ||||
|           [% NEXT UNLESS p.channel # No channel port is admin down %] | ||||
|           <tr> | ||||
|             <td> | ||||
|               <a href="[% device_ports %]&q=[% results.$row.device.dns || results.$row.device.ip | uri %]&f=[% p.port | uri %]"> | ||||
|                 [% p.port | html_entity %]</a></td> | ||||
|             <td>[% p.name %]</td> | ||||
|             <td>[% p.descr %]</td> | ||||
|             <td class="nd_center-cell">[% p.channel %]</td> | ||||
|             <td class="nd_center-cell">[% IF p.power or p.power2 %][% p.power %] / [% p.power2 %][% END %]</td> | ||||
|           </tr> | ||||
|         [% END %] | ||||
|         </tbody> | ||||
|       </table> | ||||
|     </div> | ||||
|   </div> | ||||
| [%END%] | ||||
| </div> | ||||
|  | ||||
| <script> | ||||
| $('.accordion').on('show hide', function (n) { | ||||
|     $(n.target).siblings('.accordion-heading').find('.accordion-toggle i').toggleClass('icon-chevron-up icon-chevron-down'); | ||||
| }); | ||||
| </script> | ||||
		Reference in New Issue
	
	Block a user