Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.

Commit

Permalink
NMIS release 8.6.1G
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zangerl committed Dec 21, 2016
1 parent 788324e commit 5a3711a
Show file tree
Hide file tree
Showing 80 changed files with 3,223 additions and 2,067 deletions.
349 changes: 286 additions & 63 deletions admin/node_admin.pl

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions admin/node_sys_check.pl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ sub checkNode {
my @interfaceSections = qw(interface pkts pkts_hc);
my @cpuSections = qw(hrsmpcpu);

my @systemHealthSections = qw(bgpPeer);
my @systemHealthSections = qw(
hrdisk
bgpPeer
mtxrWlRtab
mtxrWlAp
mtxrWlStat
WirelessAccessPoint
WirelessRegistration
);

my %nodeevents = loadAllEvents(node => $node);

Expand Down Expand Up @@ -136,6 +144,7 @@ sub checkNode {
) {
print "FIXING: $node has $section in data but no modelling\n";
delete $NI->{$section};
$changes = 1;
}
}

Expand Down Expand Up @@ -197,6 +206,7 @@ sub checkNode {

}

print "INFO: $node working on @cpuSections\n" if $debug;
foreach my $section (@cpuSections) {
if ( defined $NI->{graphtype}{$indx}{$section} and defined $NI->{device}{$indx} ) {
# there should be an interface to check
Expand Down Expand Up @@ -237,22 +247,31 @@ sub checkNode {
# "bgpPeer" : "bgpPeerStats,bgpPeer"
# },

print "INFO: $node working on @systemHealthSections\n" if $debug;
# clean up systemHealth Sections, BGP Peers initially
foreach my $section (@systemHealthSections) {
print " looking for $section with index $indx in graphtype\n" if $debug;
if ( defined $NI->{graphtype}{$indx}{$section}
and defined $NI->{$section}
and exists $NI->{$section}
and (keys %{$NI->{$section}})
and defined $NI->{$section}{$indx}
and exists $NI->{$section}{$indx}
) {
# there should be an section to check
print "INFO: $node graphtype $indx for $section and found $section\n" if $debug;
}
elsif ( defined $NI->{graphtype}{$indx}{$section}
and not defined $NI->{$section}
) {
print "FIXING: $node $indx has graphtype $section but no nodeinfo section defined\n";
delete $NI->{graphtype}{$indx}{$section};
$changes = 1;
}
elsif ( defined $NI->{graphtype}{$indx}{$section}
and defined $NI->{$section}
and (keys %{$NI->{$section}})
and not defined $NI->{$section}{$indx}
) {
print "FIXING: $node $indx has graphtype $section but no $section\n";
print "FIXING: $node $indx has graphtype $section but no nodeinfo section defined\n";

delete $NI->{graphtype}{$indx}{$section};

Expand Down Expand Up @@ -283,6 +302,12 @@ sub checkNode {
}


if ( defined $NI->{graphtype}{radio} and $NI->{graphtype}{radio} =~ /linkrate/ ) {
print "FIXING: $node radio $indx has graphtype linkrate things\n";
$NI->{graphtype}{radio} = "signal,power,env-temp";
$changes = 1;
}

if ( ref($NI->{graphtype}{$indx}) eq "HASH" and not keys %{$NI->{graphtype}{$indx}} ) {
print "FIXING: $node $indx graphtype has no keys\n";
delete $NI->{graphtype}{$indx};
Expand Down
74 changes: 74 additions & 0 deletions admin/samples/nodes_toggle_snmp_version.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/perl
#
# Copyright (C) Opmantek Limited (www.opmantek.com)
#
# ALL CODE MODIFICATIONS MUST BE SENT TO [email protected]
#
# This file is part of Network Management Information System ("NMIS").
#
# NMIS is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# NMIS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NMIS (most likely in a file named LICENSE).
# If not, see <http://www.gnu.org/licenses/>
#
# For further information on NMIS or for a license other than GPL please see
# www.opmantek.com or email [email protected]
#
# User group details:
# http://support.opmantek.com/users/
#
# *****************************************************************************
#
# this small contraption toggles multiple nodes' snmp versions between 1 and 2c,
# if the node is currently marked as 'snmp down'. other nodes are not
# touched. when done, a new conf/Nodes.nmis.new is left for you to
# activate/peruse.

use FindBin;
use lib "$FindBin::Bin/../lib";

use strict;
use func;
use NMIS;

# Get some command line arguements.
my %arg = getArguements(@ARGV);

# Load the NMIS Config
my $C = loadConfTable(conf=>$arg{conf},debug=>$arg{debug});

# Load the current Nodes Table.
my $LNT = loadLocalNodeTable();

my $mustupdate;
foreach my $node (sort keys %{$LNT})
{
if (getbool($LNT->{$node}{active})
and getbool($LNT->{$node}{collect}))
{
my $infodata = readFiletoHash(file => $C->{'<nmis_var>'}.lc("/$node-node.json"));
next if (!getbool($infodata->{system}->{snmpdown}));
my $currentversion = $LNT->{$node}->{version};
next if ($currentversion eq "snmpv3");

$LNT->{$node}->{version} = ($currentversion eq "snmpv1")? "snmpv2c" : "snmpv1";
++$mustupdate;
print "Updating $node, from $currentversion to $LNT->{$node}->{version}\n";
}
}

if ($mustupdate)
{
writeHashtoFile(file => "$C->{'<nmis_conf>'}/Nodes.nmis.new", data => $LNT);
}


78 changes: 42 additions & 36 deletions admin/service_graph_helper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#
# this helper guides you through the process of creating custom graphs
# for such services.
our $VERSION = "1.0.0";
our $VERSION = "1.1.0";

if (@ARGV == 1 && $ARGV[0] eq "--version")
{
Expand Down Expand Up @@ -74,13 +74,13 @@
die "could not load configuration $confname!\n"
if (!$config or !keys %$config);

my $dia = UI::Dialog->new('title' => "Service Graph Helper",
height => 20,
my $dia = UI::Dialog->new('title' => "Service Graph Helper",
height => 20,
width => 70,
listheight => 15, order => [ 'cdialog', 'ascii']); # whiptail/newt doesn't behave well

$dia->msgbox("text" => "This helper will guide you through the creation
of a simple custom graph for an custom NMIS service.
of a simple custom graph for an custom NMIS service.
Clicking Cancel at any stage will abort the helper.
Use the arrow keys and tab to navigate, space to select from lists.");
Expand All @@ -91,7 +91,7 @@
# only interested in this server's services!
%allsvc = %{$allsvc{$config->{server_name}}} if (ref($allsvc{$config->{server_name}}) eq "HASH");


my $servicesel = $dia->menu( text => "Please select the service you want to graph:",
list => [ map { ($_,'') } (sort keys %allsvc) ] );

Expand All @@ -107,11 +107,12 @@

if (!$thissvc->{status})
{
$dia->msgbox( text => "The service $servicesel seems to be down on node $nodesel.
$dia->msgbox( text => "The service $servicesel seems to be down on node $nodesel,
and no graph can be created until reliable service data is available.
Please pick a different node!");
exit 0;
}

# standard readings
my @readings = [service => 'service status'];
push @readings, [responsetime => "response time"] if (defined $thissvc->{responsetime});
Expand All @@ -124,29 +125,29 @@
push @readings, map { [ $_ => "custom" ] } (sort keys %{$thissvc->{extra}})
}

$dia->msgbox(text => "This service collects the following measurements, which
$dia->msgbox(text => "This service collects the following measurements, which
are available for graphing: ". join(", ", map { $_->[0] } (@readings)));
die "User cancelled operation.\n" if ($dia->state ne "OK");

my ($shortname, @whichds);
my ($shortname, @whichreadings);
while (1)
{
undef $shortname;
@whichds = $dia->checklist(text => "Please select one ore more measurements to include on your graph:",
@whichreadings = $dia->checklist(text => "Please select one or more measurements to include on your graph:",
list => [ map { $_->[0] => [ $_->[1], 0 ] } (@readings) ] );
die "User cancelled operation.\n" if ($dia->state ne "OK");
if (@whichds == 1)

if (@whichreadings == 1)
{
if ($whichds[0] =~ /^(service|responsetime)$/)
if ($whichreadings[0] =~ /^(service|responsetime)$/)
{
$dia->msgbox(text => "There is already a standard graph for \"$whichds[0]\". Please pick a different measurement.");
$dia->msgbox(text => "There is already a standard graph for \"$whichreadings[0]\". Please pick a different measurement.");
next;
}
$shortname = $whichds[0];
$shortname = $whichreadings[0];
last;
}
elsif (!@whichds)
elsif (!@whichreadings)
{
$dia->msgbox(text => "You have to pick at least one measurement.");
}
Expand All @@ -158,11 +159,11 @@

while (!$shortname)
{
$shortname = $dia->inputbox(text => "Please enter a name for your new graph.
$shortname = $dia->inputbox(text => "Please enter a name for your new graph.
The name should be short and must not contain any characters except a-z, 0-9, _, - or .",
entry => "");
die "User cancelled operation.\n" if ($dia->state ne "OK");

$shortname = lc($shortname);
$shortname =~ s/[^a-z0-9\._]//g;
}
Expand All @@ -178,61 +179,66 @@
NMIS-variables written as \"\$varname\" will be substituted.",
entry => escape($graph{title}->{standard}) );
die "User cancelled operation.\n" if ($dia->state ne "OK");
$graph{title}->{standard} = $newtitle if ($newtitle and $newtitle !~ /^\s*$/
$graph{title}->{standard} = $newtitle if ($newtitle and $newtitle !~ /^\s*$/
and $newtitle ne $graph{title}->{standard});

$newtitle = $dia->inputbox( text => "Please set the new graph title below. This is for small graphs.
NMIS-variables written as \"\$varname\" will be substituted.",
entry => escape($graph{title}->{short}) );
die "User cancelled operation.\n" if ($dia->state ne "OK");
$graph{title}->{short} = $newtitle if ($newtitle and $newtitle !~ /^\s*$/
$graph{title}->{short} = $newtitle if ($newtitle and $newtitle !~ /^\s*$/
and $newtitle ne $graph{title}->{short});


my $vlabel = $dia->inputbox ( text => "Please enter the new vertical axis label, or leave it empty for none. This is for full-sized graphs.",
entry => $graph{vlabel}->{standard});
die "User cancelled operation.\n" if ($dia->state ne "OK");
$graph{vlabel}->{standard} = $vlabel if ($vlabel and $vlabel !~ /^\s*$/
$graph{vlabel}->{standard} = $vlabel if ($vlabel and $vlabel !~ /^\s*$/
and $vlabel ne $graph{vlabel}->{standard});

$vlabel = $dia->inputbox ( text => "Please enter the new vertical axis label, or leave it empty for none. This is for small graphs.",
entry => $graph{vlabel}->{small});
die "User cancelled operation.\n" if ($dia->state ne "OK");
$graph{vlabel}->{small} = $vlabel if ($vlabel and $vlabel !~ /^\s*$/
$graph{vlabel}->{small} = $vlabel if ($vlabel and $vlabel !~ /^\s*$/
and $vlabel ne $graph{vlabel}->{small});


# for each choice: ask for line colour (menu of 16 named ones), label, include as gprint too and format (if so)
for my $idx (0..$#whichds)
for my $idx (0..$#whichreadings)
{
my $ds = $whichds[$idx];
my $reading = $whichreadings[$idx];

my @choices;
while (!@choices)
{
@choices = $dia->checklist(text => "Please select how measurement \"$ds\" should be graphed:",
@choices = $dia->checklist(text => "Please select how measurement \"$reading\" should be graphed:",
list => [ "line" => [ "as a line", 1 ],
"avg" => [ "show average with legend", 1 ],
"min" => [ "show min with legend (large graph only)", 0 ],
"max" => [ "show max with legend (large graph only)", 0 ] ]);
die "User cancelled operation.\n" if ($dia->state ne "OK");
}

my $label = $dia->inputbox( text => "Please enter the new label for measurement \"$ds\":",
entry => $ds);
my $label = $dia->inputbox( text => "Please enter the new label for measurement \"$reading\":",
entry => $reading);
$label =~ s/:/\\:/g; # required for rrdtool
die "User cancelled operation.\n" if ($dia->state ne "OK");


# figure out the actual rrd ds, which should be part of the service definition
my $ds = ref($thissvc->{ds}) eq "HASH" && defined($thissvc->{ds}->{$reading})? $thissvc->{ds}->{$reading} : $reading;
$ds =~ s/[^a-zA-Z0-9_]/_/g; # bsts

push @{$graph{option}->{standard}}, "DEF:$ds=\$database:$ds:AVERAGE";
push @{$graph{option}->{small}}, "DEF:$ds=\$database:$ds:AVERAGE";


if (grep($_ eq "line", @choices))
{
my $color;

while (!$color)
{
$color = $dia->radiolist(text => "Please select a line color for \"$ds\":",
$color = $dia->radiolist(text => "Please select a line color for \"$reading\":",
list => [ "C0C0C0" => [ "Silver" , 0 ],
"808080" => [ "Gray", 0 ],
"000000" => ["Black", 0],
Expand Down Expand Up @@ -266,7 +272,7 @@
for my $thisprint (@choices)
{
next if ($thisprint eq "line"); # already done

my %rrdtype = ( "avg" => "AVERAGE", "min" => "MIN", "max" => "MAX" );
my %labeltype = ( "avg" => "Avg", "min" => "Min", "max" => "Max" );
my %formats = ( "percent" => '%9.3lf%%',
Expand All @@ -279,7 +285,7 @@
$labeltype{$thisprint} = "$label $labeltype{$thisprint}" if (!grep($_ eq "line", @choices));
$labeldone = 1;
}

if (!$formatchoice)
{
while (!$formatchoice)
Expand Down Expand Up @@ -315,7 +321,7 @@
{
my $backupname = "$savefilename.backup";
unlink($backupname);

my $isok = rename($savefilename, $backupname);
die "Cannot rename $savefilename to $backupname: $!\n" if (!$isok);

Expand Down
Loading

0 comments on commit 5a3711a

Please sign in to comment.