App-Netsync

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "network/database synchronization library",
   "author" : [
      "dmtucker@ucsc.edu"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'network/database synchronization library'
author:
  - dmtucker@ucsc.edu
build_requires:
  Test::CheckManifest: '0.9'
  Test::Kwalitee: '0'
  Test::More: '0'
  Test::Pod: '1.22'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1

README.pod  view on Meta::CPAN

=head1 NAME

App::Netsync - network/database synchronization utility/library

=begin HTML

<a href="https://travis-ci.org/dmtucker/netsync"><img src="https://img.shields.io/travis/dmtucker/netsync.svg" alt="Build Status"></a>&nbsp;<a href="https://metacpan.org/pod/App::Netsync"><img src="https://img.shields.io/cpan/v/App-Netsync.svg" alt="...

=end HTML

=head1 DESCRIPTION

netsync is a network synchronization tool that:

 - maps network interfaces to their respective (potentially stacked) devices
 - gathers interface-specific information from an asset management database
 - sends the information it gathers to each device
 - provides ways of producing useful information about the network

I<Note: All communication with network nodes is done using SNMP.>

B<Overview>

README.pod  view on Meta::CPAN

It caches discovered nodes in Probe1Cache.
This cache is created in RFC1035-complaint format.
It may subsequently be passed as the Nodes parameter to skip inactive nodes.

 $ netsync -Dm "sw[^.]+|hub[0-9]+" -p1
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using DBMS)...  480 nodes (10 skipped), 500 devices
 $ netsync /var/cache/netsync/active.txt
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using /var/cache/netsync/active.txt)...  480 nodes, 500 devices
 > identifying (using DBMS)...  498 synchronized (4 conflicts)

I<Note: Since the goal of Probe Level 1 is to save time later,
        unrecognized nodes will not be included in Probe1Cache.>

=head2 7 Identification

Once netsync has a view of the network's hardware,
it requires a database to find information specific to each interface.

I<Note: Since netsync treats the database as read-only,

README.pod  view on Meta::CPAN

This must be preconfigured in the configuration file and on the DBMS.

=item Database (-d)

An RFC4180-compliant database file may be specified.

=back

netsync identifies the network interface referenced in each database entry.
A valid entry must not have missing DeviceField or InterfaceField information.
Valid rows are synchronized with the network while invalid rows are skipped.
Entries with unknown (not found) devices are skipped.
Entries are then checked for conflicts.

B<About RFC4180>

RFC4180 specifies a simple format (CSV) for database files.
This format is widely supported making it useful for importing and exporting.
Thus, for compatibility, this application is RFC4180-compliant.

 DeviceField,InterfaceField,InfoField

README.pod  view on Meta::CPAN


=back

=head2 9 Probe Level 2

Probe level 2 is specified using -p2 and updates Probe1Cache and Probe2Cache.

During Probe Level 2, only the discovery and identification stages are executed.
It caches identified nodes in Probe2Cache.
This cache is created in RFC4180-complaint format.
It may be passed as Nodes in subsequent runs to skip synchronization.

 $ netsync -Dm "host[0-9]+" -a -p2
 > configuring (using /etc/netsync/netsync.ini)... done
 > discovering (using DNS)...  480 nodes (10 skipped), 500 devices
 > identifying (using DBMS)...  498 synchronized (4 conflicts)
 > Do you want to resolve conflicts now? [y/n] n
 $ netsync -d /var/cache/netsync/synced.csv /var/cache/netsync/active.txt
 > configuring (using /etc/netsync/netsync.ini)... done
 > discovering (using /var/cache/netsync/active.txt)...  480 nodes, 500 devices
 > identifying (using /var/cache/netsync/synced.csv)...  500 synchronized

I<Note: All unidentified hardware will be present in Probe2Cache.
        This is so the output of Probe Level 2 can serve as a network snapshot.>

=head2 10 Updating

All modifications made to any device are logged in UpdateLog.

