ffdc: Add verification of remote command exit code.
Add verification of remote command exit code to inform user for
better corrective action.
- Set 1: Added for SSH/SCP group.
Tests:
- Set 1: Regression tested.
Signed-off-by: Peter D Phan <peterp@us.ibm.com>
Change-Id: I3b27483f1f3509ce631aa629aa6b137668703d7a
diff --git a/ffdc/ffdc_collector.py b/ffdc/ffdc_collector.py
index 3aab8d0..f196e0d 100644
--- a/ffdc/ffdc_collector.py
+++ b/ffdc/ffdc_collector.py
@@ -463,7 +463,7 @@
form_filename if true, pre-pend self.target_type to filename
"""
- # Executing commands, , if any
+ # Executing commands, if any
self.ssh_execute_ffdc_commands(ffdc_actions_for_machine_type,
form_filename)
@@ -548,7 +548,13 @@
if form_filename:
command_txt = str(command_txt % self.target_type)
- err, response = self.ssh_remoteclient.execute_command(command_txt, command_timeout)
+ cmd_exit_code, err, response = \
+ self.ssh_remoteclient.execute_command(command_txt, command_timeout)
+
+ if cmd_exit_code:
+ self.logger.warning(
+ "\n\t\t[WARN] %s exits with code %s." % (command_txt, str(cmd_exit_code)))
+ self.logger.warning("\t\t[WARN] %s " % err)
progress_counter += 1
self.print_progress(progress_counter)
@@ -579,8 +585,11 @@
self.logger.info("\t\tInvalid command %s for DUMP_LOGS block." % command)
continue
- err, response = self.ssh_remoteclient.execute_command(command)
+ cmd_exit_code, err, response = \
+ self.ssh_remoteclient.execute_command(command)
+ # If file does not exist, code take no action.
+ # cmd_exit_code is ignored for this scenario.
if response:
scp_result = self.ssh_remoteclient.scp_file_from_remote(filename, self.ffdc_dir_path)
if scp_result:
diff --git a/ffdc/ffdc_config.yaml b/ffdc/ffdc_config.yaml
index 45697d8..93ffae2 100644
--- a/ffdc/ffdc_config.yaml
+++ b/ffdc/ffdc_config.yaml
@@ -173,7 +173,7 @@
- 'tail -n 200000 /var/log/syslog >/tmp/OS_syslog.txt 2>&1'
- '{ uname -a; dpkg -s opal-prd; dpkg -s ipmitool ; } >/tmp/OS_info.txt 2>&1'
- 'rm -rf /tmp/sosreport*FFDC*'
- - {'sosreport --batch --tmp-dir /tmp --ticket-number FFDC >/tmp/OS_sosreport.txt 2>&1': 1200}
+ - {'sosreport --batch --tmp-dir /tmp --ticket-number FFDC >/tmp/OS_sosreport.txt': 1200}
FILES:
- '/tmp/OS_isub.txt'
- '/tmp/OS_kern.txt'
diff --git a/ffdc/ssh_utility.py b/ffdc/ssh_utility.py
index a8c1253..f363e82 100644
--- a/ffdc/ssh_utility.py
+++ b/ffdc/ssh_utility.py
@@ -73,7 +73,8 @@
if self.scpclient:
self.scpclient.close()
- def execute_command(self, command, default_timeout=60):
+ def execute_command(self, command,
+ default_timeout=60):
"""
Execute command on the remote host.
@@ -92,8 +93,8 @@
if stdout.channel.exit_status_ready():
break
time.sleep(1)
-
- return stderr.readlines(), stdout.readlines()
+ cmd_exit_code = stdout.channel.recv_exit_status()
+ return cmd_exit_code, stderr.readlines(), stdout.readlines()
except (paramiko.AuthenticationException, paramiko.SSHException,
paramiko.ChannelException, SocketTimeout) as e:
@@ -101,7 +102,7 @@
logging.error("\n>>>>>\tERROR: Fail remote command %s %s" % (e.__class__, e))
logging.error(">>>>>\tCommand '%s' Elapsed Time %s" %
(command, time.strftime("%H:%M:%S", time.gmtime(time.time() - cmd_start))))
- return empty, empty
+ return 0, empty, empty
def scp_connection(self):