Add Slow Devices admin report
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* Can now set untagged VLAN on trunking and non-trunking ports
|
||||
* Add user activity log to frontend admin menu
|
||||
* Add Poller Performance admin report
|
||||
* Add Slow Devices admin report
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
|
||||
42
Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm
Normal file
42
Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm
Normal file
@@ -0,0 +1,42 @@
|
||||
package App::Netdisco::DB::Result::Virtual::SlowDevices;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use base 'DBIx::Class::Core';
|
||||
|
||||
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||
|
||||
__PACKAGE__->table('slow_devices');
|
||||
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||
SELECT a.action, a.device, a.started, a.finished,
|
||||
justify_interval(extract(epoch FROM (a.finished - a.started)) * interval '1 second') AS elapsed
|
||||
FROM admin a
|
||||
INNER JOIN (
|
||||
SELECT device, action, max(started) AS started
|
||||
FROM admin
|
||||
WHERE status = 'done'
|
||||
AND action IN ('discover','macsuck','arpnip')
|
||||
GROUP BY action, device
|
||||
) b
|
||||
ON a.device = b.device AND a.started = b.started
|
||||
ORDER BY elapsed desc, action, device
|
||||
LIMIT 20
|
||||
ENDSQL
|
||||
);
|
||||
|
||||
__PACKAGE__->add_columns(
|
||||
"action",
|
||||
{ data_type => "text", is_nullable => 1 },
|
||||
"device",
|
||||
{ data_type => "inet", is_nullable => 1 },
|
||||
"started",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"finished",
|
||||
{ data_type => "timestamp", is_nullable => 1 },
|
||||
"elapsed",
|
||||
{ data_type => "interval", is_nullable => 1 },
|
||||
);
|
||||
|
||||
1;
|
||||
@@ -0,0 +1,24 @@
|
||||
package App::Netdisco::Web::Plugin::AdminTask::SlowDevices;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_admin_task({
|
||||
tag => 'slowdevices',
|
||||
label => 'Slowest Devices',
|
||||
});
|
||||
|
||||
ajax '/ajax/content/admin/slowdevices' => require_role admin => sub {
|
||||
my $set = schema('netdisco')->resultset('Virtual::SlowDevices');
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/admintask/slowdevices.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
};
|
||||
|
||||
true;
|
||||
28
Netdisco/share/views/ajax/admintask/slowdevices.tt
Normal file
28
Netdisco/share/views/ajax/admintask/slowdevices.tt
Normal file
@@ -0,0 +1,28 @@
|
||||
[% IF results.count == 0 %]
|
||||
<div class="span2 alert alert-info">The aren't enough jobs to report.</div>
|
||||
[% ELSE %]
|
||||
<table class="table table-bordered table-condensed table-hover nd_floatinghead">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="nd_center-cell">Action</th>
|
||||
<th class="nd_center-cell">Device</th>
|
||||
<th class="nd_center-cell">Started</th>
|
||||
<th class="nd_center-cell">Finished</th>
|
||||
<th class="nd_center-cell">Time Elapsed</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td class="nd_center-cell">[% row.action.ucfirst | html_entity %]</td>
|
||||
<td class="nd_center-cell"><a class="nd_linkcell"
|
||||
href="[% uri_for('/device') %]?q=[% row.device | uri %]">[% row.device | html_entity %]</a></td>
|
||||
<td class="nd_center-cell">[% row.started | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.finished | html_entity %]</td>
|
||||
<td class="nd_center-cell">[% row.elapsed | html_entity %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
[% END %]
|
||||
|
||||
Reference in New Issue
Block a user