Beispiel #1
0
 def sendHeartbeat(self):
     """Send a heartbeat event for this monitor.
     """
     timeout = self.options.cycletime*3
     evt = Event.EventHeartbeat(self.options.monitor, self.name, timeout)
     self.sendEvent(evt)
     self.niceDoggie(self.options.cycletime)
Beispiel #2
0
    def runEvents(self):
        "Execute all the maintanance windows at the proper time"
        if self.timer and not self.timer.called:
            self.timer.cancel()
            self.timer = None

        # sort events by the next occurance of something to do
        now = self.now()
        work = self.makeWorkList(now, self.workList)
        self.workList = [mw for t, mw in work]
        # fire events that should be done now
        for next, mw in work:
            if next <= now:
                how = {True: 'stopping', False: 'starting'}[bool(mw.started)]
                severity = {
                    True: Event.Clear,
                    False: Event.Info
                }[bool(mw.started)]
                # Note: since the MWs always return devices back to their original
                #       prod state, and there may be many devices, just provide an
                #       'unknown' production state for stopping
                prodState = {
                    True: -99,
                    False: mw.startProductionState
                }[bool(mw.started)]
                mwId = mw.getId()
                devices = mw.target().getId()
                msg = "Maintenance window %s %s for %s" % (how, mwId, devices)
                self.log.debug(msg)
                dedupid = '|'.join(["zenjobs", self.monitor, mwId, devices])
                self.sendEvent(
                    Event.Event(
                        component="zenjobs",
                        severity=severity,
                        dedupid=dedupid,
                        eventClass=Status_Update,
                        eventClassKey="mw_change",
                        summary=msg,
                        eventKey='|'.join([mwId, devices]),
                        maintenance_window=mwId,
                        maintenance_devices=devices,
                        device=self.monitor,
                        prodState=prodState,
                    ))
                self.executeMaintenanceWindow(mw, next)
            else:
                break

        work = self.makeWorkList(now, self.workList)
        if work:
            wait = max(0, work[0][0] - now)
            self.log.debug("Waiting %f seconds", wait)
            self.timer = self.callLater(wait)
 def sendEmailPingEvent( self, eventClassKey, component, summary, **kwargs ):
 
     fields = { 'agent': self.name,
                'component': component,
                'device': self.options.monitor,
                'eventClassKey': eventClassKey,
                'manager': self.fqdn,
                'monitor': self.options.monitor,
                'severity': 3,
                'summary': summary }
     if kwargs:
         fields.update( kwargs )
     
     evt = Event.buildEventFromDict( fields )
     self.eventQueue.append( evt )
Beispiel #4
0
def _send_event(task, exc, task_id, args, kwargs):
    classkey, summary = _getErrorInfo(task.app, exc)
    name = task.getJobType() if hasattr(task, "getJobType") else task.name
    publisher = getUtility(IEventPublisher)
    event = Event.Event(**{
        "evid": guid.generate(1),
        "device": name,
        "severity": Event.Error,
        "component": "zenjobs",
        "eventClassKey": classkey,
        "eventKey": "{}|{}".format(classkey, name),
        "message": task.description_from(*args, **kwargs),
        "summary": summary,
        "jobid": str(task_id),
    })
    publisher.publish(event)
    log_message = (
        "Event sent  event-class-key=%s summary=%s", classkey, summary,
    )
    task.log.info(*log_message)
    mlog.info(*log_message)
Beispiel #5
0
 def _send_event(self, event_dict):
     if not self._datacollector:
         return
     event = Event.buildEventFromDict(event_dict)
     event.evid = guid.generate(1)
     self.__publisher.publish(event)