We love monitoring things, and we also love memcached!

Monitoring or testing a memcached instance that is using TCP is fairly straight forward, but we recently ran into a situation where a client was using UNIX file sockets and had to take a step back. You can’t just telnet to a socket file.

… or can you? It turns out socat lets you do basically that.

Once installed you can interact with memcached via it’s socket file directly like this:

socat -v UNIX-CONNECT:/tmp/memcached.sock STDIN

Whatever you type will be sent to memcached, just like a telnet session.

You can also use something like this for a more automated approach (say for monitoring probes):

echo "stats" | socat -v "UNIX-CONNECT:/tmp/memcached.sock" STDIN 2>&1 | sed -e s:"\\\r":"":g | grep -v "Broken pipe" 

Happy socketing!

Leave a Reply

Your email address will not be published. Required fields are marked *