How to use the sos.plugintools.PluginBase 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 / reporters / tarball.py View on Github external
## (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 sys
import sos.plugintools
from sos.helpers import *

class tarball(sos.plugintools.PluginBase):
    """This plugin tars up the information gathered by sosreport
    """
    def postproc(self, dstroot):
        print "Please enter your first initial and last name (jsmith): ",
        name = sys.stdin.readline()[:-1]

        print "Please enter the case number that you are generating this",
        print "report for: ",
        ticketNumber = sys.stdin.readline()[:-1]

        dirName = name + "." + ticketNumber
        self.callExtProg("/bin/mkdir /tmp/%s" % dirName)
        self.callExtProg("/bin/mv %s/* /tmp/%s"
                       % (dstroot, dirName))
        self.callExtProg("/bin/rm -rf %s" % dstroot)
        self.callExtProg("/bin/tar --directory /tmp -jcf "
github sosreport / sos / src / lib / sos / plugins / openais.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 openais(sos.plugintools.PluginBase):
    """openais related information
    """
    def checkenabled(self):
        if self.isInstalled("openais") or os.path.exists("/usr/sbin/openais-confdb-display"):
            openais_ver = commands.getoutput("rpm -q --queryformat='%{VERSION}' openais")
            v, r, m = openais_ver.split('.')
            if int(r) >= 80 and int(m) >= 6:
                return True
        return False
        
    openais_config_opts = [('totem','token'), ('totem','consensus'),
                           ('totem','token_retransmits_before_loss_const'),
                           ('cman','quorum_dev_poll'), ('cman','expected_votes'),
                           ('cman','two_node')]
    
    def setup(self):
github sosreport / sos / src / lib / sos / plugins / xinetd.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 xinetd(sos.plugintools.PluginBase):
    """xinetd information
    """
    def checkenabled(self):
       if self.isInstalled("xinetd") or os.path.exists("/etc/xinetd.conf"):
          return True
       return False

    def setup(self):
        self.addCopySpec("/etc/xinetd.conf")
        self.addCopySpec("/etc/xinetd.d")
        return
github sosreport / sos / src / example_plugins / runcommand.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

# Class name must be the same as file name and method names must not change
class runcommand(sos.plugintools.PluginBase):
    """This is a very simple example plugin that just runs one command in a shell. That
    command could be a script supplied with your package which outputs information of interest
    to support. When the script or command is run, stdout is collected and included in the
    report generated by sosreport, and stderr is collected and copied into the sos log.

    This is useful for people who have minimal knowledge of python, who wish to write
    collection tools in other languages, or who have existing tools.

    If your script or command generates output files that you want included in the sosreport
    collection of files, include sosCp calls to include them.

    The only method required for this simple plugin is collect().

    Your finished plugin should be included with your package and installed in python's
    site-packages/sos/plugins/ directory
    """
github sosreport / sos / src / lib / sos / plugins / kernel.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 commands, os, re

class kernel(sos.plugintools.PluginBase):
    """kernel related information
    """
    optionList = [("modinfo", 'gathers information on all kernel modules', 'fast', True)]
    moduleFile = ""
    taintList = [
        {'regex':'mvfs*', 'description':'Clearcase module'},
        {'regex':'vnode*', 'description':'Clearcase module'},
        {'regex':'vxfs*', 'description':'Veritas file system module'},
        {'regex':'vxportal*', 'description':'Veritas module'},
        {'regex':'vxdmp*', 'description':'Veritas dynamic multipathing module'},
        {'regex':'vxio*', 'description':'Veritas module'},
        {'regex':'vxspec*', 'description':'Veritas module'},
        {'regex':'dcd*', 'description':'Dell OpenManage Server Administrator module'},
        {'regex':'ocfs', 'description':'Oracle cluster filesystem module'},
        {'regex':'oracle*', 'description':'Oracle module'},
        {'regex':'vmnet*', 'description':'VMware module'},
github sosreport / sos / src / lib / sos / plugins / veritas.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 commands
import sos.plugintools

class veritas(sos.plugintools.PluginBase):
    """veritas related information
    """
    # License
    license = {"VXLICENSE" : "/usr/sbin/vxlicense", "VXLICREP" : "/usr/sbin/vxlicense",
               "OLD_VXLICREP" : "/var/adm/VRTSshrd/VRTSlic/bin/vxlicrep",
               "VXLICTEST" : "/sbin/vxlictest"}
    
    # Slim
    slim = {"VSSAT" : "/opt/VRTSat/bin/vssat"}
    
    # VxVM
    vxvm = {"VXDCTL" : "/usr/sbin/vxdctl", "VXPRINT" : "/usr/lib/vxvm/diag.d/vxkprint",
            "VXDISK" : "/usr/sbin/vxdisk", "VXDG" : "/usr/sbin/vxdg", "VXRLINK" : "/usr/sbin/vxrlink",
            "MACROSD" : "/usr/lib/vxvm/diag.d/macros.d", "VXDMPADM" : "/usr/sbin/vxdmpadm",
            "VXSTAT" : "/usr/sbin/vxstat", "VXCONFIGD" : "/usr/sbin/vxconfigd",
            "VXDDLADM" : "/usr/sbin/vxddladm", "VXDIAGDIR" : "/usr/lib/vxvm/diag.d",
github sosreport / sos / src / lib / sos / plugins / netdump.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
from os.path import exists

class netdump(sos.plugintools.PluginBase):
    """Netdump Configuration Information
    """
    def checkenabled(self):
        if self.isInstalled("netdump") or exists("/etc/sysconfig/netdump*"):
            return True
        return False

    def setup(self):
        self.addCopySpec("/etc/sysconfig/netdump")
        return
github sosreport / sos / src / lib / sos / plugins / named.py View on Github external
## (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 commands
from os.path import normpath, join, exists

class named(sos.plugintools.PluginBase):
    """named related information
    """
    def checkenabled(self):
        self.files = [ "/etc/named.conf",
                       "/etc/sysconfig/named" ]
        self.packages = [ "bind" ]
        return sos.plugintools.PluginBase.checkenabled(self)
       
    def getDnsDir(self, configFile):
        """ grab directory path from named{conf,boot}
        """
        directoryList = self.doRegexFindAll("directory\s\"(.*)\"", configFile)
        return normpath(directoryList[0])

    def setup(self):
        cfgFiles = ("/etc/named.conf",
github sosreport / sos / src / lib / sos / plugins / sar.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 sar(sos.plugintools.PluginBase):
    """Generate the sar file from /var/log/sa/saXX files
    """
    def setup(self):
        path="/var/log/sa"
        dirList=os.listdir(path)
        # find all the sa file that don't have an existing sar file
        for fname in dirList:
            if fname[0:2] == 'sa' and fname[2:3] != 'r':
                sar_filename = 'sar' + fname[2:4]
                if sar_filename not in dirList:
                    sar_command = "/bin/sh -c \"LANG=C /usr/bin/sar -A -f /var/log/sa/" + fname + "\""
                    self.collectOutputNow(sar_command, sar_filename, root_symlink=sar_filename)
        return

    def checkenabled(self):
        if os.path.exists("/var/log/sa") and os.path.exists("/usr/bin/sar"):
github sosreport / sos / src / lib / sos / plugins / ftp.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 ftp(sos.plugintools.PluginBase):
    """FTP server related information
    """
    def checkenabled(self):
       if self.isInstalled("vsftpd") or os.path.exists("/etc/vsftpd"):
          return True
       return False

    def setup(self):
        self.addCopySpec("/etc/ftp*")
        self.addCopySpec("/etc/vsftpd")
        return