# TMcell.ctl: Tests Connection to Exadata Cells # $Id: TMcell.ctl,v 1.8 2015/05/29 06:11:26 RDA Exp $ # ARCS: $Header: /home/cvs/cvs/RDA_8/src/scripting/lib/collect/DB/TMcell.ctl,v 1.8 2015/05/29 06:11:26 RDA Exp $ # # Change History # 20150527 KRA Improve the documentation. =head1 NAME DB:TMcell - Tests Connection to Exadata Cells =head1 DESCRIPTION This test module tests the connection to Exadata cells 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 cells. -vT cell -v run cell =item b) Runs from the command line. You can specify the user for connecting to the remote cells, using the following syntax: -vT cell userid -v run cell userid =back It extracts the cell access information from the file F. 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 Exadata Cell tool ...',tput('off') if $arg[0] var $USERID = nvl(isUser(last,true),'celladmin') else {call requestInput('TMcell') var $USERID = nvl(isUser(${RUN.REQUEST.T_USERID},true),'celladmin') } =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\012" 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 !loadFile('/etc/oracle/cell/network-config/cellip.ora') {echo "\012Unable to get the cell information from file \ /etc/oracle/cell/network-config/cellip.ora" return } =item o Checks the connectivity with the best driver that is available. =cut var ($pwd,@cel) = (undef) loop $cel (grepLastFile('^cell=\"(.*?)\"','1')) {loop $val (@tbl = split('[:;]',$cel)) {if hasPassword('host',$val,$USERID) next push(@cel,$val) } call push(@cel,$tbl[0]) } loop $cel (@cel) {call addRemoteSession('cell',$cel,$USERID) if and(defined($pwd),not(hasPassword('host',$cel,$USERID))) call setPassword('host',$cel,$USERID,$pwd) if needPassword('cell') {var $pwd = setPassword('host',$cel,$USERID,\ askPassword("Enter ${VAR.USERID} at ${VAR.cel} password:",'')) if needPassword('cell') {echo 'Connection error connecting to cell ',$cel call endRemoteSession('cell') next } } if rexec('cell','env') echo 'Connection error connecting to cell ',$cel,' (error code:',last,')' else echo 'Successful connection to cell ',$cel call endRemoteSession('cell') } =back =begin credits =over 10 =item RDA 4.16: Jean-Marc Gaudron. =item RDA 8.07: Nick Xie. =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