Subject: [PATCH] [BZ 109068] dbginfo.sh: Add collection of journalctl
From: Wolfgang Taphorn <taphorn@de.ibm.com>

Description:  dbginfo.sh: Add collection of journalctl
Symptom:      * Incomplete data collection. Specifically, the journalctl is
                not collected
              * Findings when performing checkbashism test
              * Findings when performing shellcheck test
              * Messages generated by the script do not indicate the
                originator of the message
Problem:      * journalctl is needed to be collected
              * ip route, ip ntable and lscpu are not collected
              * checkbashism identified some bash built-in functions been used
                along with HOSTNAME
              * shellcheck identified old-style command substitution along 
                with some quoting issues
              * Messages generated by the script can not be identified to be
                generated by the script. This can be confusing in certain
                situations
              * journalctl, ip route, ip ntable and lscpu are not collected
              * List of authors
Solution:     * Adding journalctl and the other missing command to the data
                collection. In terms of journalctl, the data collection is
                limited to the last 5 days and 50000 lines
              * Using /bin/sh functions only and replaced HOSTNAME by using 
                the related commands to get the hostname of the system
              * Replaced the old-style command substitution with the 'modern'
                one and solved the quoting issues
              * Messages generated by the script print the script name along
                with the severity of the message
              * Removed list of authors
Reproduction: * Check the data collection for missing information such as
                journalctl
              * Use checkbashism on dbginfo.sh
              * Use shellcheck on dbginfo.sh
              * Check the output of dbginfo.sh for the missing information
Upstream-ID:  -
Problem-ID:   109068

Signed-off-by: Wolfgang Taphorn <taphorn@de.ibm.com>
---
 scripts/dbginfo.sh |  179 +++++++++++++++++++++++++++--------------------------
 1 file changed, 93 insertions(+), 86 deletions(-)

--- a/scripts/dbginfo.sh
+++ b/scripts/dbginfo.sh
@@ -1,16 +1,10 @@
 #!/bin/sh
 ###############################################################################
-# Copyright IBM Corp. 2002, 2013
+# Copyright IBM Corp. 2002, 2014
 #
 # Collect some configuration, trace, and debug information about the
 # Linux on System z machine
 #
-# Author(s): Sven Schuetz                                <sven[at]de.ibm.com>
-#            Wolfgang Taphorn                         <taphorn[at]de.ibm.com>
-#            Stefan Reimbold                  <stefan.reimbold[at]de.ibm.com>
-#            Susanne Wintenberger                     <swinten[at]de.ibm.com>
-#            Michael Mueller                             <mimu[at]de.ibm.com>
-#
 # This file is part of the s390-tools
 #
 # s390-tools is free software; you can redistribute it and/or modify
@@ -29,10 +23,11 @@
 ###############################################################################
 
 # Switching to neutral locale
-export LC_ALL=C
+LC_ALL=C
+export LC_ALL
 
 # The kernel release version as delivered from uname -r
-readonly KERNEL_RELEASE_VERSION="`uname -r 2>/dev/null`"
+readonly KERNEL_RELEASE_VERSION=$(uname -r 2>/dev/null)
 
 ########################################
 # Global used variables
@@ -42,25 +37,28 @@ readonly KERNEL_RELEASE_VERSION="`uname
 readonly SCRIPTNAME="${0##*/}"
 
 # The terminal
-readonly TERMINAL="`tty 2>/dev/null`"
+readonly TERMINAL=$(tty 2>/dev/null)
+
+# The hostname of the system
+readonly SYSTEMHOSTNAME=$(hostname -s 2>/dev/null)
 
 # The processor ID for the first processor
-readonly PROCESSORID=`grep -E ".*processor 0:.*" /proc/cpuinfo | sed 's/.*identification[[:space:]]*\=[[:space:]]*\([[:alnum:]]*\).*/\1/g'`
+readonly PROCESSORID=$(grep -E ".*processor 0:.*" /proc/cpuinfo | sed 's/.*identification[[:space:]]*\=[[:space:]]*\([[:alnum:]]*\).*/\1/g')
 
 # The processor version for the first processor