If probing is not used and the Update (-u) option is specified,
netsync attempts to actualize its internally synchronized network using SNMP.
It pushes gathered interface-specific information to the devices on the network.
This information is stored in the device at the specified SyncOID,
and is overwritten anytime netsync updates it.

 $ netsync -Dau

=head1 EXAMPLES

 $ netsync -Dm "sw[^.]+|hub[0-9]+" -au
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using DNS)...  780 nodes (50 skipped), 800 devices (10 stacks)
 > identifying (using DBMS)...  670 synchronized (4 conflicts)
 > updating... 670 successful

Z<>

 $ dig axfr domain.tld | egrep ^(sw[^.]+|hub[0-9]+) | netsync -a
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using STDIN)...  780 nodes (50 skipped), 800 devices
 > identifying (using DBMS)...  670 synchronized (4 conflicts)

Z<>

 $ netsync -Dm "sw[^.]+|hub[0-9]+" -p1
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using DBMS)...  780 nodes (50 inactive), 800 devices
 $ netsync /var/cache/netsync/active.txt
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using /var/cache/netsync/active.txt)...  780 nodes, 800 devices
 > identifying (using DBMS)...  670 synchronized (4 conflicts)

Z<>

 $ netsync -Dm "sw[^.]+|hub[0-9]+" -a -p2
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using DNS)...  780 nodes (50 skipped), 800 devices
 > identifying (using DBMS)...  670 synchronized (4 conflicts)
 $ netsync -d /var/cache/netsync/synced.csv /var/cache/netsync/active.txt
 > configuring (using /etc/netsync/netsync.ini)...
 > discovering (using /var/cache/netsync/active.txt)...  780 nodes, 800 devices
 > identifying (using /var/cache/netsync/synced.csv)...  800 synchronized

=head1 AUTHOR

David Tucker, C<< <dmtucker at ucsc.edu> >>

=head1 BUGS

Please report any bugs or feature requests to C<bug-netsync at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Netsync>.  I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.

etc/netsync.ini  view on Meta::CPAN

Table = 

# DeviceField specifies which table field to use as a unique ID for devices.
# default: <none>
DeviceField = 

# InterfaceField specifies which table field to use as a unique ID for device interfaces.
# default: <none>
InterfaceField = 

# InfoFields specifies which table fields to synchronize with device interfaces.
# default: <none>
InfoFields = 

## Advanced Settings

# SyncOID specifies which OID to send synchronized information to when updating.
# default: ifAlias
SyncOID = ifAlias

# MIBdir specifies the location of MIBs required by Netsync.
# default: /usr/share/netsync/mib
MIBdir = share/mib

# DeviceOrder specifies the width of fields specifying node and device counts.
# (e.g. 2 allows up to 99 devices, 4 up to 9999 devices, etc.)
# default: 4

lib/App/Netsync.pm  view on Meta::CPAN

package App::Netsync;

=head1 NAME

App::Netsync - network/database synchronization library

=head1 DESCRIPTION

This package can discover a network and synchronize it with a database.

