Python connector to replace netcat in OpenTSDB

I'm trying to use python socket instead of netcat to send metric to OpenTSDB but no luck. Can anyone let me know if this can be done?

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("hostname", port))
s.send("put foo 123456789 12.9 host=dummy")



returns nonzero, so I think the string is actually sent, it's just that OpenTSDB doesn't recognize it. I tried using netcat to send the same string and it works.


source to share

1 answer

OpenTSDB parses line by line, so yes, you need \n

at the end of the line you are sending.



All Articles