# M245FTXK.def: Collects CMM and SP Information on Tx000 Servers # $Id: M245FTXK.def,v 1.4 2012/08/27 14:46:24 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/M245FTXK.def,v 1.4 2012/08/27 14:46:24 mschenke Exp $ # # Change History # 20120827 JGS Improve pattern for password file generation. =head1 NAME M245FTXK - 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 Tx00O 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]]' run XPLRlib('Tx000') # Get the ping syntax var $PING = check(${RDA.OS},'solaris','/usr/sbin/ping %s',\ 'linux', '/bin/ping -c 1 %s',\ 'cygwin', '/bin/ping %s 64 1') #------------------------------------------------------------------------------ # XPLR_Tx000 section #------------------------------------------------------------------------------ section XPLR_Tx000 # Validate the execution context if !${XPLR_GLOBAL:1} return call log_run('Processing FTXK sections ...') if !grepCommand('/usr/bin/find /devices -name \*explorer\* -print 2>&1',':','f') return log_info('Module cannot be run on this platform') # Check the patch level on Solaris 10 if and(${OS.solaris},expr('==',get_osv(),10)) {var ($ptc,$rev) = check(get_arc(),'sparc',list('119764','03'),\ 'i386', list('119765','03'),\ list()) if !check_patch($ptc,$rev) return log_info(concat(' Patch ',$ptc,'-',$rev,' required')) } # Determine which ipmitool to run if $[XPL]->has_ipmitool var $IPMITOOL = last else return log_info('Ipmitool is not available') # 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' if !match($hst,'^[\w\-\.\:]+$') return log_info(concat('The ',$typ,' host name or IP "',$hst,\ '"contains invalid characters')) 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 FTXK 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({nam=>join('/','Tx000',$hst,$rec->[0]),pwf=>$pwf,\ out=>{blk=>true,flt=>true,idx=>true,rpt=>${CUR.REPORT}},\ err=>{blk=>true,flt=>true,hdr=>$ERR,rpt=>${CUR.REPORT}}\ },join(' ',$IPMITOOL,$con,$rec->[1])) 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 (split('\|',${XPLR_FTXK_SET})) {if ?getSetting(concat('XPLR_FTXK_CMM_HOST_',$set)) call do_collect(last,'CMM',@cmd) if ?getSetting(concat('XPLR_FTXK_SP_HOST_',$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,'x'),'-c',quote(lastFile(),'x'),'-o',\ quote($box,'x'))) 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]]' } } } } # 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 compare('ne',$hst,'NO_CMM') {call push(@set,incr($set)) call setTempSetting(concat('XPLR_FTXK_CMM_HOST_',$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 compare('ne',$hst,'NO_SP') {if $flg call push(@set,incr($set)) call setTempSetting(concat('XPLR_FTXK_SP_HOST_',$set),$hst) if ?$pwd call setPassword('host',$hst,'root',$pwd) } } # Save the parsing results if $set {call setTempSetting('XPLR_FTXK_CFG',$fil) call setTempSetting('XPLR_FTXK_SET',join('|',@set)) call setTempSetting('xplr_ftxk_accept',true) } else call setTempSetting('xplr_ftxk_accept',$flg) } } # Determine which input file must be parsed if and(defined($fil = ${ENV.EXP_TXINPUT_CONFIG}),\ testFile('frs',catFile($fil))) call parse_input(lastFile(),true) else call parse_input(catFile(${XPLR_ETC},'Tx000input.txt'),false) =head1 SEE ALSO L, L =head1 COPYRIGHT NOTICE Copyright (c) 2002, 2012, 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