def __init__(self, taskName, configId, scheduleIntervalSeconds=60, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._preferences = self._daemon self.options = self._daemon.options # This will take a bit to catch up, but.... self.interval = self.options.cycletime # Allow MailProcessor to work unmodified self.sendEvent = self._eventService.sendEvent self._daemon.changeUser() self.processor = POPProcessor(self,self.options.eventseverity) self._connection = None
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for ZCA interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._statService = zope.component.queryUtility(IStatisticsService) self._preferences = self._daemon self.options = self._daemon.options self._daemon.changeUser() self.processor = None log.info('Starting AMQP consumption...') self.channel.basic_consume(self.callback, queue=queue, no_ack=True) self.channel.start_consuming()
def __init__( self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__( self, taskName, configId, scheduleIntervalSeconds, taskConfig ) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._daemon = getUtility(ICollector) self._eventService = queryUtility(IEventService) self._preferences = self._daemon self._statService = queryUtility(IStatisticsService) # For compatibility with captureReplay self.options = self._daemon.options self.oidMap = self._daemon.oidMap self.stats = Stats() # Command-line argument sanity checking self.processCaptureReplayOptions() self.session = None self._replayStarted = False if not self.options.replayFilePrefix: trapPort = self._preferences.options.trapport if not self.options.useFileDescriptor and trapPort < 1024: listen_ip = "ipv6" if ipv6_is_enabled() else "0.0.0.0" # Makes call to zensocket here # does an exec* so it never returns self._daemon.openPrivilegedPort( '--listen', '--proto=udp', '--port=%s:%d' % (listen_ip, trapPort) ) self.log("Unexpected return from openPrivilegedPort. Exiting.") sys.exit(1) # Start listening for SNMP traps self.log.info("Starting to listen on SNMP trap port %s", trapPort) self.session = netsnmp.Session() listening_protocol = "udp6" if ipv6_is_enabled() else "udp" if self._preferences.options.useFileDescriptor is not None: # open port 1162, but then dup fileno onto it listening_address = listening_protocol + ':1162' fileno = int(self._preferences.options.useFileDescriptor) else: listening_address = '%s:%d' % (listening_protocol, trapPort) fileno = -1 self._pre_parse_callback = _pre_parse_factory(self._pre_parse) debug = self.log.isEnabledFor(logging.DEBUG) self.session.awaitTraps( listening_address, fileno, self._pre_parse_callback, debug ) self.session.callback = self.receiveTrap twistedsnmp.updateReactor()
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._statService = zope.component.queryUtility(IStatisticsService) self._preferences = self._daemon self.options = self._daemon.options self.stats = Stats() if not self.options.useFileDescriptor\ and self.options.syslogport < 1024: self._daemon.openPrivilegedPort( '--listen', '--proto=udp', '--port=%s:%d' % (self.options.listenip, self.options.syslogport)) self._daemon.changeUser() self.minpriority = self.options.minpriority self.processor = None if self.options.logorig: self.olog = logging.getLogger('origsyslog') self.olog.setLevel(20) self.olog.propagate = False lname = zenPath('log/origsyslog.log') hdlr = logging.FileHandler(lname) hdlr.setFormatter(logging.Formatter('%(message)s')) self.olog.addHandler(hdlr) if self.options.useFileDescriptor is not None: self.useUdpFileDescriptor(int(self.options.useFileDescriptor)) else: reactor.listenUDP(self.options.syslogport, self, interface=self.options.listenip) # yield self.model().callRemote('getDefaultPriority') self.processor = SyslogProcessor(self._eventService.sendEvent, self.options.minpriority, self.options.parsehost, self.options.monitor, self._daemon.defaultPriority)
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._preferences = self._daemon self._statService = zope.component.queryUtility(IStatisticsService) # For compatibility with captureReplay self.options = self._daemon.options self.oidMap = self._daemon.oidMap self.stats = Stats() # Command-line argument sanity checking self.processCaptureReplayOptions() self.session=None self._replayStarted = False if not self.options.replayFilePrefix: trapPort = self._preferences.options.trapport if not self._preferences.options.useFileDescriptor and trapPort < 1024: listen_ip = "ipv6" if ipv6_is_enabled() else "0.0.0.0" # Makes call to zensocket here (does an exec* so it never returns) self._daemon.openPrivilegedPort('--listen', '--proto=udp', '--port=%s:%d' % (listen_ip, trapPort)) self.log("Unexpected return from openPrivilegedPort. Exiting.") sys.exit(1) # Start listening for SNMP traps self.log.info("Starting to listen on SNMP trap port %s", trapPort) self.session = netsnmp.Session() listening_protocol = "udp6" if ipv6_is_enabled() else "udp" if self._preferences.options.useFileDescriptor is not None: # open port 1162, but then dup fileno onto it listening_address = listening_protocol + ':1162' fileno = int(self._preferences.options.useFileDescriptor) else: listening_address = '%s:%d' % (listening_protocol, trapPort) fileno = -1 self._pre_parse_callback = _pre_parse_factory(self._pre_parse) debug = self.log.isEnabledFor(logging.DEBUG) self.session.awaitTraps(listening_address, fileno, self._pre_parse_callback, debug) self.session.callback = self.receiveTrap twistedsnmp.updateReactor()
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._statService = zope.component.queryUtility(IStatisticsService) self._preferences = self._daemon self.options = self._daemon.options self.stats = Stats() if not self.options.useFileDescriptor\ and self.options.syslogport < 1024: self._daemon.openPrivilegedPort('--listen', '--proto=udp', '--port=%s:%d' % (self.options.listenip, self.options.syslogport)) self._daemon.changeUser() self.minpriority = self.options.minpriority self.processor = None if self.options.logorig: self.olog = logging.getLogger('origsyslog') self.olog.setLevel(20) self.olog.propagate = False lname = zenPath('log/origsyslog.log') hdlr = logging.FileHandler(lname) hdlr.setFormatter(logging.Formatter('%(message)s')) self.olog.addHandler(hdlr) if self.options.useFileDescriptor is not None: self.useUdpFileDescriptor(int(self.options.useFileDescriptor)) else: reactor.listenUDP(self.options.syslogport, self, interface=self.options.listenip) # yield self.model().callRemote('getDefaultPriority') self.processor = SyslogProcessor(self._eventService.sendEvent, self.options.minpriority, self.options.parsehost, self.options.monitor, self._daemon.defaultPriority)
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._preferences = self._daemon self.options = self._daemon.options # Allow MailProcessor to work unmodified self.sendEvent = self._eventService.sendEvent if (self.options.useFileDescriptor < 0 and \ self.options.listenPort < 1024): self._daemon.openPrivilegedPort( '--listen', '--proto=tcp', '--port=%s:%d' % (self.options.listenip, self.options.listenPort)) self._daemon.changeUser() self.processor = MailProcessor(self, self.options.eventseverity) self.factory = SMTPFactory(self.processor) log.info("listening on %s:%d" % (self.options.listenip, self.options.listenPort)) if self.options.useFileDescriptor != -1: self.useTcpFileDescriptor(int(self.options.useFileDescriptor), self.factory) else: reactor.listenTCP(self.options.listenPort, self.factory, interface=self.options.listenip)
def __init__(self, taskName, configId, scheduleIntervalSeconds=3600, taskConfig=None): BaseTask.__init__(self, taskName, configId, scheduleIntervalSeconds, taskConfig) self.log = log # Needed for interface self.name = taskName self.configId = configId self.state = TaskStates.STATE_IDLE self.interval = scheduleIntervalSeconds self._preferences = taskConfig self._daemon = zope.component.getUtility(ICollector) self._eventService = zope.component.queryUtility(IEventService) self._preferences = self._daemon self.options = self._daemon.options # Allow MailProcessor to work unmodified self.sendEvent = self._eventService.sendEvent if (self.options.useFileDescriptor < 0 and \ self.options.listenPort < 1024): self._daemon.openPrivilegedPort('--listen', '--proto=tcp', '--port=%s:%d' % ( self.options.listenip, self.options.listenPort)) self._daemon.changeUser() self.processor = MailProcessor(self, self.options.eventseverity) self.factory = SMTPFactory(self.processor) log.info("listening on %s:%d" % ( self.options.listenip, self.options.listenPort)) if self.options.useFileDescriptor != -1: self.useTcpFileDescriptor(int(self.options.useFileDescriptor), self.factory) else: reactor.listenTCP(self.options.listenPort, self.factory, interface=self.options.listenip)