Exemplo n.º 1
0
 def cutOffReached(self):
     cutoff = self.factory.cfg.notifications.cut_off
     if self.factory.state.get('count') > cutoff:
         log.info("Incident count has passed the cut-off " + \
             "threshold; not sending email.")
         return True
     return False
Exemplo n.º 2
0
    def connectionLost(self, reason):
        status = self.factory.status
        if status:
            status = int(status)
        log.debug(str(dir(self.factory)))
        log.debug(str(self.factory.headers))
        log.debug(str(self.factory.response_headers))
        checked_resource = self.factory.checkConfig.uri

        # push the returned data through the threshold checks
        self.rules.check(status)
        self.rules.setMsg(checked_resource, status, self.factory.message)
        self.rules.setSubj(checked_resource, status)
        if self.rules.isSendMessage():
            self.rules.sendIt()

        # dump info to log file
        log.debug('Service: %s' % self.factory.uid)
        log.info(self.rules.msg)
        log.info(self.rules.subj)
        log.debug("Status: %s for %s" % (status, self.getHost()))

        # update state information
        self.updateState()

        # dump info to log file
        log.debug('State Data: ' + str(self.factory.state.data) + '\n')
Exemplo n.º 3
0
 def isCutoff(self):
     cutoff = self.factory.cfg.app.notifications.cut_off
     if self.factory.state.get('count') > cutoff:
         log.info("Incident count has passed the cut-off " +
             "threshold; not sending email.")
         return True
     return False
Exemplo n.º 4
0
    def connectionMade(self):
        '''
        We never got a connection, and therefore can't get a connection
        lost, so we need to do the things here that would normally get
        done in connectionLost.
        '''
        ClientMixin.connectionMade(self)
        log.debug("Factory in NullClient: %s" % self.factory)
        status = self.factory.cfg.app.state_definitions.failed
        checked_resource = self.factory.cfg.checks.uri
        log.debug("Starting rules processing...")
        self.rules.check(status)
        self.rules.setMsg(checked_resource, self.factory.status, self.factory.message)
        self.rules.setSubj(checked_resource)
        if self.rules.isSendMessage():
            self.rules.sendIt()
        log.debug("Finished rules processing.")

        # dump info to log file
        log.debug('NullClient Service: %s' % self.factory.uid)
        log.info(self.rules.msg)
        log.info(self.rules.subj)
        log.debug("NullClient Status: %s for %s" % (status, self.getHost()))

        # update state information
        self.updateState()

        # dump info to log file
        log.debug(self.factory.state)
Exemplo n.º 5
0
    def connectionLost(self, reason):
        status = self.factory.status
        if status:
            status = int(status)
        log.debug(str(dir(self.factory)))
        log.debug(str(self.factory.headers))
        log.debug(str(self.factory.response_headers))
        checked_resource = self.factory.checkConfig.uri

        # push the returned data through the threshold checks
        self.rules.check(status)
        self.rules.setMsg(checked_resource, status, self.factory.message)
        self.rules.setSubj(checked_resource, status)
        if self.rules.isSendMessage():
            self.rules.sendIt()

        # dump info to log file
        log.debug("Service: %s" % self.factory.uid)
        log.info(self.rules.msg)
        log.info(self.rules.subj)
        log.debug("Status: %s for %s" % (status, self.getHost()))

        # update state information
        self.updateState()

        # dump info to log file
        log.debug("State Data: " + str(self.factory.state.data) + "\n")
Exemplo n.º 6
0
    def connectionMade(self):
        '''
        We never got a connection, and therefore can't get a connection
        lost, so we need to do the things here that would normally get
        done in connectionLost.
        '''
        ClientMixin.connectionMade(self)
        log.debug("Factory in NullClient: %s" % self.factory)
        status = self.factory.cfg.app.state_definitions.failed
        checked_resource = self.factory.cfg.checks.uri
        log.debug("Starting rules processing...")
        self.rules.check(status)
        self.rules.setMsg(checked_resource, self.factory.status,
                          self.factory.message)
        self.rules.setSubj(checked_resource)
        if self.rules.isSendMessage():
            self.rules.sendIt()
        log.debug("Finished rules processing.")

        # dump info to log file
        log.debug('NullClient Service: %s' % self.factory.uid)
        log.info(self.rules.msg)
        log.info(self.rules.subj)
        log.debug("NullClient Status: %s for %s" % (status, self.getHost()))

        # update state information
        self.updateState()

        # dump info to log file
        log.debug(self.factory.state)
