Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
69 rodolico 23
            'portsToIgnore' => ['port','numbers','to','ignore']
5 rodolico 24
         },
25
         'DNS or IP' => {
26
            'community' => 'snmp community name',
69 rodolico 27
            'portsToIgnore' => ['port','numbers','to','ignore']
5 rodolico 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
            }
69 rodolico 41
      },
42
      # this is entire optional, but if it exists, it will be used to supplement or override MAC to IP to DNS lookup.
43
      # Each entry is optional
44
      # MAC is the hexidecimal mac address, with no delimiters and all lower case. Example is: 
45
      #    402cf4e9ae9b      CORRECT
46
      #    40:2c:f4:e9:ae:9b WRONG, has delimiters (the colons)
47
      #    402CF4E9AE9B      WRONG, alphas are upper case
48
      # ip:       if this is entered, will be used as IP for the mac address, otherwise it is looked up in the routers arp table.
49
      #           default is to get IP from router's arp table
50
      # hostname: If this is entered, will be used for hostname, otherwise done via reverse DNS entry from router. Default is
51
      #           to look up via rdns
52
      # override: If false, ip/hostname only be used if no value returned from arp/rdns. If true, ip/hostname are not even
53
      #           attempted, ie this will override anything in those services. Default is false, only use if you can not find
54
      #           it.
55
      'staticmaps' => {
56
         'MAC1' => {
57
            'ip' => '1.1.1.1',
58
            'hostname' => 'some.host.name',
59
            'override' => 0
60
            },
61
         'MAC2' => {
62
            'ip' => '1.1.1.2',
63
            'hostname' => 'some other host name',
64
            'override' => 1
65
         }
5 rodolico 66
      }
69 rodolico 67
 
68
 
5 rodolico 69
   );
70
 
71
my $scriptDir = dirname( File::Spec->rel2abs( __FILE__ ) );
72
my $CONFIGFILE = $scriptDir . '/mapSwitches.config.yaml';
73
 
74
my $yaml = YAML::Tiny->new( \%config );
75
$yaml->write( $CONFIGFILE );