Subversion Repositories sysadmin_scripts

Rev

Rev 69 | Rev 136 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#! /usr/bin/env perl

# just a simple script for people more familiar with
# perl syntax than YAML. Modify %config below, then run
# this script. It will create the configuration file for
# you.
use strict;
use warnings;

use YAML::Tiny; # apt-get libyaml-tiny-perl under debian
use File::Spec; # find location of script so we can put storage in same directory
use File::Basename;


my %config = (
      # one or more switches and their corresponding
      # community name. Use v1 snmp only
      'switches' => {
         'DNS or IP' => { # enter a DNS name or an IP address to be scanned.
            'community' => 'snmp community name',
            # the following list can be used to ignore ports on this switch. Note that these are the port numbers
            # returned by OID iso.3.6.1.2.1.2.2.1.8
            'portsToIgnore' => ['port','numbers','to','ignore']
         },
         'DNS or IP' => {
            'community' => 'snmp community name',
            'portsToIgnore' => ['port','numbers','to','ignore']
         }
      },
      # You must include at least one router.
      # this will be queried to resolve IP's to MAC 
      # using its arp table
      # put IP and community name into the hash
      'routers' =>  {
            'DNS or IP' => {
               'community' => 'snmp community name',
            },
            'DNS or IP' => {
               'community' => 'snmp community name',
            }
      },
      # this is entire optional, but if it exists, it will be used to supplement or override MAC to IP to DNS lookup.
      # Each entry is optional
      # MAC is the hexidecimal mac address, with no delimiters and all lower case. Example is: 
      #    402cf4e9ae9b      CORRECT
      #    40:2c:f4:e9:ae:9b WRONG, has delimiters (the colons)
      #    402CF4E9AE9B      WRONG, alphas are upper case
      # ip:       if this is entered, will be used as IP for the mac address, otherwise it is looked up in the routers arp table.
      #           default is to get IP from router's arp table
      # hostname: If this is entered, will be used for hostname, otherwise done via reverse DNS entry from router. Default is
      #           to look up via rdns
      # override: If false, ip/hostname only be used if no value returned from arp/rdns. If true, ip/hostname are not even
      #           attempted, ie this will override anything in those services. Default is false, only use if you can not find
      #           it.
      'staticmaps' => {
         'MAC1' => {
            'ip' => '1.1.1.1',
            'hostname' => 'some.host.name',
            'override' => 0
            },
         'MAC2' => {
            'ip' => '1.1.1.2',
            'hostname' => 'some other host name',
            'override' => 1
         }
      },
      
      'nonrouter' => (
         'filename1',
         'filename2'
      )
      
          
      
   );

my $scriptDir = dirname( File::Spec->rel2abs( __FILE__ ) );
my $CONFIGFILE = $scriptDir . '/mapSwitches.config.yaml';

my $yaml = YAML::Tiny->new( \%config );
$yaml->write( $CONFIGFILE );