aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2018-05-14 09:45:16 -0400
committerBryn M. Reeves <bmr@redhat.com>2018-05-24 15:21:57 +0100
commit008082712ba4dd3396bfa3b519440ca836293005 (patch)
treef38b8907902d83f131afb4d8983f625bca8ca557
parent1beec779f0b3d37d9e4726ea1b11b109c35c10c3 (diff)
downloadsos-008082712ba4dd3396bfa3b519440ca836293005.tar.gz
[Plugins] Add new add_udev_info() method
Adds a new collection method add_udev_info() which will collect 'udevadm info' output for a given device or list of devices. An optional 'attrs' boolean will, if True, have udevadm perform an attribute-walk of the device's sysfs attributes. This method can take either device names such as '/dev/sda' or sysfs paths such as '/sys/class/scsi_host/host0' and these styles may be freely interchanged in a list given to a single call. Resolves: #1293 Signed-off-by: Jake Hunsaker <jhunsake@redhat.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
index 598cc127..7bb8d2e8 100644
--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -852,6 +852,25 @@ class Plugin(object):
self._log_debug("collecting journal: %s" % journal_cmd)
self._add_cmd_output(journal_cmd, None, None, timeout)
+ def add_udev_info(self, device, attrs=False):
+ """Collect udevadm info output for a given device
+
+ :param device: A string or list of strings of device names or sysfs
+ paths. E.G. either '/sys/class/scsi_host/host0' or
+ '/dev/sda' is valid.
+ :param attrs: If True, run udevadm with the --attribute-walk option.
+ """
+ udev_cmd = 'udevadm info'
+ if attrs:
+ udev_cmd += ' -a'
+
+ if isinstance(device, six.string_types):
+ device = [device]
+
+ for dev in device:
+ self._log_debug("collecting udev info for: %s" % dev)
+ self._add_cmd_output('%s %s' % (udev_cmd, dev))
+
def _expand_copy_spec(self, copyspec):
return glob.glob(copyspec)