Exemplo n.º 7
0
def checkPeers(cfg):
    '''
    The function that is called when periodically checking pymon peers.
    '''
    # XXX This function may not ever get used. It may be more economical
    # to simply make XHR's from JavaScript to the pymon peers.
    log.info("Checking peers...")
    for peer in cfg.peers.url:
        log.info("Cheeking peer '%s'..." % peer)
Exemplo n.º 8
0
def checkPeers(cfg):
    '''
    The function that is called when periodically checking pymon peers.
    '''
    # XXX This function may not ever get used. It may be more economical
    # to simply make XHR's from JavaScript to the pymon peers.
    log.info("Checking peers...")
    for peer in cfg.peers.url:
        log.info("Cheeking peer '%s'..." % peer)
Exemplo n.º 9
0
    def connectionLost(self, reason):
        # parse returned data
        log.debug(self.factory.data)
        parse = OutputParser(self.factory.data)
        loss = parse.getPingLoss()
        gain = parse.getPingGain()
        host = self.getHost()

        # threshold checks, messaging, and workflow
        self.processRules(gain, host=host, loss=loss, gain=gain)

        # update state information
        self.updateState()

        # dump info to log file
        log.info('State Data: '+str(self.factory.state.data)+'\n')

        # final cleanup
        LocalAgentClient.connectionLost(self, reason)
        ClientMixin.teardown(self)
Exemplo n.º 10
0
    def connectionLost(self, reason):
        # parse returned data
        log.debug(self.factory.data)
        parse = OutputParser(self.factory.data)
        loss = parse.getPingLoss()
        gain = parse.getPingGain()
        host = self.getHost()

        # threshold checks, messaging, and workflow
        self.processRules(gain, host=host, loss=loss, gain=gain)

        # update state information
        self.updateState()

        # dump info to log file
        log.info('State Data: ' + str(self.factory.state.data) + '\n')

        # final cleanup
        LocalAgentClient.connectionLost(self, reason)
        ClientMixin.teardown(self)
Exemplo n.º 11
0
 def sendIt(self):
     if self.status == self.factory.cfg.app.state_definitions.recovering:
         status_id = self.factory.state.get('current status')
         status = cfg.getStateNameFromNumber(status_id)
         self.msg = self.msg + "\r\nRecovering from '%s'." % status
     sendmail = self.factory.cfg.sendmail
     frm = self.factory.cfg.mail_from
     # XXX we probably want to make the actual sending of emails
     # non-blocking. Dererreds anyone?
     # XXX modify this when support for escalation and different
     # group levels is added to pymon
     for address in cfg.getMailList(self.factory.uid):
         email = LocalMail()
         email.setSendmailBinary(sendmail)
         email.setSubject(self.subj)
         email.setTo(address)
         email.setFrom(frm)
         email.setData(self.msg)
         email.send()
         log.info(self.factory.cfg.defaults.sent_message % address)
Exemplo n.º 12
0
 def sendIt(self):
     if self.status == self.factory.cfg.app.state_definitions.recovering:
         status_id = self.factory.state.get('current status')
         status = cfg.getStateNameFromNumber(status_id)
         self.msg = self.msg + "\r\nRecovering from '%s'." % status
     sendmail = self.factory.cfg.sendmail
     frm = self.factory.cfg.mail_from
     # XXX we probably want to make the actual sending of emails
     # non-blocking. Dererreds anyone?
     # XXX modify this when support for escalation and different
     # group levels is added to pymon
     for address in cfg.getMailList(self.factory.uid):
         email = LocalMail()
         email.setSendmailBinary(sendmail)
         email.setSubject(self.subj)
         email.setTo(address)
         email.setFrom(frm)
         email.setData(self.msg)
         email.send()
         log.info(self.factory.cfg.defaults.sent_message % address)
