# M244IPMR.def: Collects Remote IPMI Information # $Id: M244IPMR.def,v 1.3 2012/08/27 14:45:32 mschenke Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_4/src/scripting/lib/modules/M244IPMR.def,v 1.3 2012/08/27 14:45:32 mschenke Exp $ # # Change History # 20120827 JGS Improve pattern for password file generation. =head1 NAME M244IPMR - Collects Remote IPMI Information =head1 DESCRIPTION This module collects remote Intelligent Platform Management Interface (IPMI) information. =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('ipmiextended') # 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_ipmiextended section #------------------------------------------------------------------------------ section XPLR_ipmiextended # Validate the execution context if !${XPLR_GLOBAL:1} return call log_run('Processing IPMR sections ...') # 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')) } # Locate ipmitool 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 Status'],\ ['ipmitool_fru', 'fru',\ '---++ Field Replaceable Unit Information'],\ ['ipmitool_pef_status', 'pef status',\ '---++ Platform Event Filtering Status'],\ ['ipmitool_pef_list', 'pef list',\ '---++ Platform Event Filtering Entries'],\ ['ipmitool_sel_info', 'sel info',\ '---++ System Event Log'],\ ['ipmitool_sel_elist', 'sel elist',\ '---++ System Event Log Contents'],\ ['ipmitool_-v_sel_elist', '-v sel elist',\ '---++ System Event Log Contents verbose'],\ ['ipmitool_sdr_list_all_info','sdr list all info',\ '---++ Sensor Data Repository']) pretoc '2:IPMI Remote' =head2 IPMI Remote Data Collection Gathers the IMPI remote information 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 =back =cut # Process and validate input loop $set (split('\|',${XPLR_IPMR_SET})) {var $hst = getSetting(concat('XPLR_IPMR_HOST_',$set)) var $prt = getSetting(concat('XPLR_IPMR_PORT_',$set)) var $usr = getSetting(concat('XPLR_IPMR_USER_',$set)) next !?$hst # Validate the input parameters debug ' Inside IPMR collection, validating ',$hst,' access' if !match($hst,'^[\w\-\.\:]+$') next log_info(concat('The host name or IP "',$hst,\ '"contains invalid characters')) call command(sprintf($PING,$hst)) if status() next log_info(concat('Host ',$hst,' is not reachable')) if !match($prt,'^[\d]+$') next log_info('Invalid port value') if or(expr('>',$prt,65535),expr('<',$prt,0)) next log_info('Invalid port number') if !match($usr,'^[\w\-\.]+$') next log_info('The user name contains invalid characters') var $con = concat('-H ',$hst,' -p ',$prt,' -U ',$usr,' -f %s -I lan') # Run report for each valid host debug ' Inside IPMR collection, generating report for ',$hst report concat('ipmr_',$hst) title '---+!! ',$hst,' Information' title $TOC var $pwf = ["%s\012",'host',$hst,$usr,\ concat('Enter ',$usr,' password for ILOM ',$hst,': '),''] loop $rec (@cmd) {prefix {write $rec->[2] write '---## Using: ',encode($IPMITOOL),' -I lan ',encode($rec->[1]) } call collectCommand({nam=>join('/','ipmi',$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)) } # 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) loop $lin (grepFile($fil,'^\s*#','v')) {var ($hst,$prt,$usr,$pwd) = split('\s+',trim($lin),4) next !?$hst if ?$pwd call setPassword('host',$hst,$usr,$pwd) if !?$prt var $prt = 623 call push(@set,incr($set)) call setTempSetting(concat('XPLR_IPMR_HOST_',$set),$hst) call setTempSetting(concat('XPLR_IPMR_PORT_',$set),$prt) call setTempSetting(concat('XPLR_IPMR_USER_',$set),$usr) } # Save the parsing results if $set {call setTempSetting('XPLR_IPMR_CFG',$fil) call setTempSetting('XPLR_IPMR_SET',join('|',@set)) call setTempSetting('xplr_ipmi_accept',true) } else call setTempSetting('xplr_ipmr_accept',$flg) } } # Determine which input file must be parsed if and(defined($fil = ${ENV.EXP_IPMIINPUT_CONFIG}),\ testFile('frs',catFile($fil))) call parse_input(lastFile(),true) else call parse_input(catFile(${XPLR_ETC},'ipmiinput.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