Created
October 30, 2013 16:39
-
-
Save ralphbean/7235854 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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