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.2G
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zangerl committed Nov 16, 2017
1 parent f4b2b76 commit 02eb6d5
Show file tree
Hide file tree
Showing 155 changed files with 14,643 additions and 28,748 deletions.
15 changes: 15 additions & 0 deletions admin/archive/install-cisco-models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

echo This script will NOT backup your existing NMIS installation, please backup your installation before proceeding.
echo press Enter to continue ctrl+C to stop.
read X

unalias cp

cp ./install/* /usr/local/nmis8/install
cp ./models-install/* /usr/local/nmis8/models
cp ./mibs/nmis_mibs.oid /usr/local/nmis8/mibs

/usr/local/nmis8/install/install_cisco_model_dev.pl

/usr/local/nmis8/admin/fixperms.pl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@
my $C = loadConfTable(conf=>$arg{conf},debug=>$arg{debug});

# Update the UUIDs for the nodes.
createNodeUUID();
NMIS::UUID::createNodeUUID();

print $t->elapTime(). " Begin\n";
4 changes: 2 additions & 2 deletions admin/export_nodes.pl
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
# Step 7: Check the results

if ( not -f $arg{nodes} ) {
createNodeUUID();
NMIS::UUID::createNodeUUID();
exportNodes($arg{nodes});
}
else {
Expand Down Expand Up @@ -169,4 +169,4 @@ sub changeCellSep {
$string =~ s/\r\n/\\n/g;
$string =~ s/\n/\\n/g;
return $string;
}
}
119 changes: 54 additions & 65 deletions admin/migrate_rrd_locations.pl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#
# nmis collection is disabled while this operation is performed, and a record
# of operations is kept for rolling back in case of problems.
our $VERSION = "8.6.1G";
our $VERSION = "8.6.2a";

use strict;
use File::Copy;
Expand All @@ -50,16 +50,14 @@
use NMIS;
use func 1.2.1;

my $usage = "Usage: ".basename($0)." newlayout=/path/to/new/Common-database.nmis [simulate=true] [info=true] [missingonly=true]\n
my $usage = "Usage: ".basename($0)." newlayout=/path/to/new/Common-database.nmis [simulate=true] [info=true]\n
newlayout: Common-database.nmis file to use for new locations, merged into current one.
simulate: only show what would be done, don't make any changes
info: produce more informational output
missingonly: no renaming, just add missing entries to Common-database.
\n\n";

my %args=getArguements(@ARGV);
my $simulate = getbool($args{simulate});
my $missingonly = getbool($args{missingonly});
my $leavelocked = getbool($args{leavelocked});

my $base = Cwd::abs_path("$FindBin::RealBin/..");
Expand Down Expand Up @@ -105,66 +103,15 @@
my $LNT = loadLocalNodeTable();
my (%rrdfiles,$countfiles);

# verify that the current common-database doesn't have anything custom that
# the new shipped version does not have

my $curlayoutfile = $C->{'<nmis_models>'}."/Common-database.nmis";
my $curlayout = readFiletoHash(file => $curlayoutfile);
if (ref($curlayout) ne "HASH" or ref($curlayout->{database}) ne "HASH")
{
print STDERR "Cannot fine a current database layout file (Common-database.nmis), cannot proceed with migration!\n";
print STDERR "Cannot find a current database layout file (Common-database.nmis), cannot proceed with migration!\n";
exit 1;
}

print STDERR "Checking compatibility of current and new database layout files...\n";
for my $oldtypekey (sort keys %{$curlayout->{database}->{type}})
{
if (!$newlayout->{database}->{type}->{$oldtypekey})
{
print STDERR "\n\nError: Your current database layout file contains custom entries!\n
There is an entry for the RRD type \"$oldtypekey\", which is not present
in the new database layout. This is likely caused by local custom models.
This script cannot perform any database migration until all custom types
are merged into $newdbf, and will abort now.\n\n";
exit 1;
}
}

if ($missingonly)
{
print STDERR "Checking for missing entries in current database layout\n";
my $needtosave;

for my $newtype (keys %{$newlayout->{database}->{type}})
{
next if exists $curlayout->{database}->{type}->{$newtype};
print STDERR "Adding $newtype\n";
if (!$simulate)
{
$curlayout->{database}->{type}->{$newtype} =
$newlayout->{database}->{type}->{$newtype};
$needtosave = 1;
}
}
if ($needtosave)
{
push @rollback, "mv $curlayoutfile.pre-update $curlayoutfile";
rename($curlayoutfile,"$curlayoutfile.pre-update")
or die "Could not rename $curlayoutfile: $!\n";
writeHashtoFile(file => $curlayoutfile, data => $curlayout);

# save the rollback file anyway
&saverollback;
print STDERR "Saving rollback information in $rollbackf\n";
print STDERR "Update complete.\n";
}
else
{
print STDERR "No missing entries found.\n";
}
unlink($lockoutfile) if (!$leavelocked);
exit 0;
}

print STDERR "Identifying RRD files to rename\n";
# find all rrd files for all nodes with sys() objects based on
# the current config, and remember the locations, the types, index, element - everything :-/
Expand All @@ -174,14 +121,14 @@
# cache disabled so that the func table_cache gets populated
$S->init(name=>$node, snmp=>'false', cache_models => 'false');
my $NI = $S->ndinfo;

# walk graphtype keys, if hash value: key is index, go one level deeper;
# otherwise key of graphtype is all getDBName needs
for my $section (keys %{$NI->{graphtype}})
{
# the generic ones remain where they were - in /metrics/.
next if ($section =~ /^(network|nmis|metrics)$/);

if (ref($NI->{graphtype}->{$section}) eq "HASH")
{
my $index = $section;
Expand Down Expand Up @@ -223,7 +170,14 @@
or ref($cacheobj->{$cachekey}->{data}->{database}) ne "HASH"
or ref($cacheobj->{$cachekey}->{data}->{database}->{type}) ne "HASH");

$cacheobj->{$cachekey}->{data}->{database}->{type} = $newlayout->{database}->{type};
# merge the old and new stuff, new wins but orphaned old is NOT deleted!
for my $newentry (keys %{$newlayout->{database}->{type}})
{
$cacheobj->{$cachekey}->{data}->{database}->{type}->{$newentry}
= $newlayout->{database}->{type}->{$newentry};
}

my $gotchas;

# oldfile -> newfile
my %todos;
Expand All @@ -234,24 +188,43 @@
# again, disabling the model cache use so that the massaged table_cache remains in force
my $S = Sys->new;
$S->init(name=>$node, snmp=>'false', cache_models => 'false');

for my $oldname (keys %{$rrdfiles{$node}})
{
my $meta = $rrdfiles{$node}->{$oldname};

my $newname = $S->getDBName(graphtype => $meta->{graphtype},
index => $meta->{index},
item => $meta->{item});
if (!$newname)
{
if ($simulate)
{
warn("FATAL: Cannot determine new name for $oldname (graphtype=".$meta->{graphtype}
.", index=".$meta->{index}.", item=".$meta->{item}.")\n");
$newname = "fatal_conflict_".++$gotchas; # fudgery to make output possible under simulate
next;
}
die "Cannot determine new name for $oldname (graphtype=".$meta->{graphtype}
.", index=".$meta->{index}.", item=".$meta->{item}.")\n";
.", index=".$meta->{index}.", item=".$meta->{item}.")\n";
}
if ($oldname ne $newname)
{
my $friendlyold = $oldname; $friendlyold =~ s/^$C->{database_root}//;
my $friendlynew = $newname; $friendlynew =~ s/^$C->{database_root}//;


# make sure there's no clashes
if (my @conflicts = grep($todos{$_} eq $newname, keys %todos))
{
if ($simulate)
{
warn("FATAL: cannot rename $oldname to $newname, clashes with renaming $conflicts[0]\n");
$todos{$oldname} = "fatal_conflict_".++$gotchas;
next;
}
die("FATAL: cannot rename $oldname to $newname, clashes with renaming $conflicts[0]\n");
}

info("Old RRD file $friendlyold, new $friendlynew");
$todos{$oldname} = $newname;
}
Expand All @@ -264,6 +237,7 @@

my %olddirs;
print STDERR "Found ".int(scalar(keys %todos)). " RRD files to move.\n";
print STDERR "$gotchas conflicts that must be resolved before migration!\n" if ($gotchas);

if (keys %todos and !$simulate)
{
Expand Down Expand Up @@ -332,7 +306,11 @@
push @rollback, "mv $curlayoutfile.pre-migrate $curlayoutfile";
rename($curlayoutfile,"$curlayoutfile.pre-migrate") or die "Could not rename $curlayoutfile: $!\n";

$curlayout->{database}->{type} = $newlayout->{database}->{type};
# merge the old and new stuff, new wins but orphaned old is NOT deleted!
for my $newentry (keys %{$newlayout->{database}->{type}})
{
$curlayout->{database}->{type}->{$newentry} = $newlayout->{database}->{type}->{$newentry};
}
writeHashtoFile(file => $curlayoutfile, data => $curlayout);

# save the rollback file anyway
Expand All @@ -353,6 +331,7 @@
}
exit 0;

# record relationship of node -> rrdfile
sub record_rrd
{
my (%args) = @_;
Expand All @@ -377,6 +356,16 @@ sub record_rrd
if (exists $rrdfiles{$args{node}}->{$fn})
{
my $old = $rrdfiles{$args{node}}->{$fn};

if ($simulate)
{
warn("FATAL: $fn already known!\n
clash between old node=$old->{node}, graphtype=$old->{graphtype}, index=$old->{index}, item=$old->{item}
and new node=$args{node}, graphtype=$args{graphtype}, index=$args{index}, item=$args{item}\n");
$rrdfiles{ $args{node}."_fatal_conflict_".++$gotchas } = {%args};
return;
}

die "error: $fn already known!\n
clash between old node=$old->{node}, graphtype=$old->{graphtype}, index=$old->{index}, item=$old->{item}
and new node=$args{node}, graphtype=$args{graphtype}, index=$args{index}, item=$args{item}\n";
Expand Down
8 changes: 4 additions & 4 deletions admin/model_audit.pl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

my $LNT = loadLocalNodeTable();

print qq|"name","host","group","version","active","collect","last updated","icmp working","wmi working","snmp working","nodeModel","nodeVendor","nodeType","roleType","netType","sysObjectID","sysObjectName","sysDescr","intCount","intCollect"\n|;
print qq|"name","host","group","version","active","collect","last updated","icmp working","wmi working","snmp working","nodeModel","nodeVendor","nodeType","roleType","netType","sysObjectID","sysName","sysObjectName","sysDescr","intCount","intCollect"\n|;

foreach my $node (sort keys %{$LNT}) {

Expand All @@ -73,15 +73,15 @@
my $sysDescr = $NI->{system}{sysDescr};
$sysDescr =~ s/[\x0A\x0D]/\\n/g;

my $lastUpdate = returnDateStamp($NI->{system}{lastUpdateSec});
my $lastUpdate = returnDateStamp($NI->{system}{last_poll});

my $pingable = getbool($LNT->{$node}->{ping})? getbool($NI->{system}{nodedown})? "false": "true" : "N/A";
my $snmpable = defined($NI->{system}->{snmpdown})? getbool($NI->{system}->{snmpdown})? "false" : "true" : "N/A";
my $wmiworks = defined($NI->{system}->{wmidown})? getbool($NI->{system}->{wmidown})? "false" : "true" : "N/A";

$lastUpdate = "unknown" if not defined $NI->{system}{lastUpdateSec};
$lastUpdate = "unknown" if not defined $NI->{system}{last_poll};
$pingable = "unknown" if not defined $NI->{system}{nodedown};
$snmpable = "unknown" if not defined $NI->{system}{snmpdown};

print qq|"$LNT->{$node}{name}","$LNT->{$node}{host}","$LNT->{$node}{group}","$LNT->{$node}{version}","$LNT->{$node}{active}","$LNT->{$node}{collect}","$lastUpdate","$pingable","$wmiworks","$snmpable","$NI->{system}{nodeModel}","$NI->{system}{nodeVendor}","$NI->{system}{nodeType}","$LNT->{$node}{roleType}","$LNT->{$node}{netType}","$NI->{system}{sysObjectID}","$NI->{system}{sysObjectName}","$sysDescr","$intCount","$intCollect"\n|;
print qq|"$LNT->{$node}{name}","$LNT->{$node}{host}","$LNT->{$node}{group}","$LNT->{$node}{version}","$LNT->{$node}{active}","$LNT->{$node}{collect}","$lastUpdate","$pingable","$wmiworks","$snmpable","$NI->{system}{nodeModel}","$NI->{system}{nodeVendor}","$NI->{system}{nodeType}","$LNT->{$node}{roleType}","$LNT->{$node}{netType}","$NI->{system}{sysObjectID}","$NI->{system}{sysName}","$NI->{system}{sysObjectName}","$sysDescr","$intCount","$intCollect"\n|;
}
55 changes: 0 additions & 55 deletions admin/model_format.pl

This file was deleted.

4 changes: 2 additions & 2 deletions admin/nmis_run_node.pl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

my $recentUpdate = 0;
# has an update been run in the last 24 hours?
if ( $NI->{system}{lastUpdatePoll} > time() - $update ) {
if ( $NI->{system}{last_update} > time() - $update ) {
$recentUpdate = 1;
}

Expand All @@ -106,7 +106,7 @@
print "SKIP No Match: $NI->{system}{name}: $arg{field}=$NI->{system}{$arg{field}}\n";
}
if ( not $runIt and $recentUpdate ) {
print "SKIP Update: $NI->{system}{name}: lastUpdatePoll=$NI->{system}{lastUpdatePoll}\n";
print "SKIP Update: $NI->{system}{name}: lastUpdatePoll=$NI->{system}{last_update}\n";
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion admin/node_admin.pl
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
# no uuid? then we add one
if (!$mayberec->{uuid})
{
$mayberec->{uuid} = getUUID($node);
$mayberec->{uuid} = NMIS::UUID::getUUID($node);
}

# ok, looks good enough. save the node info.
Expand Down
2 changes: 1 addition & 1 deletion admin/nodes_auto_admin.pl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ sub processNodes {
}


if ( $NI->{system}{nodedown} eq "true" and $NI->{system}{lastUpdateSec} eq "" ) {
if ( $NI->{system}{nodedown} eq "true" and $NI->{system}{last_poll} eq "" ) {
# run an update.
#print "$node has never been polled\n";
push(@badNodes,"$node,$LNT->{$node}{host}");
Expand Down
Loading

0 comments on commit 02eb6d5

Please sign in to comment.