# MCftxk.ctl:245: Collects CMM and SP Information on Tx000 Servers # $Id: MCftxk.ctl,v 1.10 2015/02/25 19:07:31 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCftxk.ctl,v 1.10 2015/02/25 19:07:31 RDA Exp $ # # Change History # 20150225 PRA Improve quoting. =head1 NAME EXPLORER:MCftxk - Collects CMM and SP Information on Tx000 Servers =head1 DESCRIPTION This module collects remote information about Chassis Management Module (CMM) and Service Processor (SP) on Tx000 servers. =cut use Explorer use Mrc # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' var $WRN = ' * Links point to files that have been collected in their \ original format. Opening them directly in your browser can \ present risks. To prevent them, access the file outside the \ browser or use the link to save them and use an adequate \ viewer.' run EXPLORER:XPLRlib('Tx000') # 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_Tx000 section #------------------------------------------------------------------------------ section XPLR_Tx000 # Validate the execution context if !${B_GLOBAL:1} return call log_run('Processing FTXK sections ...') if !grepCommand(concat(${CMD.FIND:'find'},\ ' /devices -name \*explorer\* -print 2>&1'),':','f') return log_info('Module cannot be run on this platform') # Determine which ipmitool to run if $[XPL]->has_ipmitool var $IPMITOOL = last else return log_info('Ipmitool is not available') # Skip module when running on T3,T4,T5,T7,M5,M6 or M7 systems if ?nvl(testFile('x','/usr/bin/ilomconfig'),\ testFile('x','/usr/sbin/ilomconfig')) {var $exe = last debug ' Inside FTXK, validating system (can take time)' if grepCommand({cmd=>[$exe,'list system-summary 2>/dev/null'],\ inc=>4},\ '^\s*product name:\s*.*(m[567]|t[3457])(-|$)','fi') return log_info('Detected T3, T4, T5, T7, M5, M6, or M7 system ... \ module skipped') } # Determine the applicable commands var @cmd = (\ ['ipmitool_chassis_status', 'chassis status',\ '---++ System Chassis and Main Power Subsystem Status'],\ ['ipmitool_fru', 'fru',\ '---++ Field Replaceable Unit Information'],\ ['ipmitool_mc_info', 'mc info',\ '---++ Hardware Information'],\ ['ipmitool_sdr_elist', 'sdr elist',\ '---++ Sensor Data Records Contents'],\ ['ipmitool_sdr_list', 'sdr list',\ '---++ Sensor Data Records List'],\ ['ipmitool_sel_elist', 'sel elist',\ '---++ System Event Log Contents'],\ ['ipmitool_sensor', 'sensor',\ '---++ Sensor Information'],\ ['ipmitool_v_sdr', '-v sdr',\ '---++ Sensor Data Records Entries and Readings'],\ ['ipmitool_sunoem_led_get', 'sunoem led get',\ '---++ Read Led Status'],\ ['ipmitool_sunoem_sbled_get','sunoem sbled get',\ '---++ Alarm Indicators Status']) pretoc '2:CMM and SP on Tx000 Servers' =head2 ftxk - CMM and SP Data Collection Gathers the Chassis Management Module information or the Service Processor information for each specified CMM or SP, using the following commands: =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 macro do_collect {var ($hst,$typ,@cmd) = @arg import $ERR,$IPMITOOL,$PING,$TOC,$TOP keep $ERR,$IPMITOOL,$PING,$TOC,$TOP # Validate the input parameters debug ' Inside FTXK collection, validating ',$hst,' access' var $val = $hst if !?$hst = isHost($val,true) return log_info(concat('Bad ',$typ,' host name or IP "',$val,'".')) call command(sprintf($PING,$hst)) if status() return log_info(concat($typ,' ',$hst,' is not reachable')) $con = concat('-H ',$hst,' -U root -f %s') # Run report for each valid host debug ' Inside FTXK collection, generating report for ',$typ,' ',$hst report concat('ftxk_',$typ,'_',$hst) title '---+!! ',$typ,' ',$hst,' Information' title $TOC var $pwf = ["%s\012",'host',$hst,'root',\ concat('Enter root password for ',$typ,' ',$hst,': '),''] loop $rec (@cmd) {prefix {write $rec->[2] write '---## Using: ',encode($IPMITOOL),' ',encode($rec->[1]) } call collectCommand({\ inc=>4,\ nam=>join('/','Tx000',$hst,$rec->[0]),\ out=>{blk=>true,flt=>true,idx=>true,rpt=>${CUR.O_REPORT}},\ err=>{blk=>true,flt=>true,hdr=>$ERR,rpt=>${CUR.O_REPORT}}\ },{cmd=>[quote($IPMITOOL),$con,$rec->[1]],pwf=>$pwf}) if hasOutput(true) write $TOP } if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' call log_info(concat('Data gathering complete for ',$hst)) } # Validate and process all requests loop $set (@{MOD.FTXK.N_SET}) {if ?${MOD.FTXK.T_CMM_HOST_${VAR.set}} call do_collect(last,'CMM',@cmd) if ?${MOD.FTXK.T_SP_HOST_${VAR.set}} call do_collect(last,'SP',@cmd) } =head2 ftxk_snapshot - Snapshot Tool Data Collection Gathers the files produced by Explorer C tool when available and configured. =cut # Run Explorer snapshot tool when available if get_bin_tool('snapshot',true) {var ($pgm,$top) = last if ?testFile('fr',catFile($top,'data','snapshot.conf')) {var $box = cleanBox() call command(join(' ',quote($pgm),'-c',quote(lastFile()),'-o',quote($box),\ '2>/dev/null')) if status() call log_error('Command snapshot failed') else {# Collect all files generated by snapshot command report ftxk_snapshot prefix {write '---+ Snapshot Tool Results' write $WRN write '|*File*|' } loop $fil (grepDir($box,'\.+$','vn')) {if collectFile(concat('Tx000/',$fil),catFile($box,$fil),\ ['C',concat('snapshot (',$fil,')')]) write '|[[../',last,'][_blank][',$fil,']]|' } if isCreated(true) {write $TOP toc '3:[[',getFile(),'][rda_report][Snapshot Tool Results]]' } } } } =for stopwords Ipmitool =head2 ftxk_ipmitool - Ipmitool Version Gathers the F version using the C command. =cut debug ' Inside FTXK collection, getting ipmitool version' report ftxk_ipmitool call do_exec(\ ['Tx000/ipmitool_-v',\ $IPMITOOL,'-V',\ concat('---+ ',encode($IPMITOOL),' Version'),\ {out=>{nat=>true}}]) if isCreated() toc '3:[[',getFile(),'][rda_report][Ipmitool Version]]' # Adjust the table of content 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) var @lin = grepFile($fil,'^\s*#','v') while ?shift(@lin) {# Parse the first line of the set var ($flg,$hst,$pwd) = (true,split('\s+',trim(last),2)) if and(compare('ne',$hst,'NO_CMM'),$hst = isHost($hst,true)) {call push(@set,incr($set)) var ${RUN.EXPLORER.XPLR.FTXK.T_CMM_HOST_${VAR.set}} = $hst if ?$pwd call setPassword('host',$hst,'root',$pwd) var $flg = false } # Parse the second line of the set next !?shift(@lin) var ($hst,$pwd) = split('\s+',trim(last),2) if and(compare('ne',$hst,'NO_SP'),$hst = isHost($hst,true)) {if $flg call push(@set,incr($set)) var ${RUN.EXPLORER.XPLR.FTXK.T_SP_HOST_${VAR.set}} = $hst if ?$pwd call setPassword('host',$hst,'root',$pwd) } } # Save the parsing results if $set {var ${RUN.EXPLORER.XPLR.FTXK.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.FTXK.N_SET} = [@set] var ${RUN.EXPLORER.B_USE_FTXK} = true } else var ${RUN.EXPLORER.B_USE_FTXK} = $flg } } # Determine which input file must be parsed if and(defined($fil = ${ENV.EXP_TXINPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'Tx000input.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