########################################################################## # package Foundation.pm # This Perl module contains one function 'foundation', which lays the # groundwork for the typical Soma data collection routine # V Who When What # --------------------------------------------------------------------------- # 1.1.2 skendric 06-16-2008 Stylistic mods # 1.1.1 skendric 03-12-2007 Stylistic mods # 1.1.0 skendric 06-23-2005 Support new %routeTable hash # 1.0.9 skendric 06-12-2005 Support generalized acquire_route_table # 1.0.8 skendric 06-09-2005 Check subroutine parameters # 1.0.7 skendric 02-09-2005 Convert %hostname to %nodename # 1.0.6 skendric 02-06-2005 Remove redundant assign to %hostname # 1.0.5 skendric 01-03-2005 Change return value of get_hostname # 1.0.4 skendric 09-05-2004 skip->skip_name # 1.0.3 skendric 07-13-2004 Cosmetic changes # 1.0.2 skendric 06-19-2004 Strip everything but route table acquisition # 1.0.1 skendric 06-18-2004 Add esx characterization # 1.0.0 skendric 06-07-2004 First version # # # # Authors: Stuart Kendrick # # Source: http://www.skendric.com/device/soma # # This software is available under the GNU GENERAL PUBLIC LICENSE, see # http://www.fsf.org/licenses/gpl.html # package FHCRC::VDOPS::Foundation; #### Load modules #### use strict; use warnings; use threads; use threads::shared; use Carp qw(carp cluck croak confess); use Data::Dumper; use Exporter; use Perl6::Say; use lib '/home/soma/lib'; use FHCRC::VDOPS::HostTools; use FHCRC::VDOPS::NetworkTools; use FHCRC::VDOPS::PingTools; use FHCRC::VDOPS::SomaData; use FHCRC::VDOPS::SNMPTools; use FHCRC::VDOPS::Utilities; #### Set-up export stuff #### our @ISA = qw(Exporter); our @EXPORT = qw( foundation ); # Define global variables ##### Only subroutines below here #### ######################################################################## # Initialize lots of hashes and arrays ######################################################################## sub foundation { my $localRoute; my $nodename; # Nodename associated with $referenceRouter # Debug trace trace_location('begin') if $debug; # Compile MIB files compile_mibs(); # Validate $referenceRouter unless (defined $nodename{$referenceRouter}) { $nodename = get_nodename($referenceRouter); unless (defined $nodename) { confess "Fatal: cannot resolve $referenceRouter to nodename"; } $nodename{$referenceRouter} = $nodename; } for my $skip (@skip_name) { if ($nodename=~ /$skip/) { confess "Fatal: referenceRouter '$nodename' belongs to \@skip_name"; } } unless (ping_it($referenceRouter)) { confess "Fatal: referenceRouter '$nodename' is not answering pings"; } # Build route table if ( snmp_char($referenceRouter, \@snmp_read_list, \@snmp_version_list) ) { $localRoute = acquire_route_table($referenceRouter); } else { bail("referenceRouter $referenceRouter not responding to SNMP"); } # Construct hash %routeTable = %$localRoute; # Debug trace trace_location('end') if $debug; return 1; } 1;