# S120NET.def: Collects Network Information # $Id: S120NET.def,v 1.63 2009/05/10 20:07:42 mschenke Exp $ # ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/S120NET.def,v 1.63 2009/05/10 20:07:42 mschenke Exp $ # # Change History # 20090506 KRA Improve collection for RAC environment. =head1 NAME S120NET - Collects Network Information =head1 DESCRIPTION This module collects network information. The following reports can be generated and are regrouped under C: =cut echo tput('bold'),'Processing NET module ...',tput('off') # Initialization var $ETC = '/etc' var $HOSTS = '/etc/hosts' var $NETSTAT = undef var $NETWORKS = '/etc/networks' var $PACKET = getSetting('NETWORK_PACKET_SIZE',1280) var $PING = undef var $PROTOCOL = '/etc/protocols' var $SERVICES = '/etc/services' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' toc '1:Network' if getSetting('NETWORK_PING_TESTS') echo tput('bold'),'Network checks may take a few minutes. \ please be patient...',tput('off') =head2 ifconfig - Interface Configuration Gets the network interface configuration (platform-specific code). =head2 tcpip_settings - TCP/IP Settings Gets the TCP/IP settings (platform-specific code). =head2 udp_settings - UDP Settings Gets the UDP settings (platform-specific code). =cut var $osn = getOsName() if match($osn,'solaris') {run OSsunos('NET',\$PING,\$NETSTAT) } elsif match($osn,'hpux') {run OShpux('NET',\$PING,\$NETSTAT) } elsif match($osn,'aix') {run OSaix('NET',\$PING,\$NETSTAT) var $NETWORKS='/etc/hosts' } elsif match($osn,'dec_osf') {run OSosf('NET',\$PING,\$NETSTAT) } elsif match($osn,'linux') {run OSlinux('NET',\$PING,\$NETSTAT) } elsif match($osn,'dynixptx') {run OSptx('NET',\$PING,\$NETSTAT) } elsif match($osn,'darwin') {run OSdarwin('NET',\$PING,\$NETSTAT) } elsif isWindows() {run OSwin32('NET',\$PING,\$NETSTAT) if match($osn,'MSWin(32|64)') {if getEnv('SYSTEMROOT') var $sys = last else var ($sys) = command('echo %SystemRoot%') var $ETC = catDir($sys,'system32','drivers','etc') } var $HOSTS = catFile($ETC,'hosts') var $NETWORKS = catFile($ETC,'networks') var $PROTOCOL = catFile($ETC,'protocol') var $SERVICES = catFile($ETC,'services') } elsif isUnix() {run OSunix('NET',\$PING,\$NETSTAT) } elsif isVms() {run OSvms('NET',\$PING,\$NETSTAT) } =head2 netperf - Network Performance Performs ping tests when specified in the setup file. Collects connection information and statistics from F. Lists declared ports. =cut debug ' Inside NET module, network performance' report netperf write '---+!! Network Performance' write $TOC if getSetting('NETWORK_PING_TESTS') {if !and(match($PACKET,'^\d+$'),expr('>=',$PACKET,64),expr('<=',$PACKET,65200)) {echo "The size of the ping packet must be between 64 and 65200 bytes" var $PACKET = 1280 } var $PING = replace($PING,'\%d',$PACKET) write '---' write '---## Pings done using: ',sprintf($PING,'<machine>') write '---' macro do_ping {var ($key,$ttl) = @arg import $PING,$TOP var $tgt = getSetting($key) if match($tgt,'^[^><;:\*\+=\\\|\?\,\s"]+$') {debug ' Inside NET module, ping test to ',$tgt write '---+ ',$ttl,' (',$tgt,')' call writeCommand(sprintf($PING,$tgt)) write $TOP } } call do_ping('LOCAL_NODE', 'Loopback Ping') call do_ping('WAN_NODE', 'Ping to a Wan Node') call do_ping('RDBMS_NODE', 'Ping to the RDBMS Server Node') call do_ping('WEB_NODE', 'Ping to the Web Server Node') call do_ping('CLIENT_NODE','Ping to a Client Node') } debug ' Inside NET module, collect connection information' write '---+ Network Connection Report' var $flt = cond(isFiltered(),'n','') write '---## Using: ',$NETSTAT,' -a',$flt if loadCommand(concat($NETSTAT,' -a',$flt),true) {var ($cnt) = grepLastFile('ESTABL','c') write '|*Established Connection Count:*| ',$cnt,'|' var ($cnt) = grepLastFile('WAIT','c') write '|*Waiting Connection Count:*| ',$cnt,'|' write '---++!! Established Connection Listing:' write '' loop $lin (grepLastFile('ESTABL')) write $lin write '' } else {write 'There were problems running the netstat command (apparent hang, \ command took longer than 30 seconds to complete). Established and \ waiting connection counts and lists are not gathered.%BR%' } write $TOP if !match(getOsName(),'cygwin') {debug ' Inside NET module, get netstat interface table' prefix {write '---+ Network Interface Table' write '---## Using: ',$NETSTAT,' -i' } call writeCommand(concat($NETSTAT,' -i')) if hasOutput(true) write $TOP } debug ' Inside NET module, get nestat performance statistics' write '---+ Network Performance Statistics' if isWindows() var $opt = ' -s -e' else var $opt = ' -s' write '---## Using: ',$NETSTAT,$opt call writeCommand(concat($NETSTAT,$opt)) write $TOP debug ' Inside NET module, get nestat routing table' write '---+ Network Routing Table' write '---## Using: ',$NETSTAT,' -r',$flt call writeCommand(concat($NETSTAT,' -r',$flt)) write $TOP toc '2:[[',getFile(),'][rda_report][Network Performance]]' =head2 rev_lookup - Reverse Lookup Information Gets the aliases and reverse lookup information. =cut debug ' Inside NET module, get reverse lookup information' report rev_lookup prefix write '---+!! Reverse Lookup Information' var $hst = getSetting('MACHINE_NAME') call extern('Net','reverse_lookup',$hst) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Reverse Lookup Information]]' =head2 etc_files - Key /etc Files Extracts the top 500 lines of F. Gets F, F, F, F. =cut if testDir('f',$HOSTS) {debug ' Inside NET module, gather key /etc files' report etc_files write '---+!! Key Files from the /etc Directory:' write $TOC write '---+ ',$HOSTS,' File' if loadFile($HOSTS) {write '**Total Lines:** ',getLastLength() write '---## Top 500 lines of ',$HOSTS call statFile('b',$HOSTS) call writeLastFile(0,499) write $TOP } macro dsp_file {var ($fil) = @arg import $TOP prefix write '---+ ',encode($fil),' File' if statFile('b',$fil) {if !writeFile($fil) write 'Cannot access ',encode($fil) write $TOP } unprefix } macro skp_file {var ($fil) = @arg import $TOP prefix write '---+ ',encode($fil),' File' if statFile('b',$fil) {write 'Skipped for security reasons%BR%' write $TOP } unprefix } call dsp_file('/etc/defaultrouter') call dsp_file('/etc/filesystems') call dsp_file('/etc/group') call dsp_file('/etc/nodename') call dsp_file('/etc/nsswitch.conf') call dsp_file('/etc/rc.net') call dsp_file($PROTOCOL) if isFiltered() call skp_file($NETWORKS) else call dsp_file($NETWORKS) call dsp_file($SERVICES) toc '2:[[',getFile(),'][rda_report][Key /etc Files]]' } =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L =begin credits =over 10 =item RDA 4.0: Ed Bangma. =item RDA 4.1: Kevin Reardon, Guido Tijskens, Andy Young. =item RDA 4.4: Cameron Melvin. =item RDA 4.8: Johan Vanden Bossche. =item RDA 4.10: Russ Hodgson. =item RDA 4.12: Francois Lange, Kevin Reardon. =item RDA 4.15: Daniel Mortimer. =item RDA 4.16: Jaime Alcoreza, Hagen Herbst, Scott Jesse, Rick Pulliam, Sanjay Singh, Hector Viveros. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002-2009, Oracle. All rights reserved. =head1 TRADEMARK NOTICE Oracle, JD Edwards, PeopleSoft, and Siebel are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. =cut