# OSwin32.def: Windows Specific Code # $Id: OSwin32.def,v 1.34 2008/02/06 11:13:48 mschenke Exp $ # ARCS: $Header: /home/cvs/repository/RDA_4/src/scripting/lib/modules/OSwin32.def,v 1.34 2008/02/06 11:13:48 mschenke Exp $ # # Change History # 20080206 DEM Align capitalization. =head1 NAME OSwin32 - Sub Module Specific to the Windows Operating System =cut # 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 exports Windows version registry settings. =cut if !$OSN {debug ' Export Windows version registry settings' var $reg = 'HKLM\Software\Microsoft\Windows NT\CurrentVersion' var $OSN = getRegValue($reg,'ProductName') var $OSV = getRegValue($reg,'CurrentVersion') var $OSP = getRegValue($reg,'CSDVersion','No Service Packs installed') keep $OSN,$OSV,$OSP } #------------------------------------------------------------------------------ =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. Also identifies the Windows system directory and the user domain. =cut elsif compare('eq',$MODULE,'END_report') {# Determine the operating system version and its bit size. if getEnv('SYSTEMROOT') var $sys = last else var ($sys) = command('echo %SystemRoot%') if testDir('d',catDir($sys,'SysWOW64')) var $bit = 64 else var $bit = 32 # Load the system settings write '|Platform|',$bit,'-bit ', $OSN,' |' write '|O/S Version|', $OSV,' |' write '|Service Pack|', $OSP,' |' write '|Windows Directory|', $sys,' |' write '|Domain|', getEnv('USERDOMAIN'),' |' # Detect virtualization technology var ($lin) = grepFile($arg[1],'^\|System Manufacturer','fi') if match($lin,'^\|[^\|]*\|\s*(Microsoft|VMware|XEN)',true) write '|Virtualization technology detected?|',last,' |' } =head2 system - System Information Gets the system information. It first attempts to use F, and when that is not available, it uses F on NT, and F otherwise. =cut elsif compare('eq',$MODULE,'END_system') {debug ' Inside END module, trying first systeminfo' prefix write '|*Item*|*Value*|' call writeSysinfo() if !hasOutput(true) {if match($OSN,'Microsoft Windows NT') {# Winmsd should be used on NT debug ' Inside END module, trying winmsd on NT' call writeWinmsd() } else {# MSInfo32 is replacing Winmsd in more recent environments debug ' Inside END module, using msinfo32(Summary)' call writeMsinfo('System Summary','SystemSummary') } } } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE OS MODULE =cut elsif compare('eq',$MODULE,'OS') {# Check how to workaround 32-bit access limitations on 64-bits Windows if getEnv('SYSTEMROOT') var $dir = last else var ($dir) = command('echo %SystemRoot%') if or(testFile('r',catFile(catDir($dir,'system32'),'mode.com')),\ testFile('r',catFile(catDir($dir,'Sysnative'),'mode.com'))) var ($flg,$cmd,$sys,$mod) = (false,'cmd',lastDir(),lastFile()) elsif grepDir(getSetting('RDA_CWD','.'),'^cmd\.exe$','fp') {var $cmd = quote(last,'x') var $sys = catDir($dir,'system32') var $mod = catFile($sys,'mode.com') var $flg = grepCommand(concat($cmd,' /c if exist "',$mod,'" echo 32to64'),\ '^32to64') if !$flg var ($cmd,$mod) = () } else var ($flg,$cmd,$mod) = (false) macro get_evt {var ($flg,$cmd,$sys,$evt) = @arg if testFile('r',catFile($sys,'config',$evt)) return lastFile() var $tmp = getTemp('evt','.evt') if $flg call system(concat($cmd,' /c copy ',\ catCommand($sys,'config',$evt),' ',\ quote($tmp,'x'),' >NUL 2>NUL')) return cond(testFile('r',$tmp),$tmp) } =head2 sys_config - Machine Configuration Displays the configuration information on NT. =head2 cpu_info - CPUs Displays the CPU information on W2000, XP, and W2003. =head2 memory_info - Memory Displays the memory configuration on W2000, XP, and W2003. =head2 display_info - Display Displays the display configuration on W2000, XP, and W2003. =head2 disk_info - Disk Drives Displays the disk drive configuration on W2000, XP, and W2003. =head2 protocol - Protocol Displays the protocol information on W2000, XP, and W2003. =head2 services - Services Displays the defined services on W2000, XP, and W2003. =head2 drivers - Drivers Displays the driver information on W2000, XP, and W2003. =head2 odbc_info - ODBC Displays the ODBC driver information on W2000, XP, and W2003. =cut if match($OSN,'Microsoft Windows NT') {# Winmsd should be used on NT debug ' Inside OS module, trying winmsd on NT' report sys_config call writeWinmsd() toc '2:[[',getFile(),'][rda_report][Machine Configuration]]' } else {# MSInfo32 is replacing Winmsd in more recent environments debug ' Inside OS module, getting CPU information' report cpu_info prefix write '---+ CPU Information' call writeRegistry('HKLM\Hardware\Description\System\CentralProcessor') if isCreated(true) toc '2:[[',getFile(),'][rda_report][CPUs]]' # MSInfo32 is replacing Winmsd in more recent environments debug ' Inside OS module, using msinfo32(ResourcesMemory)' report memory_info if writeMsinfo('Memory','ResourcesMemory') toc '2:[[',getFile(),'][rda_report][Memory]]' debug ' Inside OS module, using msinfo32(ComponentsDisplay)' report display_info if writeMsinfo('Display','ComponentsDisplay') toc '2:[[',getFile(),'][rda_report][Display]]' debug ' Inside OS module, using msinfo32(ComponentsStorageDrives/Disks)' report disk_info if writeMsinfo('Disk Drives','ComponentsStorageDrives',\ 'ComponentsStorageDisks') toc '2:[[',getFile(),'][rda_report][Disk Drives]]' debug ' Inside OS module, using msinfo32(ComponentsNetworkProtocol)' report protocol if writeMsinfo('Protocol','ComponentsNetworkProtocol') toc '2:[[',getFile(),'][rda_report][Protocol]]' debug ' Inside OS module, using msinfo32(SWEnvServices)' report services if writeMsinfo('Services','SWEnvServices') toc '2:[[',getFile(),'][rda_report][Services]]' debug ' Inside OS module, using msinfo32(SWEnvDrivers)' report drivers if writeMsinfo('Drivers','SWEnvDrivers') toc '2:[[',getFile(),'][rda_report][Drivers]]' debug ' Inside OS module, using msinfo32(Odbc)' report odbc_info if writeMsinfo('ODBC','Odbc') toc '2:[[',getFile(),'][rda_report][ODBC]]' } =head2 appevtlog - Application Event Log Displays the application event log information. For 64-bit systems, RDA collects this information only when it can access the event log file. =cut var $age = getSetting('OS_EVENT_AGE',7) pretoc '2:Event Logs' debug ' Inside OS module, getting application event log information' if get_evt($flg,$cmd,$sys,'AppEvent.evt') {var $fil = last report appevtlog write '---+!! Application Event Log Information' write ' * Events from ',$age,' last days%BR%' if !writeEvents($fil,'.',$age) write '**No events found**' toc '3:[[',getFile(),'][rda_report][Application]]' } if $flg call unlinkTemp('evt') =head2 secevtlog - Security Event Log Displays the security event log information. For 64-bit systems, RDA collects this information only when it can access the event log file. =cut debug ' Inside OS module, getting security event log information' if get_evt($flg,$cmd,$sys,'SecEvent.evt') {var $fil = last report secevtlog write '---+!! Security Event Log Information' write ' * Events from ',$age,' last days%BR%' if !writeEvents($fil,'.',$age) write '**No events found**' toc '3:[[',getFile(),'][rda_report][Security]]' } if $flg call unlinkTemp('evt') =head2 sysevtlog - System Event Log Displays the system event log information. For 64-bit systems, RDA collects this information only when it can access the event log file. =cut debug ' Inside OS module, getting system event log information' if get_evt($flg,$cmd,$sys,'SysEvent.evt') {var $fil = last report sysevtlog write '---+!! System Event Log Information' write ' * Events from ',$age,' last days%BR%' if !writeEvents($fil,'.',$age) write '**No events found**' toc '3:[[',getFile(),'][rda_report][System]]' } if $flg call unlinkTemp('evt') unpretoc =head2 firewall - Firewall Collects the firewall settings. =cut debug ' Inside OS module, getting firewall settings' if and(compare('eq',$OSN,'Microsoft Windows XP'),\ compare('eq',$OSP,'Service Pack 2')) {report firewall write '---+!! Firewall Settings' write $TOC call writeFirewall() toc '2:[[',getFile(),'][rda_report][Firewall]]' } =head2 mode_info - Mode Collects the modes. For 64-bit systems, RDA collects this information only when it can access C. =cut if $mod {debug ' Inside OS module, getting mode settings' report mode_info prefix write '---+!! Mode' call writeCommand(concat($cmd,' /c "',$mod,'"')) if isCreated(true) toc '2:[[',getFile(),'][rda_report][Mode]]' } =head2 misc_win_info - Miscellaneous Windows Information Collects the F file and the registry key value from C. =cut debug ' Inside OS module, getting miscellaneous Windows information' report misc_win_info write '---+!! Miscellaneous Windows Information' write $TOC var $fil = catFile(getEnv('SystemDrive','C:'),'boot.ini') write '---+ Boot Information' write '---## From ',$fil call writeFile($fil) write $TOP var $key = 'HKLM\System\CurrentControlSet\Control\Session Manager\SubSystems' write '---+ Windows Startup Control Entries' write '---## From ',$key,'\Windows' write "``",getRegValue($key,'Windows'),"``" write write $TOP toc '2:[[',getFile(),'][rda_report][Miscellaneous Windows Information]]' } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE PERF MODULE =cut elsif compare('eq',$MODULE,'PERF') { =head2 overview - Overview Under cygwin, it indicates the system uptime. Displays an overview of started services. Lists the running databases. =cut report overview write '---+!! Performance Overview' write $TOC toc '2:[[',getFile(),'][rda_report][Overview]]' debug ' Inside PERF module, about to execute uptime command' prefix write '---+ Uptime' call writeCommand('uptime') if hasOutput(true) write $TOP if loadCommand('net start 2>&1') {debug ' Inside PERF module, about to gather services counts' write '---+ Started Services Overview' var $cnt = grepLastFile('^\s+Oracle','i') write '|*Oracle Services*| ',$cnt,'|' var $cnt = grepLastFile('TNSListener','i') write '|*Listeners Services*| ',$cnt,'|' var $cnt = grepLastFile('^\s+OracleService','i') write '|*Database Services*| ',$cnt,'|' var $cnt = getLastLength() write '|*Total Services*| ',$cnt,'|' write $TOP debug ' Inside PERF module, about to determine running databases' prefix {write '---+ Running Databases List' write '' } var $pat = '^\s+OracleService' loop $svc (grepLastFile($pat,'i')) {write replace($svc,$pat) } if hasOutput(true) {write '' write $TOP } } } #------------------------------------------------------------------------------ =head1 CONTRIBUTION TO THE NET MODULE Determines the F command format. =cut elsif compare('eq',$MODULE,'NET') {# usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] # [-r count] [-s count] [[-j host-list] | [-k host-list]] # [-w timeout] target_name var (undef,\$PING,\$NETSTAT) = @arg var $PING = 'ping -l %d -n 10 %s' var $NETSTAT = 'netstat' =head2 ifconfig - Interface Configuration Gets the network interface configuration. =cut debug ' Inside NET module, getting network interface configuration' report ifconfig var $cmd = 'ipconfig /all' write '---+ Interface Configuration' write '---## Using: ',$cmd call writeCommand($cmd) write $TOP toc '2:[[',getFile(),'][rda_report][Interface Configuration]]' } #------------------------------------------------------------------------------ # Return a ping command macro ping_command return concat('ping -l ',nvl($arg[1],56),' -n 10 ',$arg[0]) =begin credits =over 10 =item RDA 4.1: Yoshimasa Watanabe. =item RDA 4.11: Kanti Jadia, Guido Tijskens. =back =end credits =head1 COPYRIGHT NOTICE Copyright (c) 2002-2008, 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