Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created October 30, 2013 16:39
Show Gist options
  • Save ralphbean/7235854 to your computer and use it in GitHub Desktop.
Save ralphbean/7235854 to your computer and use it in GitHub Desktop.
# This code that goes into moksha looks something like this.
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind('ipc://127.0.0.1:5555')
# So, this can be done way more efficiently than a 'while 1' with zmq.Poller.
# But, nevermind that.. txZMQ allows us to ditch the loop and plug in to the
# Twisted framework for events.
while 1:
# Get request
request = socket.recv()
# debug
print "received request: %r" % request
# Reply with response
socket.send('Oh.. its pretty good.')
# Our nagios/nrpe check would look something like this
import zmq
context = zmq.Context()
socket = context.socket(zmq.REQ)
socket.connect('ipc://localhost:5555')
socket.send("So, how's the weather in there?")
message = socket.recv()
print 'Received reply: %s' % message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment