Ejemplo n.º 1
0
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:
                status, msg = check_proc_util.getBrickStatus(
                    volumeName, brick['name'])
            brickService = _brickService % brickPath
            bricks[brickService] = [status, msg]
    return bricks
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:
                status, msg = check_proc_util.getBrickStatus(volumeName,
                                                             brick['name'])
            brickService = _brickService % brickPath
            bricks[brickService] = [status, msg]
    return bricks
    if status == utils.PluginStatusCode.OK:
        if args.type == _NFS:
            status, msg = check_proc_util.getNfsStatus(glustercli.volumeInfo())
        elif args.type == _SMB:
            status, msg = check_proc_util.getSmbStatus(glustercli.volumeInfo())
        elif args.type == _SHD:
            status, msg = check_proc_util.getShdStatus(glustercli.volumeInfo())
        elif args.type == _QUOTA:
            status, msg = check_proc_util.getQuotadStatus(
                glustercli.volumeInfo())
        elif args.type == _CTDB:
            volInfo = glustercli.volumeInfo()
            nfsStatus, nfsMsg = check_proc_util.getNfsStatus(volInfo)
            smbStatus, smbMsg = check_proc_util.getSmbStatus(volInfo)
            status, msg = check_proc_util.getCtdbStatus(smbStatus, nfsStatus)
        elif args.type == _BRICK:
            volInfo = glustercli.volumeInfo(args.volume)
            brickName = _findBrickName(volInfo, args.brickPath)
            if brickName:
                status, msg = check_proc_util.getBrickStatus(args.volume,
                                                             brickName)
            else:
                status = utils.PluginStatusCode.CRITICAL
                msg = "Brick - %s not found" % args.brickPath
    elif args.type != _GLUSTERD:
        msg = "UNKNOWN: Status could not be determined as " \
              "glusterd is not running"
        status = utils.PluginStatusCode.UNKNOWN
    print msg
    exit(status)