def updateState(self): now = datetime.now().strftime("%Y.%m.%d %H:%M:%S") status = self.workflow.currentStatus prev = self.workflow.previousStatus state = self.factory.state uid = self.factory.uid org = self.factory.cfg.check.org if org: state.set('org', org) state.set('previous status', prev) state.set('previous status name', cfg.getStateNameFromNumber(prev)) state.set('current status', status) state.set('node', utils.getHostFromURI(uid)) state.set('service', utils.getFriendlyTypeFromURI(uid)) try: state.set('desc', self.rules.msg) except AttributeError: # mo msg set pass statusName = cfg.getStateNameFromNumber(status) state.set('current status name', statusName) state.set('last check', now) if status in [states.ok, states.warn, states.error, states.failed]: count_index = 'count %s' % statusName state_index = 'last %s' % status state.set(state_index, now) if status == prev: state.set(count_index, state.get(count_index) + 1) else: state.set(count_index, 1)
def setNonChangingState(state, stateNum, uid): stateName = cfg.getStateNameFromNumber(stateNum) type = utils.getFriendlyTypeFromURI(uid) host = utils.getHostFromURI(uid) org = cfg.getCheckConfigFromURI(uid).org state.set('current status', stateNum) state.set('current status name', stateName) state.set('count '+stateName, 1) state.set('node', host) state.set('service', type) if org: state.set('org', org) return state
def setNonChangingState(state, stateNum, uid): stateName = cfg.getStateNameFromNumber(stateNum) type = utils.getFriendlyTypeFromURI(uid) host = utils.getHostFromURI(uid) org = cfg.getCheckConfigFromURI(uid).org state.set('current status', stateNum) state.set('current status name', stateName) state.set('count ' + stateName, 1) state.set('node', host) state.set('service', type) if org: state.set('org', org) return state
def host(self): return utils.getHostFromURI(self.uid)