# S120NET.def: Collects Network Information # $Id: S120NET.def,v 2.18 2012/01/25 10:51:18 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/S120NET.def,v 2.18 2012/01/25 10:51:18 mschenke Exp $ # # Change History # 20120124 KRA Extend ping test to load balancer node. =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 $NO_DNS = cond(isFiltered(),true,getSetting('NET_NO_DNS',false)) var %DUP 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 isCygwin() {run OSwin32('NET',\$PING,\$NETSTAT) } elsif isUnix() {run OSunix('NET',\$PING,\$NETSTAT) } elsif isVms() {run OSvms('NET',\$PING,\$NETSTAT) } elsif isWindows() {run OSwin32('NET',\$PING,\$NETSTAT) 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') } =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') call do_ping('LOAD_BALANCER_NODE','Ping to a Load Balancer Node') } debug ' Inside NET module, collect connection information' write '---+ Network Connection Report' var $cmd = concat($NETSTAT,\ cond(isVms(),cond($NO_DNS,' "-an"',' "-a"'),\ cond($NO_DNS,' -an',' -a'))) write '---## Using: ',$cmd if loadCommand($cmd,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 '' if and($NO_DNS,isFiltered()) {loop $lin (grepLastFile('ESTABL')) write replace($lin,'\d+(\.\d+){3}','%R:IP4%',true) } else {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 !or(isCygwin(),isWindows()) {debug ' Inside NET module, get netstat interface table' var $cmd = concat($NETSTAT,\ cond(isVms(),cond($NO_DNS,' "-in"',' "-i"'),\ cond($NO_DNS,' -in',' -i'))) prefix {write '---+ Network Interface Table' write '---## Using: ',$cmd } call writeCommand($cmd) if hasOutput(true) write $TOP } debug ' Inside NET module, get nestat performance statistics' write '---+ Network Performance Statistics' var $cmd = concat($NETSTAT,cond(isUnix(),' -s',isVms(),' "-s"',' -s -e')) write '---## Using: ',$cmd call writeCommand($cmd) write $TOP debug ' Inside NET module, get nestat routing table' write '---+ Network Routing Table' var $cmd = concat($NETSTAT,\ cond(${OS.vms}, cond($NO_DNS,' "-rn"',' "-r"'),\ ${OS.hpux},cond($NO_DNS,' -rnv',' -rv'),\ cond($NO_DNS,' -rn',' -r'))) write '---## Using: ',$cmd call writeCommand(concat($cmd)) write $TOP if ${OS.aix} {debug ' Inside NET module, get CDLI-based device driver statistics' var $cmd = concat($NETSTAT,' -v') prefix {write '---+ CDLI-based Device Drivers Statistics' write '---## Using: ',$cmd } call writeCommand($cmd) if hasOutput(true) 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' call extern('Net','reverse_lookup',${RDA.NODE}) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Reverse Lookup Information]]' =head2 infiniband - Infiniband Statistics Collects Infiniband statistics. =cut if testFile('fx','/sbin/p1info') {debug ' Inside NET module, getting Infiniband statistics' report infiniband macro dsp_title {var ($ttl,$use) = @arg import $TOC keep $TOC if !isCreated() {write '---+!! Infiniband Statistics' write $TOC } } prefix call dsp_title('---+ Status of IB port1','---## Using: /sbin/p1info') call writeCommand('/sbin/p1info') if hasOutput(true) write $TOP prefix call dsp_title('---+ Status of IB port2','---## Using: /sbin/p2info') call writeCommand('/sbin/p2info') if hasOutput(true) write $TOP prefix call dsp_title('---+ IB port1 Statistics','---## Using: /sbin/p1stats') call writeCommand('/sbin/p1stats') if hasOutput(true) write $TOP prefix call dsp_title('---+ IB port2 Statistics','---## Using: /sbin/p2stats') call writeCommand('/sbin/p2stats') if hasOutput(true) write $TOP prefix call dsp_title('---+ IB all ports',\ concat('---## Using: /sbin/showallports -h ',${RDA.NODE})) call writeCommand(concat('/sbin/showallports -h ',${RDA.NODE})) if hasOutput(true) write $TOP prefix call dsp_title('---+ IB Device Information',\ '---## Using: /usr/sbin/ibstat -v') call writeCommand('/usr/sbin/ibstat -v') if hasOutput(true) write $TOP prefix call dsp_title('---+ RDS Usage Statistics',\ '---## Information Taken from: /proc/driver/rds/stats') call writeFile('/proc/driver/rds/stats') if hasOutput(true) write $TOP if isCreated(true) toc '2:[[',getFile(),'][rda_report][Infiniband Statistics]]' } =head2 etc_files - Key /etc Files Extracts the top 500 lines of F. Gets other key files including F, F, F, F, F, F, F, F, and F when present. =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),'%BR%' 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') loop $fil (grepDir('/etc','hostname\..*','np')) call dsp_file($fil) if isFiltered() call skp_file('/etc/netmasks') else call dsp_file('/etc/netmasks') if isFiltered() call skp_file($NETWORKS) else call dsp_file($NETWORKS) call dsp_file('/etc/nodename') call dsp_file('/etc/nsswitch.conf') call dsp_file($PROTOCOL) call dsp_file('/etc/rc.net') call dsp_file('/etc/rc.config.d/netdaemons') call dsp_file('/etc/sysconfig/network/routes') loop $fil (grepDir('/etc/sysconfig/network-scripts','^(ifcfg|route)\-','np')) call dsp_file($fil) 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. =item RDA 4.18: Jaime Alcoreza. =item RDA 4.19: Grant Hayden. =item RDA 4.23: Herbert van den Bergh. =item RDA 4.27: Daniel Mortimer. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. =head1 TRADEMARK NOTICE Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. =cut