# OSvms.def: VMS Specific Code
# $Id: OSvms.def,v 1.26 2009/02/06 18:22:53 mschenke Exp $
# ARCS: $Header: /u02/webapps/workbench/cvs/RDA_4/src/scripting/lib/modules/OSvms.def,v 1.26 2009/02/06 18:22:53 mschenke Exp $
#
# Change History
# 20090206 DEM Encode file names.
=head1 NAME
OSvms - Sub Module Specific to the VMS 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 determines the 'ps' command format.
=cut
if !$OS
{keep $OS,$OSA,$OSP
var $OS = true
# Determine the ps command format
var $OSP = 'show system'
var $OSA = undef
}
#------------------------------------------------------------------------------
=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')
{#Determine for the end report the operating system version and its bit size.
debug ' Inside END module, determining OS characteristics'
write '|Platform|64-bit ',uname('s'),'|'
write '|O/S Version|',uname('v'),'|'
}
=head2 system - System Information
Extracts the system information such as CPU, memory, and swap information.
=cut
elsif compare('eq',$MODULE,'END_system')
{prefix
write '|*Item*|*Value*|'
debug ' Inside END module, getting CPU information (vms)'
var $cnt = 0
var ($cpu) = command('write sys$output f$getsyi("ARCH_NAME")')
loop $lin (grepCommand('show cpu/full','^\s+Speed\.+:\s'))
{incr $cnt
var $mhz[$cnt] = field('Speed\.+:\s*',1,$lin)
}
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,\
$cpu,$mhz[$off])
}
write '|Processor(s)|',$str,'|'
}
write '|Active Processors|',\
command('write sys$output f$getsyi("ACTIVECPU_CNT")'),'|'
debug ' Inside END module, getting system model (vms)'
write '|System Model|',command('write sys$output f$getsyi("HW_NAME")'),'|'
debug ' Inside END module, getting memory information (vms)'
var $mem = 0
loop $lin (grepCommand('show mem/physical/unit=byte','Main Memory'))
{if match($lin,'\s\((\w+)\)\s+([\d\.]+)\s+([\d\.]+)\s')
{var ($unt,$tot,$fre) = (last)
write sprintf('|Total Physical Memory|%s %s|',$tot,$unt)
write sprintf('|Available Physical Memory|%s %s|',$fre,$unt)
}
}
debug ' Inside END module, getting swap and page information (vms)'
if loadCommand('show mem/files/unit=byte')
{macro dsp_usage
{var ($typ,$unt,$tot,$fre) = @arg
if $unt
{write sprintf('|%s: Max size|%s %s|',$typ,$tot,$unt)
write sprintf('|%s: Available|%s %s|',$typ,$fre,$unt)
}
}
var ($tot,$fre,$typ,$unt) = (0,0)
loop $lin (getLines())
{if match($lin,'^\s+\((\w+)\)\s+[\d\.]+\s+([\d\.]+)\s+([\d\.]+)')
{var ($unt,$nb1,$nb2) = (last)
incr $tot,$nb1
incr $fre,$nb2
}
elsif match($lin,'^Swap File Usage ')
{call dsp_usage($typ,$unt,$tot,$fre)
var ($typ,$cnt,$tot,$fre,$unt) = ('Swap',0,0)
}
elsif match($lin,'^Paging File Usage ')
{call dsp_usage($typ,$unt,$tot,$fre)
var ($typ,$cnt,$tot,$fre,$unt) = ('Paging',0,0)
}
}
call dsp_usage($typ,$unt,$tot,$fre)
}
if !hasOutput(true)
write 'Information not available'
}
#------------------------------------------------------------------------------
=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 (vms)'
report cpu_info
var $cmd = 'show cpu/ful'
write '---+ CPU Information'
write '---## Using: ',encode($cmd)
call writeCommand($cmd)
toc '2:[[',getFile(),'][rda_report][CPUs]]'
=head2 memory_info - Memory
Gets information about the physical memory.
=cut
debug ' Inside OS module, about physical memory (vms)'
report memory_info
var $cmd = 'show mem/physical'
write '---+ Physical Memory Installed'
write '---## Using: ',encode($cmd)
call writeCommand($cmd)
toc '2:[[',getFile(),'][rda_report][Memory]]'
=head2 disk_info - Disk Drives
Gets information about the disks.
=cut
debug ' Inside OS module, about disks (vms)'
report disk_info
write '---+!! Disk Information'
write $TOC
write '---+ Disk Mounts / Disk Free'
call writeCommand('show dev d/mount/unit=byte')
write $TOP
write '---+ Swap'
call writeCommand('show mem/files/unit=byte')
write $TOP
toc '2:[[',getFile(),'][rda_report][Disk Drives]]'
=head2 ntpstatus - NTP Status
Collects NTP status when NTP is running and accessible.
=cut
debug ' Inside OS module, getting NTP Status'
if createTemp('VMS','.com')
{var $pgm = last
call writeTemp('VMS','$ @sys$manager:tcpip$define_commands')
call writeTemp('VMS','$ NTPQ -p')
call closeTemp('VMS')
report ntpstatus
prefix
{write '---+ NTP Status'
write '---## Using: NTPQ -p'
}
var $hdr = true
if loadCommand(concat('@',$pgm))
{loop $lin (getLines())
{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),' |'
}
}
call unlinkTemp('COM')
}
if isCreated(true)
toc '2:[[',getFile(),'][rda_report][NTP Status]]'
=head2 patches - Operating System Patches
Lists the operating system patches installed.
=cut
debug ' Inside OS module, getting operating system patches'
report patches
var $cmd = 'product show history'
write '---+ Operating System Patches Information'
write '---## Using: ',encode($cmd)
call writeCommand($cmd)
toc '2:[[',getFile(),'][rda_report][Operating System Patches]]'
=head2 sysdef - System/Kernel Settings
Gets the system/kernel settings.
=cut
debug ' Inside OS module, getting system/kernel settings'
report sysdef
write '---+!! System/Kernel Settings'
write $TOC
loop $cmd ('mc sysman parameter show /all',\
'mc sysman parameter show /special',\
'type sys$system:modparams.dat')
{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
debug ' Inside OS module, getting system error log data'
report system_error_log
write '---+!! System Error Log Data'
write $TOC
var $cmd = 'type/tail=1000 SYS$MANAGER:OPERATOR.LOG'
write '---++ Using: ',encode($cmd)
call writeCommand($cmd)
write $TOP
toc '2:[[',getFile(),'][rda_report][System Error Log]]'
=head2 cluster - Cluster
Collects VMS cluster details.
=cut
debug ' Inside OS module, getting cluster details'
report cluster
write '---+ Cluster Details'
var ($flg) = command('write sys$output f$getsyi("CLUSTER_MEMBER")')
if match($flg,'TRUE',true)
{if createTemp('VMS','.com')
{var $pgm = last
call writeTemp('VMS','$ context=""')
call writeTemp('VMS','$loop_start:')
call writeTemp('VMS','$ cluster_id = f$csid(CONTEXT)')
call writeTemp('VMS','$ if cluster_id .eqs. "" then goto loop_end')
call writeTemp('VMS',"$ write sys$output \042\
|''f$getsyi(\042NODENAME\042,,cluster_id)'\
| ''f$getsyi(\042NODE_NUMBER\042,,cluster_id)'\
| ''f$getsyi(\042NODE_QUORUM\042,,cluster_id)'\
| ''f$getsyi(\042NODE_VOTES\042,,cluster_id)'|")
call writeTemp('VMS','$ goto loop_start')
call writeTemp('VMS','$loop_end:')
call closeTemp('VMS')
prefix
write '|*Node Name*| *Node Number*| *Node Quorum*| *Node Votes*|'
if loadCommand(concat('@',$pgm))
{loop $lin (getLines())
write $lin
}
if !hasOutput(true)
write '**Cluster script error**'
call unlinkTemp('COM')
}
}
else
write '**Not a member of a cluster**'
toc '2:[[',getFile(),'][rda_report][Cluster]]'
=pod
Identifies useful platform-related links.
=cut
var \@LINKS = $arg[1]
var @LINKS = ('http://h71000.www7.hp.com/',\
'http://h71000.www7.hp.com/serv_support.html',\
'http://h71000.www7.hp.com/doc/')
}
#------------------------------------------------------------------------------
=head1 CONTRIBUTION TO THE PERF MODULE
=cut
elsif compare('eq',$MODULE,'PERF')
{# Produce the performance report
report perf_over
write '---+!! Performance Overview'
write $TOC
macro write_page
{var ($cmd) = @arg
if loadCommand($cmd)
{var $flg = false
prefix
{write '