SOSREPORT generally uses the default interface (/dev/ipmi0) while
executing ipmitool command, which is quite slow as compare to
usb interface.

This usb interface uses the virtual device exposed from BMC like 
in OpenPower system AMI exposes virtual USB interface. IPMITOOL
command with usb interface sends the data to the kernel drivers
which inturn sends it to the BMC. 

This patch enables ipmitool command to use usb interface if available.

With this patch:
================
root@ubuntu1604:/home/mukesh/sos# ./sosreport --config sos.conf -o ipmitool
sosreport (version 3.2)

This command will collect system configuration and diagnostic
information from this Ubuntu system. An archive containing the collected
information will be generated in /tmp/sos.TF8N8E.

For more information on Ubuntu visit:

  http://www.ubuntu.com/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.

Press ENTER to continue, or CTRL-C to quit.

Please enter your first initial and last name [ubuntu1604]: 
Please enter the case id that you are generating this report for []: 

 Setting up archive ...
 Setting up plugins ...
 Running plugins. Please wait ...

  Running 1/1: ipmitool...        

Creating compressed archive...

Your sosreport has been generated and saved in:
  /tmp/sosreport-ubuntu1604-20161130110402.tar.xz

The checksum is: adfdbc8475874d7ad1077a3d2eda151b

Please send this file to your support representative.

root@ubuntu1604:/home/mukesh/sos# tar -xvf 
/tmp/sosreport-ubuntu1604-20161130110402.tar.xz
sosreport-ubuntu1604-20161130110402/
sosreport-ubuntu1604-20161130110402/version.txt
sosreport-ubuntu1604-20161130110402/sos_reports/
sosreport-ubuntu1604-20161130110402/sos_reports/sos.txt
sosreport-ubuntu1604-20161130110402/sos_reports/sos.html
sosreport-ubuntu1604-20161130110402/sos_commands/
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_sel_list
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_sdr_info
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_chassis_status
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_fru_print
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_sensor_list
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_sel_info
sosreport-ubuntu1604-20161130110402/sos_commands/ipmitool/ipmitool_-I_usb_mc_info
sosreport-ubuntu1604-20161130110402/sos_logs/
sosreport-ubuntu1604-20161130110402/sos_logs/ui.log
sosreport-ubuntu1604-20161130110402/sos_logs/sos.log

Signed-off-by: Mukesh Ojha <mukes...@linux.vnet.ibm.com>
---
Changes in V3:
 - Changed the way to check usb interface availability.

Changes in V2:
 - Removed redundant code added in V1 as per Vasant's suggestion.

 sos/plugins/ipmitool.py | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/sos/plugins/ipmitool.py b/sos/plugins/ipmitool.py
index 6c9c531..17aa8b8 100644
--- a/sos/plugins/ipmitool.py
+++ b/sos/plugins/ipmitool.py
@@ -13,6 +13,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+import subprocess
 from sos.plugins import Plugin, RedHatPlugin, DebianPlugin
 
 
@@ -26,14 +27,24 @@ class IpmiTool(Plugin, RedHatPlugin, DebianPlugin):
     packages = ('ipmitool',)
 
     def setup(self):
+        p = subprocess.Popen('ipmitool -I usb mc info', shell=True,
+                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        p.communicate()
+        isusbIntfEnable = p.returncode
+
+        if not isusbIntfEnable:
+            cmd = "ipmitool -I usb"
+        else:
+            cmd = "ipmitool"
+
         self.add_cmd_output([
-            "ipmitool sel info",
-            "ipmitool sel list",
-            "ipmitool sensor list",
-            "ipmitool chassis status",
-            "ipmitool fru print",
-            "ipmitool mc info",
-            "ipmitool sdr info"
+            "%s sel info" % cmd,
+            "%s sel list" % cmd,
+            "%s sensor list" % cmd,
+            "%s chassis status" % cmd,
+            "%s fru print" % cmd,
+            "%s mc info" % cmd,
+            "%s sdr info" % cmd
         ])
 
 # vim: set et ts=4 sw=4 :
-- 
2.7.4

_______________________________________________
sos-devel mailing list
sos-devel@redhat.com
https://www.redhat.com/mailman/listinfo/sos-devel

Reply via email to