observium sparklines plugin; support X:: namespace
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
* Manual Topology editing via the web
|
* Manual Topology editing via the web
|
||||||
* Job Queue view and delete page
|
* Job Queue view and delete page
|
||||||
* Empty device table prompts initial discover on homepage
|
* Empty device table prompts initial discover on homepage
|
||||||
|
* Support for App::NetdiscoX::Web::Plugin namespace
|
||||||
|
* Observium Sparklines port column plugin
|
||||||
|
|
||||||
[ENHANCEMENTS]
|
[ENHANCEMENTS]
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
* Navbar search is fuzzier
|
* Navbar search is fuzzier
|
||||||
* Phone node icon is a little phone handset
|
* Phone node icon is a little phone handset
|
||||||
* User icon color indicates port_control/admin ability
|
* User icon color indicates port_control/admin ability
|
||||||
|
* Buttons for discover/macsuck/arpnip on device details page
|
||||||
|
|
||||||
[BUG FIXES]
|
[BUG FIXES]
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ sub _load_web_plugins {
|
|||||||
my $plugin_list = shift;
|
my $plugin_list = shift;
|
||||||
|
|
||||||
foreach my $plugin (@$plugin_list) {
|
foreach my $plugin (@$plugin_list) {
|
||||||
|
$plugin =~ s/^X::/+App::NetdiscoX::Web::Plugin::/;
|
||||||
$plugin = 'App::Netdisco::Web::Plugin::'. $plugin
|
$plugin = 'App::Netdisco::Web::Plugin::'. $plugin
|
||||||
unless $plugin =~ m/^\+/;
|
if $plugin !~ m/^\+/;
|
||||||
$plugin =~ s/^\+//;
|
$plugin =~ s/^\+//;
|
||||||
|
|
||||||
debug "loading Netdisco plugin $plugin";
|
debug "loading Netdisco plugin $plugin";
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ use Dancer::Plugin::Ajax;
|
|||||||
use Dancer::Plugin::DBIC;
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
hook 'before' => sub {
|
hook 'before' => sub {
|
||||||
# list of port detail columns
|
my @default_port_columns_left = (
|
||||||
var('port_columns' => [
|
|
||||||
{ name => 'c_admin', label => 'Port Controls', default => '' },
|
{ name => 'c_admin', label => 'Port Controls', default => '' },
|
||||||
{ name => 'c_port', label => 'Port', default => 'on' },
|
{ name => 'c_port', label => 'Port', default => 'on' },
|
||||||
|
);
|
||||||
|
|
||||||
|
my @default_port_columns_right = (
|
||||||
{ name => 'c_descr', label => 'Description', default => '' },
|
{ name => 'c_descr', label => 'Description', default => '' },
|
||||||
{ name => 'c_type', label => 'Type', default => '' },
|
{ name => 'c_type', label => 'Type', default => '' },
|
||||||
{ name => 'c_duplex', label => 'Duplex', default => '' },
|
{ name => 'c_duplex', label => 'Duplex', default => '' },
|
||||||
@@ -24,7 +26,21 @@ hook 'before' => sub {
|
|||||||
{ name => 'c_neighbors', label => 'Connected Devices', default => 'on' },
|
{ name => 'c_neighbors', label => 'Connected Devices', default => 'on' },
|
||||||
{ name => 'c_stp', label => 'Spanning Tree', default => '' },
|
{ name => 'c_stp', label => 'Spanning Tree', default => '' },
|
||||||
{ name => 'c_up', label => 'Status', default => '' },
|
{ name => 'c_up', label => 'Status', default => '' },
|
||||||
]);
|
);
|
||||||
|
|
||||||
|
# build list of port detail columns
|
||||||
|
my @port_columns = ();
|
||||||
|
|
||||||
|
push @port_columns,
|
||||||
|
grep {$_->{position} eq 'left'} @{ setting('_extra_device_port_cols') };
|
||||||
|
push @port_columns, @default_port_columns_left;
|
||||||
|
push @port_columns,
|
||||||
|
grep {$_->{position} eq 'mid'} @{ setting('_extra_device_port_cols') };
|
||||||
|
push @port_columns, @default_port_columns_right;
|
||||||
|
push @port_columns,
|
||||||
|
grep {$_->{position} eq 'right'} @{ setting('_extra_device_port_cols') };
|
||||||
|
|
||||||
|
var('port_columns' => \@port_columns);
|
||||||
|
|
||||||
# view settings for port connected devices
|
# view settings for port connected devices
|
||||||
var('connected_properties' => [
|
var('connected_properties' => [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use Dancer ':syntax';
|
|||||||
use Dancer::Plugin;
|
use Dancer::Plugin;
|
||||||
|
|
||||||
set(
|
set(
|
||||||
|
'_extra_device_port_cols' => [],
|
||||||
'_navbar_items' => [],
|
'_navbar_items' => [],
|
||||||
'_search_tabs' => [],
|
'_search_tabs' => [],
|
||||||
'_device_tabs' => [],
|
'_device_tabs' => [],
|
||||||
@@ -29,6 +30,26 @@ register 'register_template_path' => sub {
|
|||||||
$path;
|
$path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
register 'register_device_port_column' => sub {
|
||||||
|
my ($self, $config) = plugin_args(@_);
|
||||||
|
$config->{default} ||= '';
|
||||||
|
$config->{position} ||= 'right';
|
||||||
|
|
||||||
|
if (!length $config->{name} or !length $config->{label}) {
|
||||||
|
error "bad config to register_device_port_column";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach my $item (@{ setting('_extra_device_port_cols') }) {
|
||||||
|
if ($item->{name} eq $config->{name}) {
|
||||||
|
$item = $config;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
push @{ setting('_extra_device_port_cols') }, $config;
|
||||||
|
};
|
||||||
|
|
||||||
register 'register_navbar_item' => sub {
|
register 'register_navbar_item' => sub {
|
||||||
my ($self, $config) = plugin_args(@_);
|
my ($self, $config) = plugin_args(@_);
|
||||||
|
|
||||||
|
|||||||
15
Netdisco/lib/App/NetdiscoX/Web/Plugin/ObserviumSparklines.pm
Normal file
15
Netdisco/lib/App/NetdiscoX/Web/Plugin/ObserviumSparklines.pm
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package App::NetdiscoX::Web::Plugin::ObserviumSparklines;
|
||||||
|
|
||||||
|
use Dancer ':syntax';
|
||||||
|
use Dancer::Plugin::DBIC;
|
||||||
|
|
||||||
|
use App::Netdisco::Web::Plugin;
|
||||||
|
|
||||||
|
register_device_port_column({
|
||||||
|
name => 'c_observiumsparklines',
|
||||||
|
position => 'mid',
|
||||||
|
label => 'Traffic',
|
||||||
|
default => 'on',
|
||||||
|
});
|
||||||
|
|
||||||
|
true;
|
||||||
@@ -28,6 +28,17 @@
|
|||||||
[% END %]
|
[% END %]
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
||||||
|
[% NEXT UNLESS config.position == 'left' AND params.${config.name} %]
|
||||||
|
<td>
|
||||||
|
[% TRY %]
|
||||||
|
[% INCLUDE "plugin/device_port_column/${config.name}.tt" %]
|
||||||
|
[% CATCH %]
|
||||||
|
<!-- dummy content required by Template Toolkit TRY -->
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
|
[% END %]
|
||||||
|
|
||||||
[% IF params.c_port %]
|
[% IF params.c_port %]
|
||||||
[% IF vars.user.port_control AND params.c_admin %]
|
[% IF vars.user.port_control AND params.c_admin %]
|
||||||
[% IF row.up_admin == 'up' %]
|
[% IF row.up_admin == 'up' %]
|
||||||
@@ -52,6 +63,17 @@
|
|||||||
</a></td>
|
</a></td>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
||||||
|
[% NEXT UNLESS config.position == 'mid' AND params.${config.name} %]
|
||||||
|
<td>
|
||||||
|
[% TRY %]
|
||||||
|
[% INCLUDE "plugin/device_port_column/${config.name}.tt" %]
|
||||||
|
[% CATCH %]
|
||||||
|
<!-- dummy content required by Template Toolkit TRY -->
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
|
[% END %]
|
||||||
|
|
||||||
[% IF params.c_descr %]
|
[% IF params.c_descr %]
|
||||||
<td nowrap>[% row.descr | html_entity %]</td>
|
<td nowrap>[% row.descr | html_entity %]</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
@@ -229,6 +251,17 @@
|
|||||||
[% row.up_admin.ucfirst | html_entity %] / [% row.up.ucfirst | html_entity %]
|
[% row.up_admin.ucfirst | html_entity %] / [% row.up.ucfirst | html_entity %]
|
||||||
</td>
|
</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
[% FOREACH config IN settings._extra_device_port_cols %]
|
||||||
|
[% NEXT UNLESS config.position == 'right' AND params.${config.name} %]
|
||||||
|
<td>
|
||||||
|
[% TRY %]
|
||||||
|
[% INCLUDE "plugin/device_port_column/${config.name}.tt" %]
|
||||||
|
[% CATCH %]
|
||||||
|
<!-- dummy content required by Template Toolkit TRY -->
|
||||||
|
[% END %]
|
||||||
|
</td>
|
||||||
|
[% END %]
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<!-- not yet a hyperlink as observium does not support device details page by device-name -->
|
||||||
|
<img src="http://[% settings.plugin_c_observiumsparklines.webhost | html_entity %]/graph.php?type=port_bits&device=[% device | uri %]&port=[% row.port | uri %]&from=-1d&to=now&width=100&height=20&legend=no"/>
|
||||||
Reference in New Issue
Block a user