-readonly PROCESSORVERSION=`grep -E ".*processor 0:.*" /proc/cpuinfo | sed 's/.*version[[:space:]]*\=[[:space:]]*\([[:alnum:]]*\).*/\1/g'`
+readonly PROCESSORVERSION=$(grep -E ".*processor 0:.*" /proc/cpuinfo | sed 's/.*version[[:space:]]*\=[[:space:]]*\([[:alnum:]]*\).*/\1/g')
 
 # The current date
-readonly DATETIME=`date +%Y-%m-%d-%H-%M-%S 2>/dev/null`
+readonly DATETIME=$(date +%Y-%m-%d-%H-%M-%S 2>/dev/null)
 
 # The base working directory
 readonly WORKDIR_BASE="/tmp/"
 
 # The current working directory for the actual script execution
-if test -z ${PROCESSORID}; then
-    readonly WORKDIR_CURRENT="DBGINFO-"${DATETIME}"-`hostname -s 2>/dev/null`"
+if test -z "${PROCESSORID}"; then
+    readonly WORKDIR_CURRENT="DBGINFO-${DATETIME}-${SYSTEMHOSTNAME:-localhost}"
 else
-    readonly WORKDIR_CURRENT="DBGINFO-"${DATETIME}"-`hostname -s 2>/dev/null`-${PROCESSORID}"
+    readonly WORKDIR_CURRENT="DBGINFO-${DATETIME}-${SYSTEMHOSTNAME:-localhost}-${PROCESSORID}"
 fi
 
 # The current path where the collected information is put together
@@ -84,6 +82,9 @@ readonly OUTPUT_FILE_SYSFS="${WORKPATH}s
 # File that includes content of OSA OAT
 readonly OUTPUT_FILE_OSAOAT="${WORKPATH}osa_oat"
 
+# File that includes the output of journalctl
+readonly OUTPUT_FILE_JOURNALCTL="${WORKPATH}journalctl.out"
+
 # Mount point of the debug file system
 readonly MOUNT_POINT_DEBUGFS="/sys/kernel/debug"
 
@@ -91,34 +92,34 @@ readonly MOUNT_POINT_DEBUGFS="/sys/kerne
 readonly COLLECTION_COUNT=7
 
 # The kernel version (e.g. '2' from 2.6.32 or '3' from 3.2.1)
-readonly KERNEL_VERSION="`uname -r 2>/dev/null | cut -d'.' -f1`"
+readonly KERNEL_VERSION=$(uname -r 2>/dev/null | cut -d'.' -f1)
 
 # The kernel major revision number (e.g. '6' from 2.6.32 or '2' from 3.2.1)
-readonly KERNEL_MAJOR_REVISION="`uname -r 2>/dev/null | cut -d'.' -f2`"
+readonly KERNEL_MAJOR_REVISION=$(uname -r 2>/dev/null | cut -d'.' -f2)
 
 # The kernel mainor revision number (e.g. '32' from 2.6.32 or '1' from 3.2.1)
-readonly KERNEL_MINOR_REVISION="`uname -r 2>/dev/null | cut -d'.' -f3 | sed s/[^0-9].*//g`"
+readonly KERNEL_MINOR_REVISION=$(uname -r 2>/dev/null | cut -d'.' -f3 | sed 's/[^0-9].*//g')
 
 # Is this kernel supporting sysfs - since 2.4 (0=yes, 1=no)
-if test ${KERNEL_VERSION} -lt 2 ||
-    ( test  ${KERNEL_VERSION} -eq 2 && test ${KERNEL_MAJOR_REVISION} -le 4 ); then
+if test "${KERNEL_VERSION}" -lt 2 ||
+    ( test  "${KERNEL_VERSION}" -eq 2 && test "${KERNEL_MAJOR_REVISION}" -le 4 ); then
     readonly LINUX_SUPPORT_SYSFS=1
 else
     readonly LINUX_SUPPORT_SYSFS=0
 fi
 
 # Is this kernel potentially using the /sys/kernel/debug feature - since 2.6.13 (0=yes, 1=no)
