This patch changes iprsos code to display the dump logs on stdout by default. It also introduces the option to print the output log to a file of the user choice when s/he appends "-o /path/to/file" when calling the script.
Signed-off-by: Daniel Kreling <krel...@linux.vnet.ibm.com> --- The first version of this patch was sent to the list as v4 and did not apply accordingly, likely because of trailing spaces at the iprsos.8 text, so I am resending a new version that will apply seamlessly. About the patch version, I was tracking versions internally, but I mistakenly did not remove the version tag before sending the first version, that is why it was sent tagged as v4. I am now naming this version 1 to start over. I apologize for the confusion. iprsos | 130 +++++++++++++++++++++++++++++++++++++++++---------------------- iprsos.8 | 11 ++++-- 2 files changed, 92 insertions(+), 49 deletions(-) mode change 100644 => 100755 iprsos diff --git a/iprsos b/iprsos old mode 100644 new mode 100755 index 08f8c3d..53662ab --- a/iprsos +++ b/iprsos @@ -1,60 +1,100 @@ #!/bin/bash -# This script creates an sos report with iprutils information at $dir +# This script displays information about iprutils, IPR adapters and systemd services +# related to IPR. It will also create an sos report with iprutils information at $file +# when iprsos is invoked with "-o /path/to/file". -dir="/var/log/iprsos.log" +function _ipr_dump() { + echo "=== Running 'iprconfig -c dump' ===" + iprconfig -c dump +} -echo Creating a new file `echo $dir` ... -if [ -f $dir ]; then - rm -f $dir -fi +function _lspci() { +echo + echo "=== Running 'lspci' ===" + lspci +} -echo === Running 'iprconfig -c dump' === >> $dir -iprconfig -c dump >> $dir +function _lsscsi() { + echo + echo "=== Running 'lsscsi' ===" + lsscsi +} -echo >> $dir -echo "=== Running 'lspci' ===" >> $dir -/sbin/lspci >> $dir +function _lsscsi_H() { + echo + echo "=== Running 'lsscsi -H' ===" + lsscsi -H +} -echo >> $dir -echo "=== Running 'lsscsi' ===" >> $dir -/usr/bin/lsscsi >> $dir +function _check_daemons() { + if [ -f "/usr/bin/systemctl" ]; then + echo + echo === IPR daemons: Running 'systemctl status ipr{init,dump,update}.service' === + systemctl status iprdump.service + systemctl status iprinit.service + systemctl status iprupdate.service + else + echo + echo === IPR daemons: Running 'service ipr* status' === + service iprinit status + service iprdump status + service iprupdate status + fi +} -echo >> $dir -echo "=== Running 'lsscsi -H' ===" >> $dir -/usr/bin/lsscsi -H >> $dir +function _etc_ipr() { + echo + echo "=== Contents of '/etc/ipr/ ' ===" + if [ -d /etc/ipr ]; then + ls /etc/ipr/ + else + echo "No files at /etc/ipr/" + fi +} -if [ -d "/usr/lib/systemd/system" ]; then - echo >> $dir - echo === IPR daemons: Running 'systemctl status ipr{init,dump,update}.service' === >> $dir - /usr/bin/systemctl status iprdump.service >> $dir - /usr/bin/systemctl status iprinit.service >> $dir - /usr/bin/systemctl status iprupdate.service >> $dir -else - echo >> $dir - echo === IPR daemons: Running 'service ipr* status' === >> $dir - /sbin/service iprinit status >> $dir - /sbin/service iprdump status >> $dir - /sbin/service iprupdate status >> $dir +function _var_log_iprdump () { + echo + echo "=== Contents of '/var/log/iprdump*' ===" + if [ -f /var/log/iprdump.? ]; then + ls -lh /var/log/iprdump* + else + echo "No iprdump files found at /var/log." + fi +} -fi +function _var_log_messages() { + echo + echo "=== Contents of '/var/log/messages' ===" + cat /var/log/messages +} -echo >> $dir -echo "=== Contents of '/etc/ipr/ ' ===" >> $dir -if [ -d /etc/ipr ]; then - /bin/ls /etc/ipr/ >> $dir -else - echo "No files at /etc/ipr/" >> $dir +function _run_sos() { + _ipr_dump + _lspci + _lsscsi + _lsscsi_H + _check_daemons + _etc_ipr + _var_log_iprdump + _var_log_messages +} + +args=($@) + +if [ -z ${args[0]} ]; then + file= + +elif [ ${args[0]} = "-o" ]; then + file=${args[1]} + if [ -z $file ]; then + echo "Usage: ./iprsos -o path/to/file" + exit 1 + fi fi -echo >> $dir -echo "=== Contents of '/var/log/iprdump*' ===" >> $dir -if [ -f /var/log/iprdump.? ]; then - /bin/ls -lh /var/log/iprdump* >> $dir +if [ -z $file ]; then + _run_sos else - echo "No iprdump files found at /var/log." >> $dir + _run_sos > $file fi - -echo >> $dir -echo "=== Contents of '/var/log/messages' ===" >> $dir -/bin/cat /var/log/messages >> $dir diff --git a/iprsos.8 b/iprsos.8 index 130bb29..5109b10 100644 --- a/iprsos.8 +++ b/iprsos.8 @@ -11,15 +11,18 @@ iprsos \- IBM Power RAID report generator .sp .SH DESCRIPTION .B iprsos -is used to generate an sosreport-like report by collecting hardware +is used to generate an sosreport-like report by collecting hardware information from the system, along with other system calls such as lspci, lscsi, and others. The information is collected from 'iprconfig' -commands and appended to the /var/log/iprsos.log file +commands and printed on stdin by default. User can specify the log file +by -o /path/to/report/file of his/her choice. .br .SH FILES .br -A detailed report file is created at /var/log/iprsos.log with the -information collected from the hardware and system information. +A detailed report file is printed both at stdin and the /path/to/report/file +specified by the user, with the information collected from the hardware and +system information. If no files are used, the information will be only displayed +at stdin. .br .SH AUTHORS Daniel B. Kreling <krel...@linux.vnet.ibm.com> -- 1.9.1 ------------------------------------------------------------------------------ _______________________________________________ Iprdd-devel mailing list Iprdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iprdd-devel