from twisted.internet import protocol, reactor
import socket,os
socket_path = "/var/lib/nagios3/rw/live"
class Echo(protocol.Protocol):
def dataReceived(self, data):
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
s.connect(socket_path)
s.send(data)
s.shutdown(socket.SHUT_WR)
answer = s.recv(100000000)
self.transport.write(answer)
class EchoFactory(protocol.Factory):
def buildProtocol(self, addr):
return Echo()
reactor.listenTCP(6557, EchoFactory())
reactor.run()
Showing posts with label livestatus. Show all posts
Showing posts with label livestatus. Show all posts
Thursday, July 4, 2013
Bind livestatus unix socket to TCP socket use Python and twisted
Subscribe to:
Posts (Atom)