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' => {
19
         'DNS or IP' => {
20
            'community' => 'snmp community name',
21
            'portsToIgnore' => [port,numbers,to,ignore]
22
         },
23
         'DNS or IP' => {
24
            'community' => 'snmp community name',
25
            'portsToIgnore' => [port,numbers,to,ignore]
26
         }
27
      },
28
      # You must include at least one router.
29
      # this will be queried to resolve IP's to MAC 
30
      # using its arp table
31
      # put IP and community name into the hash
32
      'routers' =>  {
33
            'DNS or IP' => {
34
               'community' => 'snmp community name',
35
            },
36
            'DNS or IP' => {
37
               'community' => 'snmp community name',
38
            }
39
      }
40
   );
41
 
42
my $scriptDir = dirname( File::Spec->rel2abs( __FILE__ ) );
43
my $CONFIGFILE = $scriptDir . '/mapSwitches.config.yaml';
44
 
45
my $yaml = YAML::Tiny->new( \%config );
46
$yaml->write( $CONFIGFILE );