Ejemplo n.º 1
0
 def _connectedEb(self, f):
     if f.check(errors.ConnectionFailedError):
         # switch the failure and return an UNKNOWN status
         msg = "Unable to connect to manager."
         f = failure.Failure(util.NagiosUnknown(msg))
         util.unknown(msg)
     if f.check(errors.ConnectionRefusedError):
         # switch the failure and return a CRITICAL status
         msg = "Manager refused connection."
         f = failure.Failure(util.NagiosCritical(msg))
         util.critical(msg)
     # all other failures get forwarded to the managerDeferred errback as-is
     self.managerDeferred.errback(f)
Ejemplo n.º 2
0
def getURLFromPlaylist(url):
    try:
        playlist = urlOpenWithCookies(url)
    except urllib2.URLError, e:
        raise util.NagiosCritical(e)
Ejemplo n.º 3
0
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(jar))
    r = opener.open(url)
    return r


def getURLFromPlaylist(url):
    try:
        playlist = urlOpenWithCookies(url)
    except urllib2.URLError, e:
        raise util.NagiosCritical(e)

    urls = re.findall(URLFINDER, playlist.read())
    if urls:
        return urls[-1]  # new (the last) url to check
    else:
        raise util.NagiosCritical('No URLs into the playlist.')


class CheckBase(util.LogCommand):
    '''Main class to perform the stream checks'''
    description = 'Check stream.'
    usage = '[options] url'

    def __init__(self, parentCommand=None, **kwargs):
        '''Initial values and pipeline setup'''
        self._expectAudio = False
        self._expectVideo = False
        self._playlist = False
        self._url = None
        self._streamurl = None
        self.managerDeferred = defer.Deferred()