5 |
rodolico |
1 |
#! /usr/bin/env perl
|
|
|
2 |
|
|
|
3 |
# just a simple script for people more familiar with
|
|
|
4 |
# perl syntax than YAML. Modify %config below, then run
|
|
|
5 |
# this script. It will create the configuration file for
|
|
|
6 |
# you.
|
|
|
7 |
use strict;
|
|
|
8 |
use warnings;
|
|
|
9 |
|
|
|
10 |
use YAML::Tiny; # apt-get libyaml-tiny-perl under debian
|
|
|
11 |
use File::Spec; # find location of script so we can put storage in same directory
|
|
|
12 |
use File::Basename;
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
my %config = (
|
|
|
16 |
# one or more switches and their corresponding
|
|
|
17 |
# community name. Use v1 snmp only
|
|
|
18 |
'switches' => {
|
66 |
rodolico |
19 |
'DNS or IP' => { # enter a DNS name or an IP address to be scanned.
|
5 |
rodolico |
20 |
'community' => 'snmp community name',
|
66 |
rodolico |
21 |
# the following list can be used to ignore ports on this switch. Note that these are the port numbers
|
|
|
22 |
# returned by OID iso.3.6.1.2.1.2.2.1.8
|
5 |
rodolico |
23 |
'portsToIgnore' => [port,numbers,to,ignore]
|
|
|
24 |
},
|
|
|
25 |
'DNS or IP' => {
|
|
|
26 |
'community' => 'snmp community name',
|
|
|
27 |
'portsToIgnore' => [port,numbers,to,ignore]
|
|
|
28 |
}
|
|
|
29 |
},
|
|
|
30 |
# You must include at least one router.
|
|
|
31 |
# this will be queried to resolve IP's to MAC
|
|
|
32 |
# using its arp table
|
|
|
33 |
# put IP and community name into the hash
|
|
|
34 |
'routers' => {
|
|
|
35 |
'DNS or IP' => {
|
|
|
36 |
'community' => 'snmp community name',
|
|
|
37 |
},
|
|
|
38 |
'DNS or IP' => {
|
|
|
39 |
'community' => 'snmp community name',
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
);
|
|
|
43 |
|
|
|
44 |
my $scriptDir = dirname( File::Spec->rel2abs( __FILE__ ) );
|
|
|
45 |
my $CONFIGFILE = $scriptDir . '/mapSwitches.config.yaml';
|
|
|
46 |
|
|
|
47 |
my $yaml = YAML::Tiny->new( \%config );
|
|
|
48 |
$yaml->write( $CONFIGFILE );
|