[Twisted-Python] Syslog Listener UDP

Vincent Bernat bernat at luffy.cx
Sun Sep 28 17:14:04 EDT 2008


OoO  Pendant le  journal télévisé  du dimanche  28 septembre  2008, vers
20:18, "Marc Byrd" <dr.marc.byrd at gmail.com> disait :

> I would like to build a syslog(udp port 514) listener in twisted.  The goal is
> to make it compatible with syslog and syslog-ng, which may be configured on a
> "client" to send log entries (as they occur) via udp (fire and forget) to a
> remote server (my twisted server). 

> Is there already something out there that would do this or that would be a good
> start?

Because  of the  simplicity of  the syslog  protocol, you  can  just use
UDPServer with  a protocol derived from DatagramProtocol.  You just need
to overload datagramReceived to do  something sensible with the log line
received.

In short:

class SyslogInput(protocol.DatagramProtocol):

      def datagramReceived(self, data):
          print "I have received %r" % data

service = internet.UDPServer(514, SyslogInput())
-- 
I WILL NOT BRING SHEEP TO CLASS
I WILL NOT BRING SHEEP TO CLASS
I WILL NOT BRING SHEEP TO CLASS
-+- Bart Simpson on chalkboard in episode 9F06




More information about the Twisted-Python mailing list