# OSptx.ctl: Dynix/Ptx Specific Code # $Id: OSptx.ctl,v 1.10 2015/06/15 09:54:07 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OS/OSptx.ctl,v 1.10 2015/06/15 09:54:07 RDA Exp $ # # Change History # 20150612 KRA Add 'Back to top' link. =head1 NAME OS:OSptx - Submodule Specific to the Dynix/Ptx Operating System =cut use Mrc # Make the module persistent keep $KEEP_BLOCK,@SHARE_MACROS var @SHARE_MACROS = ('ping_command') # Get the calling module var $MODULE = $arg[0] import $TOC,$TOP =head1 DESCRIPTION This module determines the F command format. =cut if !$OS {keep $OS,$OSA,$OSP var $OS = true # Determine the ps command format var $OSP = testCommand('ps -ef','/bin/ps -ef','/usr/bin/ps -ef') var $OSA = concat($OSP,' -o comm,args') } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE INI MODULE Nothing required yet. =cut if compare('eq',$MODULE,'INI') {# Nothing required yet } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE END MODULE =head2 report - Report Settings Determines the operating system version and its bit size. =cut elsif compare('eq',$MODULE,'END_report') {# Load the system settings write '|Platform|32-bit ',getOsName(),'|' write '|O/S Version|',uname('r'),'|' } =head2 system - System Information Extracts the system information such as CPU and memory. =cut elsif compare('eq',$MODULE,'END_system') {prefix write '|*Item*|*Value*|' debug ' Inside END module, getting CPU and memory information (ptx)' if loadCommand('/etc/showquads') {var ($cnt,$mem) = (0,0) loop $lin (getLines()) {if match($lin,'Total memory:\s+(\d+)MB') {var ($siz) = (last) incr $mem,$siz } else {var @rec = split('\s+',trim($lin)) if match($rec[0],'^\d+$') {incr $cnt var (undef,$typ[$cnt],$mhz[$cnt]) = @rec } } } if $cnt {var ($off,$str) = (0,concat($cnt,' Processor(s) Installed')) while expr('<',$off,$cnt) {incr $off var $str = sprintf('%s%%BR%%[%02d]: %s %d MHz',$str,$off,\ $typ[$off],$mhz[$off]) } write '|Processor(s)|',$str,'|' } if $mem write sprintf('|Total Physical Memory|%d MiB|',$mem) } debug ' Inside END module, getting swap information (ptx)' if loadCommand('/etc/swap -l') {var $mem = 0 loop $lin (getLines()) {var @rec = split('\s+',$lin) if match($rec[3],'^\d+$') incr $mem,$rec[3] } if $mem {write sprintf('|Swap: Max Size|%d MiB|',expr('/',$mem,2048)) if grepCommand('/etc/swap -f',' \d+ free,','f') {var ($mem) = (match(last,' (\d+) free,')) write sprintf('|Swap: Available|%d MiB|',expr('/',$mem,2048)) } } } if !hasOutput(true) write 'Information not available%BR%' write $TOP } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE OS MODULE =cut elsif compare('eq',$MODULE,'OS') { =head2 cpu_info - CPUs Gets CPU information. =cut debug ' Inside OS module, getting CPU information (dynix/ptx)' report cpu_info write '---+ CPU Information' write '---## Using: /etc/showcfg | grep PROC' write '' loop $lin (grepCommand('/etc/showcfg','PROC')) write $lin write '' write $TOP toc '2:[[',getFile(),'][rda_report][CPUs]]' =head2 memory_info - Memory Gets information about the physical memory. =cut debug ' Inside OS module, about physical memory (dynix/ptx)' report memory_info write '---+ Physical Memory Installed' write '---## Using: /etc/showquads | grep "Total memory"' write '' loop $lin (grepCommand('/etc/showquads','Total memory')) write $lin write '' write $TOP toc '2:[[',getFile(),'][rda_report][Memory]]' =head2 disk_info - Disk Drives Gets information about the disks. =cut debug ' Inside OS module, about disks (dynix/ptx)' report disk_info write '---+!! Disk Information' write $TOC write '---+ Disk Mounts' call writeCommand('mount') write $TOP write '---+ Disk Free' call writeCommand('df -k') write $TOP # write '---+ Swap' # call writeCommand('/sbin/swap -l') # write $TOP toc '2:[[',getFile(),'][rda_report][Disk Drives]]' =head2 ipc_info - Kernel Tables and IPC Gets the kernel tables and IPC information. =cut report kernel_info write '---+!! Kernel Tables and IPC' write $TOC write '---+ Kernel Tables' call writeCommand('sar -v 1 1') write $TOP write '---+ Semaphores' call writeCommand('ipcs -sa') write $TOP write '---+ Shared Memory' call writeCommand('ipcs -ma') write $TOP toc '2:[[',getFile(),'][rda_report][Kernel Tables and IPC]]' =head2 ntp - NTP Status and Configuration Collects NTP status information when NTP is running and accessible. It collects the F file when present. =cut debug ' Inside OS module, getting NTP status and configuration' report ntp var $ttl = '---+!! NTP Status and Configuration Information' #Get NTP Status if ?findCommand('ntpq') {var $cmd = concat(last,' -p') report ntpstatus prefix {if !isCreated() {write $ttl write $TOC } write '---+ NTP Status' write '---## Using: ntpq -p' } var $hdr = true loop $lin (grepCommand($cmd,'.')) {if match($lin,'^=') var $hdr = false elsif match($lin,'No association ') write $lin elsif $hdr write '|*',replace(trim($lin),'\s+','*|*',true),'*|' else write '|',replace(trim($lin),'\s+',' |',true),' |' } } # Get the NTP configuration file prefix {if !isCreated() {write $ttl write $TOC } write '---+ NTP Configuration' write '---## Information Taken from /etc/ntp.conf' } call writeFile('/etc/ntp.conf') if hasOutput(true) write $TOP if isCreated(true) toc '2:[[',getFile(),'][rda_report][NTP Status and Configuration]]' =head2 packages - Operating System Packages Lists all operating system packages. =cut debug ' Inside OS module, getting operating system package information' report packages write '---+ Operating System Package Information' write '---## Using: pkginfo -i' call writeCommand('pkginfo -i') write $TOP toc '2:[[',getFile(),'][rda_report][Operating System Packages]]' =head2 patches - Operating System Patches Lists the operating system patches installed. =cut debug ' Inside OS module, getting operating system patches' report patches prefix {write '---+ Operating System Patches Information' write '---## Using: cat /etc/versionlog' } call writeFile('/etc/versionlog') if isCreated(true) {write $TOP toc '2:[[',getFile(),'][rda_report][Operating System Patches]]' } =head2 sysdef - System/Kernel Settings Collects system/kernel settings. =cut debug ' Inside OS module, getting system/kernel settings' report sysdef var $cmd = '/etc/sysdef' write '---+ System/Kernel Settings' write '---## Using: ',encode($cmd) call writeCommand($cmd) write $TOP toc '2:[[',getFile(),'][rda_report][System/Kernel Settings]]' =head2 system_error_log - System Error Log Collects system error log data. =cut collect OS:RCptx|OS() =pod Identifies useful platform-related links. =cut var \@LINKS = $arg[1] var @LINKS = ('http://www.ibm.com/eserver/support/',\ 'http://www.ibm.com/support/fixcentral/diags',\ 'http://www.redbooks.ibm.com/abstracts/sg246215.html') } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE PERF MODULE =cut elsif compare('eq',$MODULE,'PERF') {# Produce the performance report report perf_over write '---+!! System Performance Overview' write $TOC =pod Gets the system uptime. =cut debug ' Inside PERF module, about to execute uptime command' prefix write '---+ Uptime' call writeCommand('uptime') if hasOutput(true) write $TOP =pod Gets the system last reboot. =cut debug ' Inside PERF module, about to execute last reboot command' prefix write '---+ Last Restart' if findCommand('last') call writeCommand(concat(last,' reboot')) if hasOutput(true) write $TOP =pod Gets a process overview in terms of running databases, users logged on, and top CPU users. =cut if loadCommand($OSP) {debug ' Inside PERF module, about to gather user and process counts' write '---+ Process Overview' var $cnt = grepLastFile('oracle') write '|*Oracle Processes*|', $cnt,' |' var $cnt = grepLastFile('tnslsn','i') write '|*Listeners Processes*|', $cnt,' |' var $cnt = grepLastFile('DESCRIPTION=') write '|*Background Processes*|',$cnt,' |' var $cnt = grepLastFile('root') write '|*Root Processes*|', $cnt,' |' var $cnt = getLastLength() write '|*Total Processes*|', $cnt,' |' var $cnt = command('who') write '|*Number Users*|', $cnt,' |' var ($hdr) = getLines(0,0) call sortLastFile('ps_time') debug ' Inside PERF module, about to determine running databases' prefix {write '---+ Running Databases' write 'Note: the CPU usage in minutes' write '' write $hdr } loop $lin (grepLastFile('pmon')) write $lin if hasOutput(true) {write '' write $TOP } debug ' Inside PERF module, about to determine users logged on' write '---+ Who is Logged On?' call writeCommand('who | sort') write $TOP debug ' Inside PERF module, about to determine CPU hogs' var $cnt = ${N_TOP_PS:15} write '---+ Current CPU Hogs / Top ',$cnt,' by CPU Time' call writeLastFile(0,$cnt) write $TOP debug ' Inside PERF module, about to determine root CPU hogs' var $cnt = ${N_TOP_ROOT:5} write '---+ Root CPU Hogs / Top ',$cnt,' by CPU Time' write '' write $hdr loop $lin (grepLastFile('root')) {next match($lin,'ckunix') write $lin decr $cnt break !$cnt } write '' write $TOP } =pod Gets a disk overview in terms of free space, disk I/O, paging, and swapping. =cut debug ' Inside PERF module, about to gather File System Free Space' write '---+ File System Free Space in KiB' call writeCommand('df -k') write $TOP debug ' Inside PERF module, about to gather disk throughput (takes 30 sec)' write '---+ Throughput MiB/sec, Transfers/sec, avg Service Time milliseconds' write '---## Using: sar -d 10 3' call writeCommand('sar -d 10 3') write $TOP var $osn = uname('s') var $out = verbatim($osn) debug ' Inside PERF module, about to gather paging statistics' write '---+ Paging Activities' write '---## Using: sar -w 1 4 | grep -v ',$osn write '' loop $lin (grepCommand('sar -w 1 4 2>&1',$out,'v')) write $lin write '' write $TOP debug ' Inside PERF module, about to gather swapping activity (dynix/ptx)' write '---+ Swap Activities' write '---## Using: sar -w 2 2' call writeCommand('sar -w 2 2') write $TOP =pod Gets a system overview in terms of CPU usage, top processes, system calls, memory, message, and semaphore statistics. =cut debug ' Inside PERF module, about to gather CPU per-processor stats' write '---+ CPU per-Processor Statistics' write '---## Using: sar -qwu 1 3' call writeCommand('sar -qwu 1 3') write $TOP debug ' Inside PERF module, about to gather CPU usage stats' write '---+ Sar CPU Usage' write '---## Using: sar -u 1 4 | grep -v ',$osn write '' loop $lin (grepCommand('sar -u 1 4 2>&1',$out,'v')) write $lin write '' write $TOP debug ' Inside PERF module, about to echo top command output' write '---+ Top Report Usage' call writeCommand('/usr/bin/top -s1 -d2 40') write $TOP debug ' Inside PERF module, about to gather system calls' write '---+ System Calls' write '---## Using: sar -c 1 4 | grep -v ',$osn write '' loop $lin (grepCommand('sar -c 1 4 2>&1',$out,'v')) write $lin write '' write $TOP debug ' Inside PERF module, about to gather memory statistics' write '---+ Memory Statistics' write '---## Using: sar -cwmpr' call writeCommand('sar -cwmpr') write $TOP debug ' Inside PERF module, about to gather message and semaphore statistics' write '---+ Message and Semaphore Statistics' write '---## Using: sar -m 1 4 | grep -v ',$osn write '' loop $lin (grepCommand('sar -m 1 4 2>&1',$out,'v')) write $lin write '' write $TOP =pod Lists running processes information. =cut if ${B_PS} {debug ' Inside PERF module, about to list running processes' prefix {write '---+ List of Running Processes' write '---## Using: ps -aef' } call writeCommand(replace($OSP,'-ef','-aef')) if hasOutput(true) write $TOP } toc '2:[[',getFile(),'][rda_report][System Performance Overview]]' } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE NET MODULE Determines the F command format. =cut elsif compare('eq',$MODULE,'NET') {# usage: ping [-dfnqrvR] [-c count] [-i wait] [-l preload] [-p pattern] # [-s packetsize] host # -R records the route var (undef,\$PING,\$NETSTAT) = @arg var $PING = 'ping -R -s %d -c 10 %s' var $NETSTAT = 'netstat' =head2 ifconfig - Interface Configuration Gets the network interface configuration. =cut collect OS:RCptx|NET() =head2 tcpip_settings - TCP/IP Settings Gets the TCP/IP settings. =cut var $fil = \ concat('/usr/conf/uts/symmetry.',${RDA.T_NODE},'/config.h') debug ' Inside NET module, getting network interface configuration (dynix/ptx)' if ?testFile('r',$fil) {report tcpip_settings var $cmd = concat('grep -i tcp ',quote($fil)) write '---+ TCP/IP Settings' write '---## Using: ',encode($cmd) write '' loop $lin (command($cmd)) {next match($lin,'tcpstatus') next match($lin,'tcp_bind_hash') next match($lin,'tcp_listen_hash') next match($lin,'tcp_queue_hash') write $lin } if status() {write 'Could not get tcp/ip settings.' write 'Probable permission problem.' } write '' if isCreated() toc '2:[[',getFile(),'][rda_report][TCP/IP Settings]]' } =head2 udp_settings - UDP Settings Gets the UDP settings. Because there is no known method of performing UDP on Sequent, this is skipped on Sequent systems. =cut # debug ' Inside NET module, getting udp settings (dynix/ptx)' # report udp_settings # if isCreated() # toc '2:[[',getFile(),'][rda_report][UDP Settings]]' } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE DEV MODULE Sets up the shared library path for Oracle Forms and Reports. =cut elsif compare('eq',$MODULE,'DEV') {# Setup the shared library path for Forms and Reports var (undef,\$ENV,\$PS_EF) = @arg if and($ora = ${SET.OFM.INIT.D_ORACLE_HOME/P},${CUR.W_SHLIB}) {loop $key (@{CUR.W_SHLIB}) var $ENV->{$key} = join(${RDA.T_SEPARATOR},\ concat($ora,'/network/jre11/lib/sparc/native_threads'),@{SYS.${VAR.key}}) } var $PS_EF = $OSP } #------------------------------------------------------------------------------ elsif compare('eq',$MODULE,'PS') {# Pass the command format of the ps variants import $PS_ARG,$PS_EF var $PS_ARG = $OSA var $PS_EF = $OSP } #------------------------------------------------------------------------------ # Return a ping command macro ping_command return concat('ping -R -s ',nvl($arg[1],56),' -c 10 ',quote($arg[0])) =head1 OPERATING SYSTEM COMMANDS USED The main operating system commands used in the data collection include the following: =over 16 =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =item o F =back =head1 SEE ALSO L =begin credits =over 10 =item RDA 4.30: Daniel Mortimer. =item RDA 8.06: Hiroki Ata. =item RDA 8.09: Torben Hein. =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