Subversion Repositories sysadmin_scripts

Rev

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

Rev Author Line No. Line
5 rodolico 1
This script polls network switch ports to see which MAC addresses are assigned to them, then polls the arp table
2
on one or more routers to determine the IP address. It then uses reverse DNS to look up the name of the device
3
 
4
The results are saved in a YAML file and used to initialize the internal structures if it exists, so when a device
5
goes off the network, the information that it was there remains available (and the date/time it was last seen).
6
 
7
Since the data is stored in a YAML file, a second script, mapSwitchesShow.pl was created to convert to a tab delimited text
8
file for human viewing and/or script processing.
9
 
10
Files:
11
 
12
mapSwitches.pl - the main file which connects to each device in config, gathers data, and updates persistent storage
13
mapSwitchesShow.pl - converts stored data into a CSV (tab delimited)
14
mapswitches.cron - sample cron file to gather information hourly and generate a CSV once a day
15
 
16
The following files are not required for the system to run
17
mapSwitches.config.yaml.sample - sample configuration file
18
README - This file
19
makeConfig.pl.sample - generate configuration file from hash. Easier for perl programmers
20
mapSwitches.config.yaml.sample - sample configuration file
21
pingall.pl - utility to ping all available ports on a /24 network. Used to artificially refresh arp table
22
 
23
The configuration file MUST be created before running the script. It can be manually created
24
(rename mapSwitches.config.yaml.sample to mapSwitches.config.yaml and edit) or generated makeConfig.pl.sample
25
(edit hash, then run)
26
 
27
The following file is created on first run.
28
mapSwitches.yaml
29
This is the persistent storage. It can be safely deleted at any time to reinitialize the system.
30
 
31
The script requires snmp to be installed (no MIB files required), and uses the perl module YAML::Tiny. On a Debian based
32
system, this can be installed with the command:
33
 
34
apt-get libyaml-tiny-perl snmp
35
 
36
We generally set this to be run hourly, and we then generate a tab delimited text file once a day. See the sample cron file
37
for how we do it.