Exemplo n.º 13
0
    def connectionLost(self, reason):
        results = self.factory.data
        log.debug(results)

        # push the returned data through the threshold checks
        status = self.rules.check(gain)
        self.workflow.checkTransition(status, self.factory.cfg)
        #self.rules.setMsg(results['gain'], self.getHost())
        #self.rules.setSubj(self.getHost(), results['loss'])
        #if self.rules.isSendMessage():
        #    self.rules.sendIt()

        # dump info to log file
        log.debug('Service: %s' % self.factory.uid)
        log.debug("Status: %s for %s" % (self.rules.status, host))

        # update state information
        self.updateState()

        # dump info to log file
        log.info('State Data: ' + str(self.factory.state.data) + '\n')

        # final cleanup
        ClientMixin.connectionLost(self)
Exemplo n.º 14
0
    def connectionLost(self, reason):
        results = self.factory.data
        log.debug(results)

        # push the returned data through the threshold checks
        status = self.rules.check(gain)
        self.workflow.checkTransition(status, self.factory.cfg)
        #self.rules.setMsg(results['gain'], self.getHost())
        #self.rules.setSubj(self.getHost(), results['loss'])
        #if self.rules.isSendMessage():
        #    self.rules.sendIt()

        # dump info to log file
        log.debug('Service: %s' % self.factory.uid)
        log.debug("Status: %s for %s" % (self.rules.status, host))

        # update state information
        self.updateState()

        # dump info to log file
        log.info('State Data: '+str(self.factory.state.data)+'\n')

        # final cleanup
        ClientMixin.connectionLost(self)
Exemplo n.º 15
0
# setup global registry
globalRegistry = Registry()
state       = BaseState()
history     = History()
factories   = {}

app_state = os.path.join(cfg.admin.backups.state_dir,
    cfg.admin.backups.application_state)
state.setFilename(app_state)


# load previous app state data, if available
try:
    state.restore()
    log.info("Restoring previous application state...")
except IOError:
    state.save()

globalRegistry.add('state', state)
globalRegistry.add('history', history)
globalRegistry.add('factories', factories)


def _test():
    import doctest, application
    doctest.testmod(application)

if __name__ == '__main__':
    _test()
Exemplo n.º 16
0

# setup global registry
globalRegistry = Registry()
state = BaseState()
history = History()
factories = {}

app_state = os.path.join(cfg.admin.backups.state_dir,
                         cfg.admin.backups.application_state)
state.setFilename(app_state)

# load previous app state data, if available
try:
    state.restore()
    log.info("Restoring previous application state...")
except IOError:
    state.save()

globalRegistry.add('state', state)
globalRegistry.add('history', history)
globalRegistry.add('factories', factories)


def _test():
    import doctest, application
    doctest.testmod(application)


if __name__ == '__main__':
    _test()
Exemplo n.º 17
0
 def logStatus(self):
     log.info('Return status: %s' % self.status)
     self.message = "test message: ", self.status
Exemplo n.º 18
0
def publishJSON():
    '''
    This is a function for peering but the data is only for the local
    pymon installtion.
    '''
    log.info("Publishing JSON data...")
Exemplo n.º 19
0
 def _cb(result, msg):
     log.info(msg)
Exemplo n.º 20
0
 def logStatus(self):
     log.info('Return status: %s' % self.status)
     self.message = "test message: ",self.status
Exemplo n.º 21
0
 def _cb(result):
     if not quiet:
         log.info(result)
Exemplo n.º 22
0
 def _cb(result):
     if not quiet:
         log.info(result)
Exemplo n.º 23
0
def publishJSON():
    '''
    This is a function for peering but the data is only for the local
    pymon installtion.
    '''
    log.info("Publishing JSON data...")