From 1167dab89e7097478b4744906045b0b9f3855d45 Mon Sep 17 00:00:00 2001 From: Jake Hunsaker Date: Mon, 19 Feb 2018 14:06:23 -0500 Subject: [alternatives] Add new plugin Adds a new plugin to capture output for alternatives Resolves: #1220 Signed-off-by: Jake Hunsaker Signed-off-by: Bryn M. Reeves --- sos/plugins/alternatives.py | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 sos/plugins/alternatives.py diff --git a/sos/plugins/alternatives.py b/sos/plugins/alternatives.py new file mode 100644 index 00000000..7c3e5c64 --- /dev/null +++ b/sos/plugins/alternatives.py @@ -0,0 +1,52 @@ +# Copyright (C) 2018 Red Hat, Inc., Jake Hunsaker + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +from sos.plugins import Plugin, RedHatPlugin +from sos.utilities import is_executable + + +class Alternatives(Plugin, RedHatPlugin): + """System alternatives + """ + + packages = ('chkconfig',) + commands = ('alternatives',) + + def setup(self): + self.add_cmd_output([ + 'alternatives --list', + 'alternatives --version' + ]) + + alts = [] + ignore = [ + 'cdrecord', + 'ld', + 'mkisofs', + 'whois', + 'xinputrc' + ] + + res = self.get_command_output('alternatives --list') + if res['status'] == 0: + for line in res['output'].splitlines(): + alt = line.split()[0] + if alt not in ignore: + alts.append(alt) + disp_cmd = "alternatives --display %s" + self.add_cmd_output([disp_cmd % alt for alt in alts]) + +# vim: set et ts=4 sw=4 : -- cgit