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
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')
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
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)
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")
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)
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)
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)
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)
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)
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)
# 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()
def logStatus(self): log.info('Return status: %s' % self.status) self.message = "test message: ", self.status
def publishJSON(): ''' This is a function for peering but the data is only for the local pymon installtion. ''' log.info("Publishing JSON data...")
def _cb(result, msg): log.info(msg)
def logStatus(self): log.info('Return status: %s' % self.status) self.message = "test message: ",self.status
def _cb(result): if not quiet: log.info(result)