-if test ${KERNEL_VERSION} -lt 2 ||
-    ( test ${KERNEL_VERSION} -eq 2 &&
-	( test ${KERNEL_MAJOR_REVISION} -lt 6 ||
-	    ( test ${KERNEL_MAJOR_REVISION} -eq 6 && test ${KERNEL_MINOR_REVISION} -lt 13 ))); then
+if test "${KERNEL_VERSION}" -lt 2 ||
+    ( test "${KERNEL_VERSION}" -eq 2 &&
+	( test "${KERNEL_MAJOR_REVISION}" -lt 6 ||
+	    ( test "${KERNEL_MAJOR_REVISION}" -eq 6 && test "${KERNEL_MINOR_REVISION}" -lt 13 ))); then
     readonly LINUX_SUPPORT_SYSFSDBF=1
 else
     readonly LINUX_SUPPORT_SYSFSDBF=0
 fi
 
 if test "x${PROCESSORVERSION}" = "xFF" || test "x${PROCESSORVERSION}" = "xff"; then
-    readonly RUNTIME_ENVIRONMENT=`grep -E "VM00.*Control Program.*" /proc/sysinfo| sed 's/.*:[[:space:]]*\([[:graph:]]*\).*/\1/g'`;
+    readonly RUNTIME_ENVIRONMENT=$(grep -E "VM00.*Control Program.*" /proc/sysinfo| sed 's/.*:[[:space:]]*\([[:graph:]]*\).*/\1/g')
 else
     readonly RUNTIME_ENVIRONMENT="LPAR"
 fi
@@ -165,12 +166,12 @@ PROCFILES="\
 # Adding files to PROCFILES in case scsi devices are available
 if test -e /proc/scsi; then
     PROCFILES="${PROCFILES}\
-      `find /proc/scsi -type f -perm /444 2>/dev/null`\
+      $(find /proc/scsi -type f -perm /444 2>/dev/null)\
       "
 fi
 
 # Adding files to PROCFILES in case we run on Kernel 2.4 or older
-if test ${LINUX_SUPPORT_SYSFS} -eq 1; then
+if test "${LINUX_SUPPORT_SYSFS}" -eq 1; then
     PROCFILES="${PROCFILES}\
       /proc/chpids\
       /proc/chandev\
@@ -181,10 +182,10 @@ if test ${LINUX_SUPPORT_SYSFS} -eq 1; th
 fi
 
 # Adding s390dbf files to PROCFILE in case we run on Kernel lower than 2.6.13
-if test ${LINUX_SUPPORT_SYSFSDBF} -eq 1; then
+if test "${LINUX_SUPPORT_SYSFSDBF}" -eq 1; then
     if test -e /proc/s390dbf; then
 	PROCFILES="${PROCFILES}\
-          `find /proc/s390dbf -type f -not -path \"*/raw\" -not -path \"*/flush\" 2>/dev/null`\
+          $(find /proc/s390dbf -type f -not -path "*/raw" -not -path "*/flush" 2>/dev/null)\
           "
     fi
 fi
@@ -246,7 +247,7 @@ CONFIGFILES="\
   /etc/udev*\
   /etc/xinet.d\
   /etc/*release\
-  `find /lib/modules -name modules.dep 2>/dev/null`\
+  $(find /lib/modules -name modules.dep 2>/dev/null)\
   "
 
 ########################################
@@ -265,9 +266,11 @@ CMDS="uname -a\
   :nm-tool\
   :route -n\
   :ip route list\
+  :ip route list table all\
   :ip rule list\
   :ip neigh list\
   :ip link show\
+  :ip ntable\
   :ipcs -a\
   :netstat -pantu\
   :netstat -s\
@@ -282,6 +285,7 @@ CMDS="uname -a\
   :lsqeth\
   :lschp\
   :lscss\
+  :lscpu -ae\
   :lsmem\
   :lsdasd\
   :ziorep_config -ADM\
@@ -311,6 +315,7 @@ CMDS="uname -a\
   :java -version\
   :cat /root/.bash_history\
   :env\
+  :journalctl --all --no-pager --since=$(date -d '5 day ago' +%Y-%m-%d) --until=now --lines=50000 > ${OUTPUT_FILE_JOURNALCTL}\
   "
 
 ########################################
