From 36cea3ad57caa8fc88e9d46954b9acfb7d440673 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Wed, 28 Jun 2017 14:41:16 +0100 Subject: [PATCH] update stats web page to use db data --- lib/App/Netdisco/Web/Statistics.pm | 2 +- share/views/ajax/statistics.tt | 99 ++++++++++++++---------------- 2 files changed, 48 insertions(+), 53 deletions(-) diff --git a/lib/App/Netdisco/Web/Statistics.pm b/lib/App/Netdisco/Web/Statistics.pm index 400a5933..07a929a1 100644 --- a/lib/App/Netdisco/Web/Statistics.pm +++ b/lib/App/Netdisco/Web/Statistics.pm @@ -9,7 +9,7 @@ get '/ajax/content/statistics' => require_login sub { my $stats = schema('netdisco')->resultset('Statistics') ->search(undef, { order_by => { -desc => 'day' }, rows => 1 }); - $stats = ($stats->count ? $stats->first->hri : undef); + $stats = ($stats->count ? $stats->first : undef); var( nav => 'statistics' ); template 'ajax/statistics.tt', diff --git a/share/views/ajax/statistics.tt b/share/views/ajax/statistics.tt index becd7e43..5d06253d 100644 --- a/share/views/ajax/statistics.tt +++ b/share/views/ajax/statistics.tt @@ -1,6 +1,38 @@ [% USE Number.Format %]
+ [% IF stats.day %]
+

Statistics for this installation

+ + + + + + + + + + + + + + + + + + + + + + + +
[% stats.device_count | format_number %] devices + with [% stats.device_ip_count | format_number %] IPs +
[% stats.device_port_count | format_number %] interfaces + of which [% stats.device_port_up_count | format_number %] are up +
[% stats.device_link_count| format_number %] layer 2 links between devices
[% stats.node_table_count | format_number %] nodes of which [% stats.node_active_count | format_number %] are active
[% stats.ip_table_count | format_number %] IPs of which [% stats.ip_active_count | format_number %] are active
Statistics last generated on [% stats.day %]
+
+

Built using Open Source

@@ -12,66 +44,29 @@ - - - - - - - - - - - - - - - - - + - + + + + + + + + + + - +
App::Netdisco[% disco_ver | html_entity %]
DB Schemav[% schema_ver | html_entity %]
Dancer[% dancer_version | html_entity %]
Bootstrap[%# Can't determine magically %] 2.3.1
PostgreSQL - [% db_version| html_entity %].
-  DBI [% dbi_ver | html_entity %], - DBD::Pg [% dbdpg_ver | html_entity %] -
[% stats.netdisco_ver | html_entity %]
SNMP::Info[% snmpinfo_ver | html_entity %][% stats.snmpinfo_ver | html_entity %]
DB Schema[% stats.schema_ver | html_entity %]
PostgreSQL[% stats.pg_ver | html_entity %]
Perl[% perl_version | html_entity %][% stats.perl_ver | html_entity %]
-
-

Statistics for this installation

- - - - - - - - - - - - - - - - - - - - - - - - -
[% device_count | format_number %] devices with [% device_port_count | format_number %] interfaces - using [% device_count + device_ip_count | format_number %] IPs
[% device_links | format_number %] layer 2 links between devices
[% node_count | format_number %] nodes in [% node_table_count | format_number %] entries
[% ip_count | format_number %] IPs in [% ip_table_count | format_number %] entries
Statistics took [% process_time %] seconds to process.
-
+ [% ELSE %] +
Statistics will be available tomorrow.
+ [% END %]