change to use Virtual table for Poller Performance report
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
package App::Netdisco::DB::Result::Virtual::PollerPerformance;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use base 'DBIx::Class::Core';
|
||||||
|
|
||||||
|
__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
|
||||||
|
|
||||||
|
__PACKAGE__->table('poller_performance');
|
||||||
|
__PACKAGE__->result_source_instance->is_virtual(1);
|
||||||
|
__PACKAGE__->result_source_instance->view_definition(<<ENDSQL
|
||||||
|
SELECT action, entered, to_char( entered, 'YYYY - MM - DD HH24:MI:SS' ) AS entered_stamp,
|
||||||
|
COUNT( device ) AS number, MIN( started ) AS start, MAX( finished ) AS end,
|
||||||
|
justify_interval( extract ( epoch FROM( max( finished ) - min( started ) ) ) * interval '1 second' ) AS elapsed
|
||||||
|
FROM admin
|
||||||
|
WHERE action IN ( 'discover', 'macsuck', 'arpnip' )
|
||||||
|
GROUP BY action, entered
|
||||||
|
HAVING count( device ) > 1
|
||||||
|
ORDER BY elapsed DESC, entered DESC
|
||||||
|
LIMIT 15
|
||||||
|
ENDSQL
|
||||||
|
);
|
||||||
|
|
||||||
|
__PACKAGE__->add_columns(
|
||||||
|
"action",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"entered",
|
||||||
|
{ data_type => "timestamp", is_nullable => 1 },
|
||||||
|
"entered_stamp",
|
||||||
|
{ data_type => "text", is_nullable => 1 },
|
||||||
|
"number",
|
||||||
|
{ data_type => "integer", is_nullable => 1 },
|
||||||
|
"start",
|
||||||
|
{ data_type => "timestamp", is_nullable => 1 },
|
||||||
|
"end",
|
||||||
|
{ data_type => "timestamp", is_nullable => 1 },
|
||||||
|
"elapsed",
|
||||||
|
{ data_type => "interval", is_nullable => 1 },
|
||||||
|
);
|
||||||
|
|
||||||
|
1;
|
||||||
@@ -13,26 +13,7 @@ register_admin_task({
|
|||||||
});
|
});
|
||||||
|
|
||||||
ajax '/ajax/content/admin/performance' => require_role admin => sub {
|
ajax '/ajax/content/admin/performance' => require_role admin => sub {
|
||||||
my $set = schema('netdisco')->resultset('Admin')
|
my $set = schema('netdisco')->resultset('Virtual::PollerPerformance');
|
||||||
->search({
|
|
||||||
action => { -in => [qw/discover macsuck arpnip/] },
|
|
||||||
}, {
|
|
||||||
columns => [
|
|
||||||
'action', 'entered',
|
|
||||||
{ entered_stamp => \"to_char(entered, 'YYYY-MM-DD HH24:MI:SS')" },
|
|
||||||
],
|
|
||||||
select => [
|
|
||||||
{ count => 'device', -as => 'number' },
|
|
||||||
{ min => 'started', -as => 'start' },
|
|
||||||
{ max => 'finished', -as => 'end' },
|
|
||||||
\"justify_interval(extract(epoch from (max(finished) - min(started))) * interval '1 second') AS elapsed",
|
|
||||||
],
|
|
||||||
as => [qw/ number start end elapsed /],
|
|
||||||
group_by => [qw/ action entered /],
|
|
||||||
having => \'count(device) > 1',
|
|
||||||
order_by => { -desc => [qw/ entered elapsed /] },
|
|
||||||
rows => 50,
|
|
||||||
});
|
|
||||||
|
|
||||||
content_type('text/html');
|
content_type('text/html');
|
||||||
template 'ajax/admintask/performance.tt', {
|
template 'ajax/admintask/performance.tt', {
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
[% WHILE (row = results.next) %]
|
[% WHILE (row = results.next) %]
|
||||||
<tr>
|
<tr>
|
||||||
<td class="nd_center-cell">[% row.action.ucfirst | html_entity %]</td>
|
<td class="nd_center-cell">[% row.action.ucfirst | html_entity %]</td>
|
||||||
<td class="nd_center-cell">[% row.get_column('number') | html_entity %]</td>
|
<td class="nd_center-cell">[% row.number | html_entity %]</td>
|
||||||
<td class="nd_center-cell">[% row.get_column('entered_stamp') | html_entity %]</td>
|
<td class="nd_center-cell">[% row.entered_stamp | html_entity %]</td>
|
||||||
<td class="nd_center-cell">[% row.get_column('start') | html_entity %]</td>
|
<td class="nd_center-cell">[% row.start | html_entity %]</td>
|
||||||
<td class="nd_center-cell">[% row.get_column('end') | html_entity %]</td>
|
<td class="nd_center-cell">[% row.end | html_entity %]</td>
|
||||||
<td class="nd_center-cell">[% row.get_column('elapsed') | html_entity %]</td>
|
<td class="nd_center-cell">[% row.elapsed | html_entity %]</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user