# TMexl.ctl: Tests Connection to Oracle Exalogic Nodes # $Id: TMexl.ctl,v 1.7 2015/05/29 07:48:00 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/OFM/TMexl.ctl,v 1.7 2015/05/29 07:48:00 RDA Exp $ # # Change History # 20150527 KRA Improve the documentation. =head1 NAME OFM:TMexl - Tests Connection to Oracle Exalogic Nodes =head1 DESCRIPTION This test module tests the connection to Oracle Exalogic nodes and can be used in two ways: =over 3 =item a) Runs interactively. It requests the user to input the user for connecting to the remote nodes. -vT exl -v run exl =item b) Runs from the command line. You can specify the user for connecting to the remote nodes, using the following syntax: -vT exl:userid -v run exl userid =back It extracts the node access information by executing the F command. This test module executes the following tests: =over 2 =cut use Remote section tool call unshift(@{CUR.W_NEXT},'test') section test echo tput('bold'),'Processing Oracle Exalogic Node tool ...',tput('off') if $arg[0] var $USERID = nvl(isUser(last,true),'oracle') else {call requestInput('TMexl') var $USERID = nvl(isUser(${RUN.REQUEST.T_USERID},true),'oracle') } =item o Tests which commands are available from the C environment variable. =cut echo "\012Command Availability:" loop $cmd ('rcp','remsh','rsh','scp','ssh','ssh-add','ssh-agent') echo sprintf(' %-12s %s',$cmd,nvl(findCommand($cmd),'(Not found)')) =item o Checks the existence and the permissions of the F<.ssh> directory. =item o Checks the existence and the permissions of a DSA or RSA key file. =cut if or(isUnix(),isCygwin()) {var $dir = catDir(getEnv('HOME'),'.ssh') echo "\012.ssh Directory:" if ?testDir('e',$dir) {var @sta = getStat($dir) echo ' File permissions of .ssh directory are: ',\ sprintf('%03o',expr('&',$sta[2],511)) if expr('&',$sta[2],63) echo ' Other users than the owner have permissions on it' var $flg = true if ?testFile('f',catFile($dir,'id_dsa')) {var @sta = getStat(lastFile()) if expr('&',$sta[2],7) echo ' DSA key file is ignored due to invalid permissions: ',\ sprintf('%03o',expr('&',$sta[2],511)) else var $flg= false } if ?testFile('s',catFile($dir,'id_rsa')) {var @sta = getStat(lastFile()) if expr('&',$sta[2],7) echo ' RSA key file is ignored due to invalid permissions: ',\ sprintf('%03o',expr('&',$sta[2],511)) else var $flg= false } if $flg echo ' No DSA or RSA key file found' } else echo ' ',$dir,' directory does not exist' } =item o Tests if an authentication agent is configured. When possible, it checks if identities have been added. =cut macro chk_env {var ($key,$flg) = @arg if $val = getEnv($key,$flg) {import $TTL if ?$TTL {echo $TTL var $TTL = undef } echo ' ',$key,'=',$val } } var $TTL = "\012Check if an authentication agent is running" call chk_env('SSH_AGENT_PID') call chk_env('SSH_AUTH_SOCK') var $agt = $TTL if !$agt {echo "\012Agent identities:" loop $lin (command('ssh-add -l')) echo ' ',$lin } =item o Tests which drivers are available for the remote connection. =cut echo "\012Driver Availability:" loop $typ ('da','jsch','ssh') echo sprintf(' %4s %s',$typ,cond($[REM]->can_use($typ),'Available','-')) =item o Checks the access to the F file. =cut if !loadCommand('/usr/sbin/ibnodes') {echo "\012Unable to get the node information by executing /usr/sbin/ibnodes \ command. Check the permission." return } =item o Checks the connectivity with the best driver that is available. =cut var $pwd = undef loop $lin (grepLastFile('\".*?\sEL-C\s.*?\"')) {if match($lin,'\"(.*?)\sEL-C\s.*?\"') {var $nod = join(".",last,${RDA.T_DOMAIN}) next compare('eq',$nod,${RDA.T_HOST}) call addRemoteSession('exl',$nod,$USERID) if and(defined($pwd),not(hasPassword('host',$nod,$USERID))) call setPassword('host',$nod,$USERID,$pwd) if needPassword('exl') {var $pwd = setPassword('host',$nod,$USERID,\ askPassword("Enter ${VAR.USERID} at ${VAR.nod} password:",'')) if needPassword('exl') {echo 'Connection error connecting to node ',$nod call endRemoteSession('exl') next } } if rexec('exl','env') echo 'Connection error connecting to node ',$nod,' (error code:',last,')' else echo 'Successful connection to node ',$nod call endRemoteSession('exl') } } =back =begin credits =over 10 =item RDA 4.25: Chenna Gaddam, Wes Root. =back =end credits =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