=head1 SYNOPSIS

 use App::Netsync;

 App::Netsync::configure({
     'Table'          => 'assets',
     'DeviceField'    => 'SERIAL_NUMBER',
     'InterfaceField' => 'PORT',
     'InfoFields'     => ['BLDG','ROOM','JACK'],

lib/App/Netsync.pm  view on Meta::CPAN

=back

=item Indent

the number of spaces to use when output is indented

default: 4

=item InfoFields

which table fields to synchronize with device interfaces

=item InterfaceField

which table field to use as a unique ID for device interfaces

=item NodeLog

where to log all probed nodes

default: F</var/log/E<lt>script nameE<gt>/nodes.log>

=item Quiet

Print nothing.

default: 0

=item SyncOID

which OID to send synchronized information to when updating

default: ifAlias

=item Table

which database table to use

=item UpdateLog

where to log all modifications made to the network

lib/App/Netsync.pm  view on Meta::CPAN

}




################################################################################




sub synchronize { # Use information in the databse to update discovered nodes.
    warn 'too few arguments'  if @_ < 4;
    warn 'too many arguments' if @_ > 4;
    my ($nodes,$identified,$auto_match,$rows) = @_;

    my $conflict_count = 0;
    foreach my $row (@$rows) {
        my $serial = uc $row->{$config{'DeviceField'}};
        my $ifName = $row->{$config{'InterfaceField'}};

        # Identify the device indicated by the given database entry.

lib/App/Netsync.pm  view on Meta::CPAN

        ROW : foreach my $row (@data) {
            my $valid = [
                $config{'DeviceField'},
                $config{'InterfaceField'},
            ];
            foreach my $field (@$valid) { # Verify necessary fields aren't empty.
                next ROW unless defined $row->{$field} and $row->{$field} =~ /\S+/; # Otherwise, skip to the next entry.
            }

            # Synchronize the entry with gathered info.
            $conflict_count += synchronize ($nodes,\%identified,$auto_match,[$row]);

            # Show the user how many nodes have been identified if necessary.
            unless ($config{'Quiet'} or $config{'Verbose'}) {
                print  "\b"x$config{'DeviceOrder'};
                printf ('%'.$config{'DeviceOrder'}.'d',scalar keys %identified);
            }
        }

        # Show the user what's been found if necessary.
        unless ($config{'Quiet'}) {
            print scalar keys %identified if $config{'Verbose'};
            print ' synchronized';
            print ' ('.$conflict_count.' conflicts)' if $conflict_count > 0;
            print "\n";
        }
    }

    # Search for network devices and interfaces that were not identified in the database.
    foreach my $ip (sort keys %$nodes) {
        my $node = $nodes->{$ip};
        foreach my $serial (sort keys %{$node->{'devices'}}) {
            my $device = $node->{'devices'}{$serial};

script/netsync  view on Meta::CPAN

#!perl

=head1 NAME

netsync - network/database synchronization utility

=head1 DESCRIPTION

This tool can discover a network and synchronize it with a database.

=head1 SYNOPSIS

 -h --help   Help. Print usage and options.
 -V          Version. Print build information.
 -v          Verbose. Print everything.
 -q          Quiet. Print nothing.
 -c .ini     Config. Specify a configuration file.
 -p #        Probe. There are 2 Probe levels:
               1: Probe the network for active nodes.

script/netsync  view on Meta::CPAN


Z<>

 $ netsync -Dm "host[0-9]+" -p1
 > configuring (using /etc/netsync/netsync.ini)... done
 > discovering (using DNS)...  778 nodes (47 skipped), 796 devices (12 stacks)

 $ netsync -ap2 /var/cache/netsync/active.txt
 > configuring (using /etc/netsync/netsync.ini)... done
 > discovering (using /var/cache/netsync/active.txt)...  778 nodes, 796 devices (12 stacks)
 > identifying (using DBMS)...  664 synchronized (2389 conflicts)

 $ netsync -d /var/cache/netsync/synced.csv -a /var/cache/netsync/active.txt
 configuring (using /etc/netsync/netsync.ini)... done
 discovering (using /var/cache/netsync/active.txt)...  778 nodes, 796 devices (12 stacks)
 identifying (using /var/cache/netsync/synced.csv)...  796 synchronized

=cut


use autodie; #XXX Is autodie adequate?
#use diagnostics;
use strict;
use warnings;
use feature 'say';

share/mib/CISCO-STACK-MIB.my  view on Meta::CPAN

        MAX-ACCESS    read-only
        STATUS        current
        DESCRIPTION   "Specifies additional link fault status on a
                      gigabit link.

                      noFault:
                              Link is up and operational.
                      nearEndFault:
                              The port is enabled but there is no GBIC
                              present or the local port cannot
                              synchronize with the remote end.
                      nearEndConfigFail:
                              The local port has detected a
                              configuration mismatch with the remote
                              end.
                      farEndDisable:
                              The far end is in the disabled state.
                      farEndFault:
                              The remote port is cannot synchronize.
                      farEndConfigFail:
                              The remote port has detected a
                              configuration mismatch with the local end.
                      notApplicable:
                              Link fault status is not applicable on
                              this port."
        ::= { portEntry 22 }

portAdditionalOperStatus OBJECT-TYPE
        SYNTAX        BITS {

share/mib/FOUNDRY-SN-AGENT-MIB.mib  view on Meta::CPAN

	::= { snAgentRedunGbl 1 }

snAgentRedunSyncConfig         OBJECT-TYPE
	SYNTAX   Integer32
	MAX-ACCESS	read-write
	STATUS	current
	DESCRIPTION
		"Frequency of the backup management module copying the
		configuration data from the active management module.
		Each unit is 1 second. Setting a value 0 will disable
		the synchronization copy. Setting a negative value will
		initiate the synchronization copy once immediately."
	::= { snAgentRedunGbl 2 }

snAgentRedunBkupCopyBootCode   OBJECT-TYPE
	SYNTAX	INTEGER { disabled(0), enabled(1) }
	MAX-ACCESS	read-write
	STATUS	current
	DESCRIPTION
		"If enabled(1), the backup management module copies the boot code
		from the active management module to its boot code flash storage
		after power up, and whenever the active management module's boot

share/mib/FOUNDRY-SN-SWITCH-GROUP-MIB.mib  view on Meta::CPAN

		octet   3: day of the month [1-31]
		octet   4: months since January [0-11]
		octet   5: years since 1900
		octet   6: days since Sunday [0-6]
		Setting this object requires valid value in octets 0 to 5,
		and zero in octet 6. System clock can be disabled by setting
		zero to all octets."
	::= { snNTPGeneral 4 }

snNTPSync                  OBJECT-TYPE
	SYNTAX  INTEGER { other(1), synchronize(2) }
	MAX-ACCESS  read-write
	STATUS  current
	DESCRIPTION
		"Initiate time synchronization to the NTP servers.
		For set operation, only 'synchronize(2)' is accepted.
		For get operation, always return 'other(1)'.
		This object is not supported in NI devices from R5.3"
	::= { snNTPGeneral 5 }

-- NTP server table
-- snNTPServerTable is deprecated, replaced by fdrySntpServerTable.
-- The new table "fdrySntpServerTable" combines Ipv4 and Ipv6 Simple Network Time Protocol server configuration.

snNTPServerTable           OBJECT-TYPE
	SYNTAX  SEQUENCE OF SnNTPServerEntry

share/mib/P-BRIDGE-MIB.txt  view on Meta::CPAN

        transparent bridge that are on high-capacity interfaces, as
        defined in the conformance clauses for this table.  This table
        is provided as a way to read 64-bit counters for agents that
        support only SNMPv1.

        Note that the reporting of most-significant and
        least-significant counter bits separately runs the risk of
        missing an overflow of the lower bits in the interval between
        sampling.  The manager must be aware of this possibility, even
        within the same varbindlist, when interpreting the results of
        a request or asynchronous notification."
    ::= { dot1dTp 6 }

dot1dTpPortOverflowEntry OBJECT-TYPE
    SYNTAX      Dot1dTpPortOverflowEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "The most significant bits of statistics counters for a high-
        capacity interface of a transparent bridge.  Each object is
        associated with a corresponding object in dot1dTpPortTable

share/mib/Q-BRIDGE-MIB.txt  view on Meta::CPAN

        high-capacity interfaces, as defined in the conformance clauses
        for these objects.  This mechanism is provided as a way to read
        64-bit counters for agents that support only SNMPv1.

        Note that the reporting of most-significant and least-
        significant counter bits separately runs the risk of missing
        an overflow of the lower bits in the interval between sampling.
        The manager must be aware of this possibility, even within the
        same varbindlist, when interpreting the results of a request or

        asynchronous notification."
    ::= { dot1qVlan 6 }

dot1qPortVlanStatisticsEntry OBJECT-TYPE
    SYNTAX      Dot1qPortVlanStatisticsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "Traffic statistics for a VLAN on an interface."
    INDEX   { dot1dBasePort, dot1qVlanIndex }
    ::= { dot1qPortVlanStatisticsTable 1 }



( run in 0.398 second using v1.01-cache-2.11-cpan-0d8aa00de5b )