#!/opt/vdops/bin/perl # This script populates the 'switches', 'switch_ports', and 'port_statusi # tables. In addition, it populates the mac, ip_addr, and switch_port # fields in the 'hosts' table. # Functionally, this script lays the foundation for all the other data # collection routines feeding Soma: 'hosts' table entries require a mac # address, and this is the script which populates that field ... the # other data collection scripts, in general, gather information about # 'hosts' using IP addresses ... which they then look-up in Soma in order to # acquire the MAC address ... which then allows them to insert/update the # data they have acquired into the 'hosts' table. When they gather data # about an IP address for which the 'hosts' table contains no MAC address, # they must throw away what they have discovered. Thus, the data this # script gathers provides the foundation for most of the work performed # by the data collecting scripts populating Soma. I run this script as # frequently as I can (currently once/hour), in order to discover new # devices as quickly as possible and thus permit the other data # collecting scripts to enter their data into Soma. # # Specifically, this script; # - discovers ethernet switches and inserts new ones # - discovers the ports on those ethernet switches, inserting new ones # - discovers CAM entries, inserting new ones # - updates ifAdminStatus for each port ('port_status' table) # - discovers routers and acquires ARP tables, updating the # MAC <-> IP mapping (mac and ip_addr fields in the 'hosts' table) # # Load modules use strict; use warnings; use Data::Dumper; use Perl6::Say; use lib '/home/soma/lib'; use FHCRC::VDOPS::Foundation; use FHCRC::VDOPS::NetworkTools; use FHCRC::VDOPS::SomaCrud; use FHCRC::VDOPS::SomaData; use FHCRC::VDOPS::Utilities; # Notify operator log_it("Beginning $0"); say "Beginning $0" if $job eq 'interactive'; # Thread job doesn't work well here, so disable it $debug = 0; $thrMode = 0; # Construct a foundation foundation(); build_switches(); build_routers(); build_ports(); # Insert switches and ports iu_switches(); iu_ports(); # Insert CAM table acquire_cam_table(); iu_cam_table(); # Insert ifAdminStatus table acquire_if_admin_status(); iu_if_admin_status(); # Insert ARP table acquire_arp_table(); iu_arp_table(); # Notify operator log_it("Ending $0"); say "Ending $0" if $job eq 'interactive';