Skip to content

Instantly share code, notes, and snippets.

@confiq
Created January 25, 2016 12:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save confiq/b59b0c56ff16e15d4c12 to your computer and use it in GitHub Desktop.
send message to 0mq
import zmq
import datetime
def _init():
myzmq = zmq.Context.instance()
publisher = myzmq.socket(zmq.PUB)
publisher.connect("tcp://10.0.100.132:2120")
message = {
"@source": __file__,
"@tags": ["dump_tag", "can_send_email_is_false"],
"@timestamp": datetime.datetime.now().isoformat(),
"@type": 'SelfCheck',
"@fields": '{"field"=>value}',
"@source_host": 'HostX',
"@message": '2015-12-02 05:18:45,742 staging-1:\t[BaseService:getApiSpec:93]\tDEBUG\tgetApiSpec was called and yayayayay\t'
}
publisher.send_json(message)
if __name__ == '__main__':
_init()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment