# MCn12c.ctl:240: Collects Extended Netra [V]1280 System Controller Information # $Id: MCn12c.ctl,v 1.8 2015/05/09 15:08:05 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/EXPLORER/MCn12c.ctl,v 1.8 2015/05/09 15:08:05 RDA Exp $ # # Change History # 20150509 MSC Change handle management. =head1 NAME EXPLORER:MCn12c - Collects Netra 1280 and V1280 System Controllers Information =head1 DESCRIPTION This module collects extended Netra 1280 and V1280 System Controllers information. =cut use Buffer use Mrc use Remote use Telnet # Initialization var $VALIDATE = true keep $VALIDATE section begin var $ERR = '---## Associated Errors' var $TOC = '%TOC%' var $TOP = '[[#Top][Back to top]]' var $USR = '[xplr:netra]' run EXPLORER:XPLRlib('1280extended') # 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_n12c section #------------------------------------------------------------------------------ section XPLR_n12c # Defined the macro to handle connection dialog macro connect {var ($ctl,$hst,$usr) = @arg # Wait for an initial prompt if !$ctl->choose({\ hit => true,\ lim => 120,\ pat => 'm/lom>$|#\s$|ok\s$|Connected\.(\012|\015|\015\012)$|\ force logout of other user \? \(y\/n\)[\s]*$/i',\ plf => true,\ usr => $usr}) return concat('Unable to collect data from ',$hst) var $hit = $ctl->get_hit var $buf = new('Buffer','S') call $buf->set_handle('eol',false) if match($hit,'force logout',true) {# Connection already established, send n option and disconnect call $ctl->collect($buf,{cmd => "n",\ lim => 2,\ pat => 'm/$/'}) call $buf->close return concat('Another user is already connected to ',$hst) } if match($hit,'Connected\.\015$',true) var $hit = cond($ret = $ctl->collect($buf,{\ cmd => "\012",\ fix => true,\ hit => true,\ pat => 'm/lom>$|#\s$|ok\s$/i'}),undef,$ctl->get_hit) # Try to switch to Solaris console if match($hit,'ok\s$') var $hit = cond($ret = $ctl->collect($buf,{\ cmd => "go\012\012",\ fix => true,\ hit => true,\ pat => 'm/lom>$|#\s$|ok\s$/i'}),undef,$ctl->get_hit) # Try to switch from Solaris console to LOM console if match($hit,'^#\s$') {# Obtain the escape sequence call $buf->truncate call $ctl->collect($buf,{cln => true,\ cmd => '/usr/sbin/lom -c',\ hit => true,\ pat => 'm/#\s$/',\ skp => true}) var $esc = value($buf->grep('serial escape sequence=','if')) # Send the escape sequence var $hit = cond($ret = $ctl->collect($buf,{\ cmd => nvl($esc,'#.'),\ fix => true,\ hit => true,\ pat => 'm/#\s$|lom>$/'}),undef,$ctl->get_hit) } call $buf->close # Detect a collection issue if !?$hit return concat('Unable to collect data from ',$hst) # Return the connection result return cond(match($hit,'lom>$'),'',\ concat('Unable to enter the LOM console (last prompt:',$hit,')')) } # Validate the execution context if !${B_GLOBAL:true} return call log_run('Processing N12C sections ...') pretoc '2:Netra 1280 and V1280 System Controllers' =head2 Extended Netra 1280 and V1280 System Controllers Information Gathers the following Netra 1280 and V1280 System Controllers commands through SSH (requires a working Java environment) or 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 =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 =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 ${BOARD} represents each online board returned by the C command. =cut loop $itm (@{MOD.N12C.T_HOST}) {var ($ses,@cmd,@out) = () # Validate the input parameters debug ' Inside N12C collection, validating ',$itm,' access' if !?$hst = isHost($itm,true) next log_info(concat('Bad SC host name or IP "',$itm,'".')) 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 password for SC ',$hst,': '),'')) # Connect to the service controller var $ctl = new('Telnet',bin=>true,dis=>'logout',lim=>120,hst=>$hst) if !$ctl->open {# Try SSH when not possible with Telnet var $ctl = addRemoteSession('SC',$hst,$USR) if and($ctl->set_type('da'),$ctl->set_type('jsch')) next log_warning(concat('Unable to connect to ',$hst,' using Telnet or SSH')) if !$ctl->open next log_warning($ctl->get_message) } if connect($ctl,$hst,$USR) next log_warning(last) # Collect boards and system controller information for later use var $buf = new('Buffer','S') call $buf->set_handle('eol',false) call $ctl->collect($buf,{\ cln => true,\ cmd => 'showboards -e',\ max => 60,\ nxt => ['m/^.*?--pause--.*?continue.*?$/i',"\012"],\ pat => 'm/lom>[\x20]?$/',\ skp => true}) var @brd = $buf->get_lines(true) call $buf->truncate call $ctl->collect($buf,{\ cln => true,\ cmd => 'showsc -v',\ max => 60,\ nxt => ['m/^.*?--pause--.*?continue.*?$/i',"\012"],\ pat => 'm/lom>[\x20]?$/',\ skp => true}) var @scv = $buf->get_lines(true) call $buf->close # Prepare the Netra 1280 and V1280 System Controller commands call push(@cmd,\ ['showresetstate_-v.out',\ 'showresetstate -v',\ '---+ All CPU Registers Contents After an Abnormal Solaris Reset'],\ ['inventory.out',\ 'inventory',\ '---+ All FRU SEPROM Contents'],\ ['showcodusage_-v.out',\ 'showcodusage -v',\ '---+ Capacity on Demand (COD) Resources Usage Statistics'],\ ['showcodlicense_-v.out',\ 'showcodlicense -v',\ '---+ Capacity on Demand (COD) RTU Licenses Stored in COD License \ Database'],\ ['history.out',\ 'history',\ '---+ Command history along with date and time stamps'],\ ['showescape.out',\ 'showescape',\ '---+ Current escape sequence'],\ ['showdate_-v.out',\ 'showdate -v',\ '---+ Date and Time'],\ ['showenvironment_-v.out',\ 'showenvironment -v',\ '---+ Environmental Status'],\ ['showerrorbuffer.out',\ 'showerrorbuffer',\ '---+ Error Buffer Contents']) var $ver = field(':?\s+',2,grep(@scv,'ScApp version','f')) if compare('valid',$ver,'5.20.2') call push(@cmd,\ ['showchs_-b.out',\ 'showchs -b',\ '---+ Faulty Components']) call push(@cmd,\ ['showmodel.out',\ 'showmodel',\ '---+ Platform Model'],\ ['showeventreporting.out',\ 'showeventreporting',\ '---+ Settings Applied to Event Reporting and Messages'],\ ['showalarm_1.out',\ 'showalarm 1',\ '---+ State of the Alarm 1 LED and Relay'],\ ['showalarm_2.out',\ 'showalarm 2',\ '---+ State of the Alarm 2 LED and Relay'],\ ['showalarm_system.out',\ 'showalarm system',\ '---+ State of System Alarm Relay and LED'],\ ['showfault.out',\ 'showfault',\ '---+ State of the System Fault LED'],\ ['showlocator.out',\ 'showlocator',\ '---+ State of the System Locator LED']) # Collect boards information loop $brd (@brd) {next match(field('\s+',0,$brd),'^FT0$|^PS0$|^PS1$|^PS2$|^PS3$|^SSC1$') next !match($brd,'^(.*?)\s+.*On') var ($brd) = last call push(@cmd,\ [concat('showcomponent_-v_',replace($brd,'\/','@',true),'.out'),\ concat('showcomponent -v ',$brd),\ concat('---+ System Board ',$brd,' Status and POST Information')]) } call push(@cmd,\ ['showboards_-v_-p_cpu.out',\ 'showboards -v -p cpu',\ '---+ System Boards CPU Information'],\ ['showboards_-p_proms.out',\ 'showboards -p proms',\ '---+ System Boards Firmware Version'],\ ['showboards_-v_-p_io.out',\ 'showboards -v -p io',\ '---+ System Boards I/O Information'],\ ['showboards_-v.out',\ 'showboards -v',\ '---+ System Boards Information'],\ ['showboards_-v_-p_memory.out',\ 'showboards -v -p memory',\ '---+ System Boards Memory Information'],\ ['showboards_-v_-p_board.out',\ 'showboards -v -p board',\ '---+ System Boards Status'],\ ['showboards_-v_-p_version.out',\ 'showboards -v -p version',\ '---+ System Boards Version Information'],\ ['showlogs_-v.out',\ 'showlogs -v',\ '---+ System Controller Logged Events'],\ ['shownetwork_-v.out',\ 'shownetwork -v',\ '---+ System Controller Network Settings and MAC Addresses'],\ ['showhostname.out',\ 'showhostname',\ '---+ System Hostname']) # Genererate the report debug ' Inside N12C collection, gathering ',$hst,' information (can take time)' report concat('n12c_info_',$hst) title '---+!! Netra 1280 and V1280 System Controller' title '---## ',$hst,' Information' title $TOC loop $rec (@cmd) {if ref($rec) {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},{\ cln => true,\ cmd => $rec->[1],\ max => 60,\ nxt => ['m/^.*?--pause--.*?continue.*?$/i',"\012"],\ pat => 'm/lom>[\x20]?$/',\ skp => true}) call log_warning($ctl->get_message) if hasOutput(true) {call endBlock() write $TOP } } else write $rec } # Close the connection call $ctl->close # Add boards information previously collected call do_exec(\ {cmd => 'ARRAY',\ det => 'showboards -e',\ nam => concat('sc/',$hst,'/showboards_-e.out'),\ tbl => \@brd,\ ttl => '---+ System Boards Status (Including Empty Slots)'}) # Add system controller information previously collected call do_exec(\ {cmd => 'ARRAY',\ det => 'showsc -v',\ nam => concat('sc/',$hst,'/showsc_-v.out'),\ tbl => \@scv,\ ttl => '---+ System Controller Status, Version and Uptime'}) if isCreated(true) toc '3:[[',getFile(),'][rda_report][',$hst,' Information]]' } =head2 n12c_input - Input File Lists the characteristics of the specified input file. =cut if ?testFile('r',catFile(${MOD.N12C.F_CFG})) {debug ' Inside N12C collection, getting input file characteristics' report n12c_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 import $USR 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,$USR,$pwd) call push(@hst,$hst) } # Save the parsing results if @hst {var ${RUN.EXPLORER.XPLR.N12C.F_CFG} = $fil var ${RUN.EXPLORER.XPLR.N12C.T_HOST} = [@hst] var ${RUN.EXPLORER.B_USE_N12C} = true } else var ${RUN.EXPLORER.B_USE_N12C} = $flg } } # Parse the input file if and(defined($fil = ${ENV.EXP_LW8INPUT_CONFIG}),\ defined(testFile('frs',catFile($fil)))) call parse_input(lastTestFile(),true) elsif ?testFile('frs',catFile(${RUN.EXPLORER.D_ETC},'1280input.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