# MCb16c.ctl:240:Collects Sun Blade B1600 Server System Controller Information # $Id: MCb16c.ctl,v 1.8 2015/05/09 15:08:04 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCb16c.ctl,v 1.8 2015/05/09 15:08:04 RDA Exp $ # # Change History # 20150509 MSC Change handle management. =head1 NAME EXPLORER:MCb16c - Collects Sun Blade B1600 Server System Controller Information =head1 DESCRIPTION This module collects System Controller (SC) information in Sun Blade B1600 servers. =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('b1600extended') # 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_b16c section #------------------------------------------------------------------------------ section XPLR_b16c # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing B16C sections ...') pretoc '2:B1600 System Controller' =head2 Sun Blade B1600 System Controller Information Gathers the following System Controller 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 =item o C =item o C =item o C =back =cut # Treat all requests loop $set (@{MOD.B16C.N_SET}) {var $val = ${MOD.B16C.T_HOST_${VAR.set}} next !?$val # Validate the input parameters debug ' Inside B16C collection, validating ',$val,' access' if !?$hst = isHost($val,true) next log_info(concat('Bad B1600 SC host name or IP "',$val,'".')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Host ',$hst,' is not reachable.')) var $val = ${MOD.B16C.T_USER_${VAR.set}} if !?$usr = isUser($val,true) next log_info(concat('Bad B1600 SC user name "',$val,'".')) if !hasPassword('host',$hst,$usr) call setPassword('host',$hst,$usr,\ askPassword(concat('Enter ',$usr,' password for B1600 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,{chk=>'m/Advanced Lights Out Manager for Blade/',\ flg=>1,\ lim=>10,\ dis=>'logout'}) {# Report the login dialog in case of failure var $buf = $ctl->get_input call $buf->set_handle('eol',false) var $msg = $ctl->get_message report concat('b16c_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) } # Describe the Service Controller commands var @cmd = (\ '---+ System Controller',\ ['showdate.out',\ 'showdate',\ '---++ UTC date and time'],\ ['showlogs_-v_CH.out',\ 'showlogs -v CH',\ '---++ Events Logged'],\ ['usershow.out',\ 'usershow',\ '---++ Users Accounts'],\ ['showusers.out',\ 'showusers',\ '---++ Users Currently Logged'],\ ['showplatform_-v.out',\ 'showplatform -v',\ '---++ Operational Status'],\ ['showenvironment_-v.out',\ 'showenvironment -v',\ '---++ Environmental Sensors']) # Determine commands for non-empty blades loop $fru ($ctl->command('showplatform -v')) {var ($slt,$sta) = split('\s+',$fru,3) next !match($slt,'^(S\d{1,2}|SSC[0-1])$') next !match($sta,'^(OK|Faulty)$') call push(@cmd,\ concat('---+ Blade ',$slt),\ [concat('showfru_',$slt,'.out'),\ concat('showfru ',$slt),\ '---++ Information from FRUID Database'],\ [concat('showlogs_',$slt,'.out'),\ concat('showlogs ',$slt),\ '---++ Logged Events']) if match($slt,'^SSC[0-1]$') call push(@cmd,\ [concat('consolehistory_-v_',$slt,'@SWT.out'),\ concat('consolehistory -v ',$slt,'/SWT'),\ '---++ Switch Console Log']) else call push(@cmd,\ [concat('consolehistory_-v_',$slt,'.out'),\ concat('consolehistory -v ',$slt),\ '---++ Console Log']) } # Genererate the report debug ' Inside B16C collection, gathering ',$hst,' information' report concat('b16c_info_',$hst) title '---+!! Sun Blade B1600 Server System Controller' 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 b16c_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.B16C.F_CFG})) {debug ' Inside B16C collection, getting input file characteristics' report b16c_input 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 ($set,@set) = (0) loop $lin (grepFile($fil,'^\s*#','v')) {var ($hst,$usr,$pwd) = split('\s+',trim($lin),3) next !?$hst = isHost($hst,true) next !?$usr = isUser($usr,true) if ?$pwd call setPassword('host',$hst,$usr,$pwd) call push(@set,incr($set)) var ${RUN.EXPLORER.XPLR.B16C.T_HOST_${VAR.set}} = $hst var ${RUN.EXPLORER.XPLR.B16C.T_USER_${VAR.set}} = $usr } # Save the parsing results if $set {var ${RUN.EXPLORER.XPLR.B16C.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.B16C.N_SET} = [@set] var ${RUN.EXPLORER.B_USE_B16C} = true } else var ${RUN.EXPLORER.B_USE_B16C} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_B1600INPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'b1600input.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