Example #1
0
 def testMissing(self):
     NAME = 'nonsense'
     try:
         utils.CommandPath(NAME, 'utter nonsense').cmd
     except OSError as e:
         self.assertEquals(e.errno, errno.ENOENT)
         self.assertIn(NAME, e.strerror)
Example #2
0
from logging import handlers
import nscautils
import check_proc_util
import glusternagios

from glusternagios import utils
from glusternagios import glustercli

_nfsService = "Gluster NFS"
_shdService = "Self-Heal"
_smbService = "SMB"
_brickService = "Brick - %s"
_glusterdService = "Gluster Management"
_quotadService = "Quota"
_ctdbdService = "CTDB"
checkIdeSmartCmdPath = utils.CommandPath(
    'check_ide_smart', '/usr/lib64/nagios/plugins/check_ide_smart')
nagios_server_conf_path = nscautils.__NAGIOSSERVER_CONF


def getBrickStatus(volInfo):
    bricks = {}
    hostUuid = glustercli.hostUUIDGet()
    for volumeName, volumeInfo in volInfo.iteritems():
        for brick in volumeInfo['bricksInfo']:
            if brick.get('hostUuid') != hostUuid:
                continue
            brickPath = brick['name'].split(':')[1]
            if volumeInfo['volumeStatus'] == glustercli.VolumeStatus.OFFLINE:
                status = utils.PluginStatusCode.CRITICAL
                msg = "CRITICAL: Brick %s is down" % brickPath
            else:
# 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

import sys
import argparse

from glusternagios import utils
import nscautils

__SED_CMD_PATH = utils.CommandPath("sed", "/bin/sed")


def configureParam(paramName, value):
    sed_pattern = '/%s=.*/c\\%s=%s' % (paramName, paramName, value)
    command_sed = [
        __SED_CMD_PATH.cmd, '-i', sed_pattern, nscautils.__NAGIOSSERVER_CONF
    ]
    utils.execCmd(command_sed)


def configureNode(nagiosAddress, clusterName, hostName):
    configureParam("nagios_server", nagiosAddress)
    configureParam("cluster_name", clusterName)
    configureParam("hostname_in_nagios", hostName)
    print "Configured the node successfully"
Example #4
0
#
# 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
#

import os
import errno


from glusternagios import utils
from glusternagios import glustercli
from glusternagios import storage


_checkProc = utils.CommandPath('check_proc',
                               '/usr/lib64/nagios/plugins/check_procs')

_chkConfig = utils.CommandPath('chkconfig',
                               '/sbin/chkconfig', '/usr/sbin/chkconfig')

_chkService = utils.CommandPath('service',
                                '/sbin/service', 'usr/sbin/service')

_glusterVolPath = "/var/lib/glusterd/vols"
_checkGlusterService = [_chkService.cmd, "glusterd", "status"]
_checkNfsCmd = [_checkProc.cmd, "-c", "1:", "-C", "glusterfs", "-a", "nfs"]
_checkShdCmd = [_checkProc.cmd, "-c", "1:", "-C", "glusterfs", "-a",
                "glustershd"]
_checkSmbCmd = [_checkProc.cmd, "-c", "1:", "-C", "smbd"]
_chkConfigSmb = [_chkConfig.cmd, "smb"]
_checkQuotaCmd = [_checkProc.cmd, "-c", "1:", "-C", "glusterfs", "-a",
# 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
#
import sys
import json
import datetime
from pynag import Model

from glusternagios import utils
import submit_external_command
from constants import NRPE_PATH
from constants import NAGIOS_PATH

serviceCmdPath = utils.CommandPath(
    "service",
    "/sbin/service",
)
nrpeCmdPath = utils.CommandPath(
    "check_nrpe",
    NRPE_PATH,
)
nagiosCmdPath = utils.CommandPath(
    "nagios",
    NAGIOS_PATH,
)


def restartNagios():
    now = datetime.datetime.now()
    cmdStr = "[%s] RESTART_PROGRAM\n" % (now)
    submit_external_command.submitExternalCommand(cmdStr)
Example #6
0
 def testExisting(self):
     cp = utils.CommandPath('sh', 'utter nonsense', '/bin/sh')
     self.assertEquals(cp.cmd, '/bin/sh')