add About page (jeneric) with system stats
Squashed commit of the following: commit f53b3778de8dc529c0d161a9339ad14e21294802 Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 21:05:39 2013 -0400 remove header from statistics table commit fa69b1b5900444ca5320502d8c22ecd7ee21df45 Author: Eric A. Miller <emiller@cpan.org> Date: Sun Sep 8 21:00:02 2013 -0400 about page - software and statistics
This commit is contained in:
@@ -19,6 +19,7 @@ use App::Netdisco::Web::Report;
|
|||||||
use App::Netdisco::Web::AdminTask;
|
use App::Netdisco::Web::AdminTask;
|
||||||
use App::Netdisco::Web::TypeAhead;
|
use App::Netdisco::Web::TypeAhead;
|
||||||
use App::Netdisco::Web::PortControl;
|
use App::Netdisco::Web::PortControl;
|
||||||
|
use App::Netdisco::Web::About;
|
||||||
|
|
||||||
sub _load_web_plugins {
|
sub _load_web_plugins {
|
||||||
my $plugin_list = shift;
|
my $plugin_list = shift;
|
||||||
|
|||||||
81
Netdisco/lib/App/Netdisco/Web/About.pm
Normal file
81
Netdisco/lib/App/Netdisco/Web/About.pm
Normal file
@@ -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;
|
||||||
79
Netdisco/share/views/about.tt
Normal file
79
Netdisco/share/views/about.tt
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row nd_hero-row">
|
||||||
|
<div class="hero-unit">
|
||||||
|
<h2>About Netdisco</h2>
|
||||||
|
<small>Netdisco is a web-based network management tool designed for
|
||||||
|
network administrators. Data is collected into a Postgres database
|
||||||
|
using SNMP.</small>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="span5 offset1">
|
||||||
|
<h4>Built using Open Source</h4>
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Software</th>
|
||||||
|
<th>Version</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th><b><a href="http://netdisco.org">App::Netdisco</a></b></th>
|
||||||
|
<th>[% disco_ver | html_entity %]</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><a href="http://http://perldancer.org/">Dancer</a></th>
|
||||||
|
<th>[% dancer_ver | html_entity %]</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><a href="http://www.perl.org">Perl</a></th>
|
||||||
|
<th>[% perl_ver | html_entity %]</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><a href="http://www.postgresql.org">PostgreSQL</a></th>
|
||||||
|
<th>
|
||||||
|
[% db_version| html_entity %] DBI [% dbi_ver | html_entity %]
|
||||||
|
DBD::Pg [% dbdpg_ver | html_entity %]
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><a href="http://getbootstrap.com">Bootstrap</a></th>
|
||||||
|
<th>[% # Can't determine magically %] 2.3.1</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><a href="http://http://snmp-info.sourceforge.net/">SNMP::Info</a></th>
|
||||||
|
<th>[% # Don't want to load in web to get version %]</th>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div class="span5">
|
||||||
|
<h4>Statistics for this installation</h4>
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>[% device_count %] devices with [% device_port_count %] interfaces
|
||||||
|
using [% device_count + device_ip_count %] IPs</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>[% device_links %] layer 2 links between devices.</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>[% node_count %] nodes in [% node_table_count %] entries. </th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>[% ip_count %] IPs in [% ip_table_count %] entries.</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Statistics took [% process_time %] seconds to process.</th>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div> <!-- /container -->
|
||||||
@@ -132,14 +132,13 @@
|
|||||||
[% ELSE %]
|
[% ELSE %]
|
||||||
<i class="icon-user"></i>
|
<i class="icon-user"></i>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF NOT settings.no_auth %]
|
|
||||||
[% session.logged_in_user | html_entity %] <b class="caret"></b></a>
|
[% session.logged_in_user | html_entity %] <b class="caret"></b></a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
[% IF NOT settings.no_auth %]
|
||||||
<li><a href="[% uri_for('/logout') %]">Log Out</a></li>
|
<li><a href="[% uri_for('/logout') %]">Log Out</a></li>
|
||||||
</ul>
|
|
||||||
[% ELSE %]
|
|
||||||
[% session.logged_in_user | html_entity %]</a>
|
|
||||||
[% END %]
|
[% END %]
|
||||||
|
<li><a href="[% uri_for('/about') %]">About</a></li>
|
||||||
|
</ul>
|
||||||
</li> <!-- /dropdown -->
|
</li> <!-- /dropdown -->
|
||||||
</ul>
|
</ul>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|||||||
Reference in New Issue
Block a user