# DCnet.ctl:120:Collects Network Information # $Id: DCnet.ctl,v 1.13 2015/10/06 12:45:10 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OS/DCnet.ctl,v 1.13 2015/10/06 12:45:10 RDA Exp $ # # Change History # 20150930 KRA Share 'Network Performance' section. =head1 NAME OS:DCnet - 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 OS.NET module ...',tput('off') # Initialization var $ETC = '/etc' var $HOSTS = '/etc/hosts' var $NETSTAT = undef var $NETWORKS = '/etc/networks' var $PACKET = ${N_PACKET_SIZE:1280} var $PING = undef var $PROTOCOL = '/etc/protocols' var $SERVICES = '/etc/services' var $NO_DNS = cond(isFiltered(),true,${B_NO_DNS}) var %DUP var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' var $XPL = 'OS.NET/files/' toc '1:Network' if ${B_PING_TESTS} echo tput('bold'),'Network checks may take a few minutes. \ 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 OS:OSsunos('NET',\$PING,\$NETSTAT) } elsif match($osn,'hpux') {run OS:OShpux('NET',\$PING,\$NETSTAT) } elsif match($osn,'aix') {run OS:OSaix('NET',\$PING,\$NETSTAT) var $NETWORKS='/etc/hosts' } elsif match($osn,'dec_osf') {run OS:OSosf('NET',\$PING,\$NETSTAT) } elsif match($osn,'linux') {run OS:OSlinux('NET',\$PING,\$NETSTAT) } elsif match($osn,'dynixptx') {run OS:OSptx('NET',\$PING,\$NETSTAT) } elsif match($osn,'darwin') {run OS:OSdarwin('NET',\$PING,\$NETSTAT) } elsif isCygwin() {run OS:OSwin32('NET',\$PING,\$NETSTAT) } elsif isUnix() {run OS:OSunix('NET',\$PING,\$NETSTAT) } elsif isVms() {run OS:OSvms('NET',\$PING,\$NETSTAT) } elsif isWindows() {run OS:OSwin32('NET',\$PING,\$NETSTAT) if ${ENV.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 if ?getCodePage() write '' write '---+!! Network Performance' write $TOC if ${B_PING_TESTS} {if or(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 ($tgt,$ttl) = @arg import $PING,$TOP if match($tgt,'^[^><;:\*\+=\\\|\?\,\s"]+$') {debug ' Inside NET module, ping test to ',$tgt write '---+ ',$ttl,' (',$tgt,')' call addBlock('X','T','OS.NET/ping') call writeCommand(sprintf($PING,$tgt)) write $TOP } } call do_ping(${T_LOCAL_NODE}, 'Loopback Ping') call do_ping(${T_WAN_NODE}, 'Ping to a Wan Node') call do_ping(${T_RDBMS_NODE}, 'Ping to the RDBMS Server Node') call do_ping(${T_WEB_NODE}, 'Ping to the Web Server Node') call do_ping(${T_CLIENT_NODE}, 'Ping to a Client Node') call do_ping(${T_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'))) var $opt = 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,'|' var $flg = ${B_NETSTAT_ALL} write '---++!! ',cond($flg,'Connection','Established Connection'),' Listing:' call beginBlock(true) call addBlock('X','D',\ concat('OS.NET/netstat_',$opt,cond($flg,'_ANY','_ESTABL'))) if and($NO_DNS,isFiltered()) {loop $lin (grepLastFile(cond($flg,'TCP|UDP','ESTABL'))) write replace($lin,'\d+(\.\d+){3}','%R:IP4%',true) } else {loop $lin (grepLastFile(cond($flg,'TCP|UDP','ESTABL'))) write $lin } call endBlock() } 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 and(or(${OS.linux},isCygwin(),isWindows()),\ not(isFiltered())) {debug ' Inside NET module, collecting detailed connection information' var $cmd = join(' ',$NETSTAT,\ $opt = cond(${OS.linux},cond($NO_DNS,'-anp','-ap'),\ cond($NO_DNS,'-ano','-ao'))) prefix {write '---+ Detailed Network Connection Report' write '---## Using: ',$cmd call addBlock('X','O',concat('OS.NET/netstat_',$opt,'.out')) } call writeCommand($cmd) if hasOutput(true) 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 var $opt = cond($NO_DNS,'-in','-i') call addBlock('X','O',concat('OS.NET/netstat_',$opt,'.out')) } 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')) var $opt = cond(or(isUnix(),isVms()),'-s','-s_-e') call addBlock('X','O',concat('OS.NET/netstat_',$opt,'.out')) 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'))) var $opt = cond(${OS.hpux},cond($NO_DNS,'-rnv','-rv'),\ cond($NO_DNS,'-rn','-r')) write '---## Using: ',$cmd call addBlock('X','O',concat('OS.NET/netstat_',$opt,'.out')) 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 addBlock('X','O','OS.NET/netstat_-v.out') } call writeCommand($cmd) if hasOutput(true) write $TOP } share 'NET_PERF','Network Performance' 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 beginBlock(false) call addBlock('X','D','OS.NET/rev_lookup') } call extern('Net','reverse_lookup',${RDA.T_NODE}) if isCreated(true) {call endBlock() 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 addBlock('X','O','OS.NET/p1info.out') } call writeCommand('/sbin/p1info') if hasOutput(true) write $TOP prefix {call dsp_title('---+ Status of IB port2','---## Using: /sbin/p2info') call addBlock('X','O','OS.NET/p2info.out') } call writeCommand('/sbin/p2info') if hasOutput(true) write $TOP prefix {call dsp_title('---+ IB port1 Statistics','---## Using: /sbin/p1stats') call addBlock('X','O','OS.NET/p1stats.out') } call writeCommand('/sbin/p1stats') if hasOutput(true) write $TOP prefix {call dsp_title('---+ IB port2 Statistics','---## Using: /sbin/p2stats') call addBlock('X','O','OS.NET/p2stats.out') } call writeCommand('/sbin/p2stats') if hasOutput(true) write $TOP prefix {call dsp_title('---+ IB all ports',\ concat('---## Using: /sbin/showallports -h ',${RDA.T_NODE})) call addBlock('X','O',concat('OS.NET/showallports_-h_',${RDA.T_NODE},'.out')) } call writeCommand(concat('/sbin/showallports -h ',${RDA.T_NODE})) if hasOutput(true) write $TOP prefix {call dsp_title('---+ IB Device Information',\ '---## Using: /usr/sbin/ibstat -v') call addBlock('X','O','OS.NET/ibstat_-v.out') } 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 addBlock('X','D','OS.NET/files/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 addBlock('X','D','OS.NET/tail_-n_500_etc_hosts') call writeLastFile(0,499) write $TOP } macro dsp_file {var ($fil) = @arg import $TOP,$XPL prefix {write '---+ ',encode($fil),' File' call addBlock('X','D',concat($XPL,$fil)) } 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. =item RDA 8.06: Hiroki Ata. =item RDA 8.07: Rui Du. =item RDA 8.09: Jayatheertha Hanumantha Rao. =item RDA 8.10: Yogesh Sontakke. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2016, 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