How to use the sos.plugintools function in sos

To help you get started, we’ve selected a few sos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sosreport / sos / src / lib / sos / plugins / networking.py View on Github external
## 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., 675 Mass Ave, Cambridge, MA 02139, USA.

import sos.plugintools
import os,re,commands

class networking(sos.plugintools.PluginBase):
    """network related information
    """
    optionList = [("traceroute", "collects a traceroute to rhn.redhat.com", "slow", False)]

    def get_interface_name(self,ifconfigFile):
        """Return a dictionary for which key are interface name according to the
        output of ifconifg-a stored in ifconfigFile.
        """
        out=self.doRegexFindAll(r"^(eth\d+)\D", ifconfigFile)
        return out

    def collectIPTable(self,tablename):
        """ When running the iptables command, it unfortunately auto-loads
        the modules before trying to get output.  Some people explicitly
        don't want this, so check if the modules are loaded before running
        the command.  If they aren't loaded, there can't possibly be any
github sosreport / sos / src / lib / sos / plugins / yum.py View on Github external
def checkenabled(self):
        self.files = [ "/etc/yum.conf" ]
        self.packages = [ "yum" ]
        return sos.plugintools.PluginBase.checkenabled(self)
github sosreport / sos / src / lib / sos / plugins / sanitize.py View on Github external
## 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., 675 Mass Ave, Cambridge, MA 02139, USA.

import os
import sos.plugintools
import glob
import socket

class sanitize(sos.plugintools.PluginBase):
    """ sanitize specified log files, etc
    """
    def defaultenabled(self):
        # disabled by default b/c still a work in progress
        return False

    def setup(self):
        # sanitize ip's, hostnames in logs
        hostname = socket.gethostname()
        rhelver = self.policy().rhelVersion()
        if rhelver == 5 or rhelver == 4:
            logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/syslog.conf")
        else:
            logs=self.doRegexFindAll(r"^\S+\s+(\/.*log.*)\s+$", "/etc/rsyslog.conf")
        for log in logs:
            self.addCopySpec(log)
github sosreport / sos / sos / plugins / openstack_nova.py View on Github external
## 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., 675 Mass Ave, Cambridge, MA 02139, USA.

import sos.plugintools

class openstack_nova(sos.plugintools.PluginBase):
    """openstack nova related information
    """

    optionList = [("log", "gathers openstack nova logs", "slow", True),
                   ("cmds", "gathers openstack nova commands", "slow", False)]

    packages = ('openstack-nova-common',
                'openstack-nova-network',
                'openstack-nova-conductor',
                'openstack-nova-conductor',
                'openstack-nova-scheduler',
                'openstack-nova-console',
                'openstack-nova-novncproxy',
                'openstack-nova-compute',
                'openstack-nova-api',
                'openstack-nova-cert',
github sosreport / sos / sos / plugins / cloudforms.py View on Github external
import sos.plugintools
import os

class cloudforms(sos.plugintools.PluginBase):
    """CloudForms related information
    """

    def defaultenabled(self):
        return False

    def checkenabled(self):
        self.packages = ["katello", "katello-common",
                        "katello-headpin", "aeoleus-conductor"]
        self.files = ["/usr/share/katello/script/katello-debug",
                        "/usr/bin/aeolus-debug"]
        return sos.plugintools.PluginBase.checkenabled(self)

    def setup(self):
        katello_debug = "/usr/share/katello/script/katello-debug"
        aeolus_debug = "/usr/bin/aeolus-debug"
github sosreport / sos / sos / plugins / pgsql.py View on Github external
if max_depth:
        base_depth = os.path.dirname(top_dir).count(os.path.sep)
        max_depth += base_depth

    for path, dirlist, filelist in os.walk(top_dir):
        if max_depth and path.count(os.path.sep) >= max_depth:
            del dirlist[:]

        if path_pattern and not fnmatch.fnmatch(path, path_pattern):
            continue

        for name in fnmatch.filter(filelist, file_pattern):
            yield os.path.join(path,name)

# Class name must be the same as file name and method names must not change
class pgsql(sos.plugintools.PluginBase):
    """PostgreSQL related information"""
    __pghome = '/var/lib/pgsql'
    __username = 'postgres'
    __dbport = 5432

    packages = [ 'postgresql' ]

    password_warn_text = " (password visible in process listings)"

    optionList = [
        ("pghome",  'PostgreSQL server home directory (default=/var/lib/pgsql)', '', __pghome),
        ("username",  'username for pg_dump (default=postgres)', '', False),
        ('password', 'password for pg_dump' + password_warn_text, '', False),
        ("dbname",  'database name to dump for pg_dump (default=None)', '', False),
        ("dbhost",  'hostname/IP of the server upon which the DB is running (default=localhost)', '', False),
        ("dbport",  'database server port number (default=5432)', '', False)
github sosreport / sos / src / lib / sos / plugins / smartcard.py View on Github external
## 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., 675 Mass Ave, Cambridge, MA 02139, USA.

import sos.plugintools
import os

class smartcard(sos.plugintools.PluginBase):
    """Smart Card related information
    """

    def checkenabled(self):
       if self.isInstalled("pam_pkcs11") or os.path.exists("/etc/pam_pkcs11/pam_pkcs11.conf"):
          return True
       return False

    def setup(self):
        self.addCopySpec("/etc/reader.conf")
        self.addCopySpec("/etc/reader.conf.d/")
        self.addCopySpec("/etc/pam_pkcs11/")
        self.collectExtOutput("/usr/bin/pkcs11_inspect debug")
        self.collectExtOutput("/usr/bin/pklogin_finder debug")
        self.collectExtOutput("/bin/ls -l /usr/lib/pam_pkcs11/")
        return
github sosreport / sos / src / lib / sos / plugins / systemtap.py View on Github external
def checkenabled(self):
        self.files = [ "/usr/bin/stap" ]
        self.packages = [ "systemtap", "systemtap-runtime" ]
        return sos.plugintools.PluginBase.checkenabled(self)