NAME
App::Netsync - network/database synchronization library
DESCRIPTION
This package can discover a network and synchronize it with a database.
SYNOPSIS
use App::Netsync;
App::Netsync::configure({
'Table' => 'assets',
'DeviceField' => 'SERIAL_NUMBER',
'InterfaceField' => 'PORT',
'InfoFields' => ['BLDG','ROOM','JACK'],
},{
'domain' => 'example.com',
},{
'Version' => 2,
'Community' => 'example',
},{
'DBMS' => 'pg',
'Server' => 'pg.example.com',
'Port' => 5432,
'Database' => 'example_db',
'Username' => 'user',
'Password' => 'pass',
});
my $nodes = App::Netsync::discover ('DNS','host[0-9]+');
App::Netsync::identify ($nodes,'DB',1);
App::Netsync::update ($nodes);
METHODS
configure
configure the operating environment
Arguments
( \%Netsync [, \%DNS [, \%SNMP [, \%DB ] ] ] )
- Netsync
-
key-value pairs of Netsync environment settings
Available Environment Settings
Note: If a default is not specified, the setting is required.
- ConflictLog
-
where to log conflicts
default: /var/log/<script name>/conflicts.log
- DeviceField
-
the table field to use as a unique ID for devices
- DeviceOrder
-
the width of fields specifying node and device counts
default: 4
Example
- DeviceOrder = 3 (i.e. nodes < 1000), 500 nodes
-
> discovering (using DNS)... 500 nodes (50 skipped), 600 devices (50 stacks)
- DeviceOrder = 9 (i.e. nodes < 1000000000), 500 nodes
-
> discovering (using DNS)... 500 nodes (50 skipped), 600 devices (50 stacks)
- DeviceOrder = 1 (i.e. nodes < 10), 20 nodes !
-
> discovering (using DNS)... 111111111120 nodes (2 skipped), 24 devices (2 stacks)
- Indent
-
the number of spaces to use when output is indented
default: 4
- InfoFields
-
which table fields to synchronize with device interfaces
- InterfaceField
-
which table field to use as a unique ID for device interfaces
- NodeLog
-
where to log all probed nodes
default: /var/log/<script name>/nodes.log
- Quiet
-
Print nothing.
default: 0
- SyncOID
-
which OID to send synchronized information to when updating
default: ifAlias
- Table
-
which database table to use
- UpdateLog
-
where to log all modifications made to the network
default: /var/log/<script name>/updates.log
- Verbose
-
Print everything.
Note: Quiet mode overrides Verbose mode.
default: 0
Netsync requires the following settings to use a DBMS:
- DBMS
-
the database platform to use
- Server
-
the server containing the database to use
- Port
-
the port to contact the database server on
- Database
-
the database to connect to
- Username
-
the user to connect to the database as
- Password
-
the authentication key to use to connect to the database
Netsync requires the following settings to use SNMP:
- MIBdir
-
the location of MIBs required by Netsync
default: /usr/share/<script name>/mib
- DNS
-
See Net::DNS documentation for more acceptable settings.
- SNMP
-
See SNMP::Session documentation for more acceptable settings.
- DB
-
See DBI documentation for more acceptable settings.
device_interfaces
discover all the devices and corresponding interfaces of a potentially stacked node
Arguments
( $vendor , $session )
- vendor
-
a value returned from SNMP::Info::vendor
Supported Vendors
- session
-
an SNMP::Session object
Example
device_interfaces ($node->{'info'}->vendor,$node->{'session'});
{
'1A2B3C4D5E6F' => {
'1001' => 'ethernet1/1/1',
'1002' => 'ethernet1/1/2',
...
},
'2B3C4D5E6F7G' => {
'2001' => 'ethernet2/1/1',
'2002' => 'ethernet2/1/2',
...
},
...
}
discover
search the network for active nodes
Arguments
[ ( $node_source [, $host_pattern ] ) ]
- node_source
-
where to get nodes from (DNS, STDIN, or a filename)
default: DNS
- host_pattern
-
a regular expression to match hostnames from the list of retrieved nodes
default: [^.]+
identify
identify discovered nodes in a database
Arguments
( \%nodes [, $data_source [, $auto_match ] ] )
- nodes
-
the discovered nodes to identify
- data_source
-
the location of the database (DB or a filename)
default: DB
- auto_match
-
whether to enable interface automatching
default: 0
update
push information to interfaces
Arguments
( \%nodes )
- nodes
-
the nodes to update
Example
update $nodes;
Table
---------------------------------------------------------
| DeviceField | InterfaceField | InfoFields... |
--------------------------------------------------------- =============
| (serial) | (ifName) |(interface-specific)| --> || SyncOID ||
| ... | =============
--------------------------------------------------------- (device)
AUTHOR
David Tucker, <dmtucker at ucsc.edu>
BUGS
Please report any bugs or feature requests to bug-netsync at rt.cpan.org
, or through the web interface at 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.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::Netsync
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
LICENSE
Copyright 2013 David Tucker.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.