# MCrscx.ctl:240: Collects Remote System Control (RSC) Information # $Id: MCrscx.ctl,v 1.6 2015/05/09 15:08:05 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCrscx.ctl,v 1.6 2015/05/09 15:08:05 RDA Exp $ # # Change History # 20150509 MSC Change handle management. =head1 NAME EXPLORER:MCrscx - Collects Remote System Control (RSC) Information =head1 DESCRIPTION This module collects Remote System Control (RSC) information. =cut use Buffer use Mrc use Telnet # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' run EXPLORER:XPLRlib('srscextended') # Get the ping syntax var $PING = check(${RDA.T_OS},\ 'solaris',concat(${CMD.PING:'ping'},' %s'),\ 'linux', concat(${CMD.PING:'ping'},' -c 1 %s'),\ 'cygwin', concat(${CMD.PING:'ping'},' %s 64 1')) #------------------------------------------------------------------------------ # XPLR_rscx section #------------------------------------------------------------------------------ section XPLR_rscx # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing RSCX sections ...') pretoc '2:Remote System Control (RSC)' =head2 Remote System Control Information Gathers Remote System Control (RSC) information using the following commands: =over 2 =item o C =back In addition, gathers Remote System Control (RSC) information from remote host using the following commands through telnet: =over 2 =item o C =item o C =item o C =item o C =item o C =item o C =item o C =back =cut # Treat all requests var $usr = 'root' loop $val (@{MOD.RSCX.T_HOST}) {next !?$val # Validate the input parameters debug ' Inside RSCX collection, validating ',$val,' access' if !?$hst = isHost($val,true) next log_info(concat('Bad Remote SC host name or IP "',$val,'".')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Host ',$hst,' is not reachable.')) if !hasPassword('host',$hst,$usr) call setPassword('host',$hst,$usr,\ askPassword(concat('Enter ',$usr,' password for Remote SC ',$hst,': '),'')) # Connect to the System Controller var $ctl = new('Telnet',hst=>$hst) if !?$ctl->open next log_warning($ctl->get_info('msg')) if !?$ctl->login($usr,{dis=>'logout',\ flg=>1,\ lim=>10,\ pat=>'m/rsc>/'}) {# Check for valid prompt when the last line contains an alert message var $buf = $ctl->get_input call $buf->set_handle('eol',false) var ($msg,$pre) = reverse($buf->get_lines(true)) if !and(match($msg,'^SC Alert:'),match($pre,'rsc>',true)) {# Report the login dialog in case of failure var $msg = $ctl->get_message report concat('rscx_info_',$hst) prefix {title '---++ ',$hst,' Login Dialog' call addBlock('E','D',concat('sc/',$hst,'/','connect_dialog.out')) } call writeFile($buf,[]) write 'Return code: ',$msg if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Connect Dialog]]' call $buf->close call $ctl->close next log_warning($msg) } # Clear the input buffer and perform the collection call $buf->close call $ctl->empty_buffer } # Describe the Remote Service Controller commands var @cmd = (\ ['show.out',\ 'show',\ '---++ Configuration Variables'],\ ['consolehistory.out',\ 'consolehistory',\ '---++ Console Messages Logged in RSC Buffers'],\ ['showenvironment_-v.out',\ 'showenvironment -v',\ '---++ Environmental Sensors'],\ ['loghistory.out',\ 'loghistory',\ '---++ Events Logged in RSC Event Buffer'],\ ['version_-v.out',\ 'version -v',\ '---++ Firmware Version'],\ ['usershow.out',\ 'usershow',\ '---++ Users Accounts'],\ ['showdate.out',\ 'showdate',\ '---++ UTC date and time']) # Genererate the report debug ' Inside RSCX collection, gathering ',$hst,' information' report concat('rscx_info_',$hst) title '---+!! Remote System Control (RSC)' title '---## ',$hst,' Information' title $TOC loop $rec (@cmd) {if !ref($rec) write $rec else {prefix {write $rec->[2] write '---## Using: ',encode($rec->[1]) call beginBlock(true) call addBlock('E','D',concat('sc/',$hst,'/',$rec->[0])) } if $ctl->collect(${CUR.O_REPORT},{cmd=>$rec->[1]}) call log_warning($ctl->get_info('msg')) if hasOutput(true) {call endBlock() write $TOP } } } if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' # Close the connection call $ctl->quit } =head2 rscx_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.RSCX.F_CFG})) {debug ' Inside RSCX collection, getting input file characteristics' report rscx_input title '---+ Input File Details' call do_exec(\ [concat('sc/ls_-l_',replace(lastFile(),'\/','@',true)),\ ${CMD.LS:'ls'},concat('-l ',quote(lastFile())),\ '---+ Explorer Input File']) if isCreated() toc '3:[[',getFile(),'][rda_report][Input File]]' } unpretoc #------------------------------------------------------------------------------ # Input file conversion section #------------------------------------------------------------------------------ section input # Define the input file parser macro macro parse_input {var ($fil,$flg) = @arg var @sta = getStat($fil) if !expr('&',$sta[2],077) {# Parse the input file var @hst = () loop $lin (grepFile($fil,'^\s*#','v')) {var ($hst,$pwd) = split('\s+',trim($lin),2) next !?$hst = isHost($hst,true) if ?$pwd call setPassword('host',$hst,'root',$pwd) call push(@hst,$hst) } # Save the parsing results if @hst {var ${RUN.EXPLORER.XPLR.RSCX.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.RSCX.T_HOST} = [@hst] var ${RUN.EXPLORER.B_USE_RSCX} = true } else var ${RUN.EXPLORER.B_USE_RSCX} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_SRSCINPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'srscinput.txt')) call parse_input(lastTestFile(),false) =head1 SEE ALSO L, L =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