From 3334095c19e301d8383c9141ada8ba3fa6e4f332 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 9 Sep 2013 08:37:41 +0100 Subject: [PATCH] add About page (jeneric) with system stats Squashed commit of the following: commit f53b3778de8dc529c0d161a9339ad14e21294802 Author: Eric A. Miller Date: Sun Sep 8 21:05:39 2013 -0400 remove header from statistics table commit fa69b1b5900444ca5320502d8c22ecd7ee21df45 Author: Eric A. Miller Date: Sun Sep 8 21:00:02 2013 -0400 about page - software and statistics --- Netdisco/lib/App/Netdisco/Web.pm | 1 + Netdisco/lib/App/Netdisco/Web/About.pm | 81 ++++++++++++++++++++++++++ Netdisco/share/views/about.tt | 79 +++++++++++++++++++++++++ Netdisco/share/views/layouts/main.tt | 7 +-- 4 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 Netdisco/lib/App/Netdisco/Web/About.pm create mode 100644 Netdisco/share/views/about.tt diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index d9252a62..757f52ec 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -19,6 +19,7 @@ use App::Netdisco::Web::Report; use App::Netdisco::Web::AdminTask; use App::Netdisco::Web::TypeAhead; use App::Netdisco::Web::PortControl; +use App::Netdisco::Web::About; sub _load_web_plugins { my $plugin_list = shift; diff --git a/Netdisco/lib/App/Netdisco/Web/About.pm b/Netdisco/lib/App/Netdisco/Web/About.pm new file mode 100644 index 00000000..a8be2e09 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/About.pm @@ -0,0 +1,81 @@ +package App::Netdisco::Web::About; + +use Dancer ':syntax'; +use Dancer::Plugin::DBIC; +use Dancer::Plugin::Auth::Extensible; + +get '/about' => require_login sub { + + my $time1 = time; + my $schema = schema('netdisco'); + my $devices = $schema->resultset('Device')->search( + {}, + { select => [ { version => '' } ], + as => [qw/ version /], + } + ); + + my $device_count = $devices->count; + my $device_port_count = $schema->resultset('DevicePort')->count; + + my $device_ip_count = $schema->resultset('DeviceIp') + ->search( undef, { columns => [qw/ alias /] } )->count; + + my $nodes = $schema->resultset('Node')->search( + {}, + { columns => [qw/mac/], + distinct => 1 + } + ); + + my $node_count = $nodes->count; + my $node_table_count = $schema->resultset('Node')->count; + + my $nodes_ips = $schema->resultset('NodeIp')->search( + {}, + { columns => [qw/ip/], + distinct => 1 + } + ); + my $ip_count = $nodes_ips->count; + my $ip_table_count + = $schema->resultset('NodeIp')->search( {}, { columns => [qw/ip/] } ) + ->count; + my $device_links = $schema->resultset('DevicePort') + ->search( { 'remote_ip' => { '!=', undef } } )->count; + my $schema_version = $schema->get_db_version; + my $target_version = $schema->schema_version; + + my $time2 = time; + my $process_time = $time2 - $time1; + + my $disco_ver = $App::Netdisco::VERSION; + my $dancer_ver = $Dancer::VERSION; + my $perl_ver = sprintf( "v%vd", $^V ); + my $db_version = $devices->next->get_column('version'); + my $dbi_ver = $DBI::VERSION; + my $dbdpg_ver = $DBD::Pg::VERSION; + + var( nav => 'about' ); + + template 'about', + { + device_count => $device_count, + device_ip_count => $device_ip_count, + device_links => $device_links, + device_port_count => $device_port_count, + ip_count => $ip_count, + ip_table_count => $ip_table_count, + node_count => $node_count, + node_table_count => $node_table_count, + process_time => $process_time, + disco_ver => $disco_ver, + dancer_ver => $dancer_ver, + perl_ver => $perl_ver, + db_version => $db_version, + dbi_ver => $dbi_ver, + dbdpg_ver => $dbdpg_ver, + }; +}; + +true; diff --git a/Netdisco/share/views/about.tt b/Netdisco/share/views/about.tt new file mode 100644 index 00000000..adb37239 --- /dev/null +++ b/Netdisco/share/views/about.tt @@ -0,0 +1,79 @@ +
+
+
+

About Netdisco

+ Netdisco is a web-based network management tool designed for + network administrators. Data is collected into a Postgres database + using SNMP. +
+
+
+

Built using Open Source

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SoftwareVersion
App::Netdisco[% disco_ver | html_entity %]
Dancer[% dancer_ver | html_entity %]
Perl[% perl_ver | html_entity %]
PostgreSQL + [% db_version| html_entity %] DBI [% dbi_ver | html_entity %] + DBD::Pg [% dbdpg_ver | html_entity %] +
Bootstrap[% # Can't determine magically %] 2.3.1
SNMP::Info[% # Don't want to load in web to get version %]
+
+
+

Statistics for this installation

+ + + + + + + + + + + + + + + + + + + + + + + +
[% device_count %] devices with [% device_port_count %] interfaces + using [% device_count + device_ip_count %] IPs
[% device_links %] layer 2 links between devices.
[% node_count %] nodes in [% node_table_count %] entries.
[% ip_count %] IPs in [% ip_table_count %] entries.
Statistics took [% process_time %] seconds to process.
+
+
+
\ No newline at end of file diff --git a/Netdisco/share/views/layouts/main.tt b/Netdisco/share/views/layouts/main.tt index afad2173..51b77422 100644 --- a/Netdisco/share/views/layouts/main.tt +++ b/Netdisco/share/views/layouts/main.tt @@ -132,14 +132,13 @@ [% ELSE %] [% END %]  - [% IF NOT settings.no_auth %] [% session.logged_in_user | html_entity %] - [% ELSE %] - [% session.logged_in_user | html_entity %] [% END %] +
  • About
  • + [% END %]