@@ -404,26 +409,26 @@ collect_vmcmdsout() {
     if echo "${RUNTIME_ENVIRONMENT}" | grep -qi "z/VM" >/dev/null 2>&1; then
 	pr_syslog_stdout "2 of ${COLLECTION_COUNT}: Collecting z/VM command output"
 
-	if type vmcp >/dev/null 2>&1; then
+	if which vmcp >/dev/null 2>&1; then
 	    cp_command="vmcp"
 	    if ! lsmod 2>/dev/null | grep -q vmcp; then
 		modprobe vmcp && module_loaded=0 && sleep 2
 	    fi
-	elif type hcp >/dev/null 2>&1; then
+	elif which hcp >/dev/null 2>&1; then
 	    cp_command="hcp"
 	    if ! lsmod 2>/dev/null | grep -q cpint; then
 		modprobe cpint && module_loaded=0 && sleep 2
 	    fi
 	else
 	    pr_log_stdout " "
-	    pr_log_stdout "WARNING: No program found to communicate to z/VM CP"
-	    pr_log_stdout "WARNING: Skipping the collection of z/VM command output"
+	    pr_log_stdout "${SCRIPTNAME}: Warning: No program found to communicate to z/VM CP"
+	    pr_log_stdout "       Skipping collection of z/VM command output"
 	    pr_log_stdout " "
 	    return 1
 	fi
-	VMUSERID="`${cp_command} q userid 2>/dev/null | sed -ne 's/^\([^[:space:]]*\).*$/\1/p'`"
+	VMUSERID=$(${cp_command} q userid 2>/dev/null | sed -ne 's/^\([^[:space:]]*\).*$/\1/p')
 
-	vm_cmds="`echo ${VM_CMDS} | sed "s/VMUSERID/${VMUSERID}/g"`"
+	vm_cmds=$(echo "${VM_CMDS}" | sed "s/VMUSERID/${VMUSERID}/g")
 
 	IFS=:
 	for vm_command in ${vm_cmds}; do
@@ -431,9 +436,9 @@ collect_vmcmdsout() {
 	    local cp_buffer_size=2
 	    local rc_buffer_size=2
 	    while test ${rc_buffer_size} -eq 2 && test ${cp_buffer_size} -lt 1024; do
-		cp_buffer_size=$(( ${cp_buffer_size} * 2 ))
+		cp_buffer_size=$(( cp_buffer_size * 2 ))
 
-		eval ${cp_command} -b ${cp_buffer_size}k ${vm_command} >/dev/null 2>&1
+		eval ${cp_command} -b ${cp_buffer_size}k "${vm_command}" >/dev/null 2>&1
 		rc_buffer_size=$?
 	    done
 	    call_run_command "${cp_command} -b ${cp_buffer_size}k ${vm_command}" "${OUTPUT_FILE_VMCMD}"
@@ -470,22 +475,22 @@ collect_procfs() {
 
 ########################################
 collect_sysfs() {
-    local debugfs_mounted=0;
+    local debugfs_mounted=0
     local file_name
     local file_names
     local rc_mount
 
     # Requires kernel version newer then 2.4
-    if test ${LINUX_SUPPORT_SYSFS} -eq 0; then
+    if test "${LINUX_SUPPORT_SYSFS}" -eq 0; then
 	pr_syslog_stdout "4 of ${COLLECTION_COUNT}: Collecting sysfs"
 	# Requires kernel version of 2.6.13 or newer
-	if test ${LINUX_SUPPORT_SYSFSDBF} -eq 0; then
+	if test "${LINUX_SUPPORT_SYSFSDBF}" -eq 0; then
 	    if ! grep -qE "${MOUNT_POINT_DEBUGFS}.*debugfs" /proc/mounts 2>/dev/null; then
 		if mount -t debugfs debugfs "${MOUNT_POINT_DEBUGFS}" >/dev/null 2>&1; then
 		    sleep 2
-		    debugfs_mounted=1;
+		    debugfs_mounted=1
 		else
-		    pr_log_stdout "WARNING: \"Unable to mount debugfs ${MOUNT_POINT_DEBUGFS}\""
+		    pr_log_stdout "${SCRIPTNAME}: Warning: Unable to mount debugfs at \"${MOUNT_POINT_DEBUGFS}\""
 		fi
 	    fi
 	fi
@@ -498,14 +503,16 @@ collect_sysfs() {
 
 	find /sys -noleaf -type f -perm /444 2>/dev/null | while IFS= read -r file_name; do
 	    echo " ${file_name}"
-	    dd if="${file_name}" iflag=nonblock of="${WORKPATH}${file_name}"
+	    if ! dd if="${file_name}" status=noxfer iflag=nonblock of="${WORKPATH}${file_name}" >/dev/null 2>&1; then
+		echo "${SCRIPTNAME}: Warning: failed to copy \"${file_name}\""
+	    fi
 	done
 
 	if test ${debugfs_mounted} -eq 1; then
 	    umount "${MOUNT_POINT_DEBUGFS}"
 	fi
     else
-	pr_syslog_stdout "4 of ${COLLECTION_COUNT}: Collecting sysfs skipped. Kernel `uname -r` must be newer than 2.4"
+	pr_syslog_stdout "4 of ${COLLECTION_COUNT}: Collecting sysfs skipped. Kernel $(uname -r) must be newer than 2.4"
     fi
 
     pr_log_stdout " "
@@ -542,13 +549,13 @@ collect_configfiles() {
 
 ########################################
 collect_osaoat() {
-    local network_devices="`lsqeth 2>/dev/null | grep "Device name" | sed 's/.*:[[:space:]]\+\([^[:space:]]*\)[[:space:]]\+/\1/g'`"
+    local network_devices=$(lsqeth 2>/dev/null | grep "Device name" | sed 's/.*:[[:space:]]\+\([^[:space:]]*\)[[:space:]]\+/\1/g')
     local network_device
 
     if which qethqoat >/dev/null 2>&1; then
 	if test -n "${network_devices}"; then
 	    pr_syslog_stdout "7 of ${COLLECTION_COUNT}: Collecting osa oat output"
-	    for network_device in "${network_devices}"; do
+	    for network_device in ${network_devices}; do
 		call_run_command "qethqoat ${network_device}" "${OUTPUT_FILE_OSAOAT}.out" &&
 		call_run_command "qethqoat -r ${network_device}" "${OUTPUT_FILE_OSAOAT}_${network_device}.raw"
 	    done
@@ -569,23 +576,23 @@ collect_osaoat() {
 call_run_command() {
     local cmd="${1}"
     local logfile="${2}"
-    local raw_cmd="`echo ${cmd} | sed -ne 's/^\([^[:space:]]*\).*$/\1/p'`"
+    local raw_cmd=$(echo "${cmd}" | sed -ne 's/^\([^[:space:]]*\).*$/\1/p')
 
     echo "#######################################################" >> "${logfile}"
-    echo "${USER}@${HOSTNAME}> ${cmd}" >> "${logfile}"
+    echo "${USER}@${SYSTEMHOSTNAME:-localhost}> ${cmd}" >> "${logfile}"
 
     # check if command exists
     if ! which "${raw_cmd}" >/dev/null 2>&1; then
         # check if command is a builtin
 	if ! command -v "${raw_cmd}" >/dev/null 2>&1; then
-	    echo "WARNING: Command \"${raw_cmd}\" not available" >> "${logfile}"
+	    echo "${SCRIPTNAME}: Warning: Command \"${raw_cmd}\" not available" >> "${logfile}"
 	    echo >> "${logfile}"
-	    return 1;
+	    return 1
 	fi
     fi
 
     if ! eval "${cmd}" >> "${logfile}" 2>&1; then
-	echo "WARNING: Command \"${cmd}\" failed" >> "${logfile}"
+	echo "${SCRIPTNAME}: Warning: Command \"${cmd}\" failed" >> "${logfile}"
 	echo >> "${logfile}"
 	return 1
     else
@@ -602,7 +609,7 @@ call_collect_file() {
 
     echo " ${file_name}"
 
-    directory_name="`dirname \"${file_name}\" 2>/dev/null`"
+    directory_name=$(dirname "${file_name}" 2>/dev/null)
     if test ! -e "${WORKPATH}${directory_name}"; then
 	mkdir -p "${WORKPATH}${directory_name}" 2>&1
     fi
@@ -622,7 +629,7 @@ call_collect_file() {
 print_version() {
     cat <<EOF
 ${SCRIPTNAME}: Debug information script version %S390_TOOLS_VERSION%
-Copyright IBM Corp. 2002, 2013
+Copyright IBM Corp. 2002, 2014
 EOF
 }
 
@@ -673,7 +680,7 @@ print_alreadyrunning() {
     cat <<EOF
 
 
-Please check the system if another instance of ${SCRIPTNAME} is already
+Please check the system if another instance of '${SCRIPTNAME}' is already
 running. If this is not the case, please remove the lock file
 '${WORKDIR_BASE}${SCRIPTNAME}.lock'.
 EOF
@@ -687,22 +694,22 @@ commandline_parse()
     local cmdline_arg1=${1}
     local cmdline_count=${#}
 
-    if test ${cmdline_count} -eq 1; then
-	if test ${cmdline_arg1} = '-h' || test ${cmdline_arg1} = '--help'; then
+    if test "${cmdline_count}" -eq 1; then
+	if test "${cmdline_arg1}" = '-h' || test "${cmdline_arg1}" = '--help'; then
 	    print_usage
-	elif test ${cmdline_arg1} = '-v' || test ${cmdline_arg1} = '--version'; then
+	elif test "${cmdline_arg1}" = '-v' || test "${cmdline_arg1}" = '--version'; then
 	    print_version
 	else
 	    echo
-	    echo "${SCRIPTNAME}: invalid option ${cmdline_arg1}"
+	    echo "${SCRIPTNAME}: invalid option \"${cmdline_arg1}\""
 	    echo "Try '${SCRIPTNAME} --help' for more information"
 	    echo
 	    exit 1
 	fi
 	exit 0
-    elif test ${cmdline_count} -ge 1; then
+    elif test "${cmdline_count}" -ge 1; then
 	echo
-	echo "ERROR: Invalid number of arguments!"
+	echo "${SCRIPTNAME}: Error: Invalid number of arguments!"
 	echo
 	print_usage
 	exit 1
@@ -717,8 +724,8 @@ environment_setup()
     if test ! -e "${WORKDIR_BASE}"; then
 	mkdir -p "${WORKDIR_BASE}"
     elif test ! -d "${WORKDIR_BASE}"; then
-	echo "ERROR: ${WORKDIR_BASE} exists but this is a file!"
-	echo "       Please make sure ${WORKDIR_BASE} is a directory."
+	echo "${SCRIPTNAME}: Error: \"${WORKDIR_BASE}\" exists but this is a file!"
+	echo "       Please make sure \"${WORKDIR_BASE}\" is a directory."
 	exit 1
     fi
 
@@ -730,8 +737,8 @@ environment_setup()
     fi
 
     if ! mkdir "${WORKPATH}" 2>/dev/null; then
-	echo "ERROR: Target directory ${WORKPATH} already exists or"
-	echo "       ${WORKDIR_BASE} does not exist!"
+	echo "${SCRIPTNAME}: Error: Target directory \"${WORKPATH}\" already exists or"
+	echo "       \"${WORKDIR_BASE}\" does not exist!"
 	exit 1
     fi
 }
@@ -746,9 +753,9 @@ create_package()
 
     if ! tar -czf "${WORKARCHIVE}" "${WORKDIR_CURRENT}"; then
 	pr_stdout " "
-	pr_stdout "ERROR: Collection of data failed!"
-	pr_stdout "       The creation of ${WORKARCHIVE} was not successful."
-	pr_stdout "       Please check the directory ${WORKDIR_BASE}"
+	pr_stdout "${SCRIPTNAME}: Error: Collection of data failed!"
+	pr_stdout "       The creation of \"${WORKARCHIVE}\" was not successful."
+	pr_stdout "       Please check the directory \"${WORKDIR_BASE}\""
 	pr_stdout "       to provide enough free available space."
     else
 	pr_stdout " "
@@ -766,14 +773,14 @@ environment_cleanup()
 {
     if ! rm -rf "${WORKPATH}" 2>/dev/null; then
 	pr_stdout " "
-	pr_stdout "WARNING: Deletion of ${WORKPATH} failed"
-	pr_stdout "Please remove the directory manually"
+	pr_stdout "${SCRIPTNAME}: Warning: Deletion of \"${WORKPATH}\" failed"
+	pr_stdout "       Please remove the directory manually"
 	pr_stdout " "
     fi
     if ! rm -f "${WORKDIR_BASE}${SCRIPTNAME}".lock 2>/dev/null; then
 	pr_stdout " "
-	pr_stdout "WARNING: Deletion of ${WORKDIR_BASE}${SCRIPTNAME} failed"
-	pr_stdout "Please remove the file manually"
+	pr_stdout "${SCRIPTNAME}: Warning: Deletion of \"${WORKDIR_BASE}${SCRIPTNAME}\" failed"
+	pr_stdout "       Please remove the file manually"
 	pr_stdout " "
     fi
 }
@@ -784,14 +791,14 @@ environment_cleanup()
 emergency_exit()
 {
     pr_stdout " "
-    pr_stdout "INFO: Data collection has been interrupted"
-    pr_stdout "INFO: Cleanup of temporary collected data"
+    pr_stdout "${SCRIPTNAME}: Info: Data collection has been interrupted"
+    pr_stdout "       Cleanup of temporary collected data"
     environment_cleanup
-    pr_stdout "INFO: Emergency exit processed"
+    pr_stdout "${SCRIPTNAME}: Info: Emergency exit processed"
 
     pr_stdout " "
     logger -t "${SCRIPTNAME}" "Data collection interrupted"
-    exit;
+    exit
 }
 
 
@@ -818,18 +825,18 @@ pr_syslog_stdout()
 {
     echo "$@"
     echo "$@" >&8
-    logger -t ${SCRIPTNAME} "$@"
+    logger -t "${SCRIPTNAME}" "$@"
 }
 
 
 ###############################################################################
 # Running the script
 
-commandline_parse ${*}
+commandline_parse "${@}"
 
 # Verification to run as root
-if test `/usr/bin/id -u 2>/dev/null` -ne 0; then
-    echo "ERROR: You must be user root to run ${SCRIPTNAME}!"
+if test "$(/usr/bin/id -u 2>/dev/null)" -ne 0; then
+    echo "${SCRIPTNAME}: Error: You must be user root to run \"${SCRIPTNAME}\"!"
     exit 1
 fi
 
@@ -837,14 +844,14 @@ environment_setup
 print_version
 
 # saving stdout/stderr and redirecting stdout/stderr into log file
-exec 8>&1 9>&2 >${LOGFILE} 2>&1
+exec 8>&1 9>&2 >"${LOGFILE}" 2>&1
 
-# trap on SIGHUP SIGINT SIGTERM
-trap emergency_exit 1 2 15
+# trap on SIGHUP=1 SIGINT=2 SIGTERM=15
+trap emergency_exit SIGHUP SIGINT SIGTERM
 
 pr_log_stdout ""
-pr_log_stdout "Hardware platform     = `uname -i`"
-pr_log_stdout "Kernel version        = ${KERNEL_VERSION}.${KERNEL_MAJOR_REVISION}.${KERNEL_MINOR_REVISION} (`uname -r 2>/dev/null`)"
+pr_log_stdout "Hardware platform     = $(uname -i)"
+pr_log_stdout "Kernel version        = ${KERNEL_VERSION}.${KERNEL_MAJOR_REVISION}.${KERNEL_MINOR_REVISION} ($(uname -r 2>/dev/null))"
 pr_log_stdout "Runtime environment   = ${RUNTIME_ENVIRONMENT}"
 pr_log_stdout ""
 
