Tech Blog

Test memcached Using UNIX File Sockets

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...

Published
April 10, 2017
Author
Adam Strohl
Reading time
1 minute

Test memcached Using UNIX File Sockets

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!

Need help with Linux or FreeBSD infrastructure?

A-Team Systems provides engineer-led support for production Linux and FreeBSD environments, including troubleshooting, operational oversight, and ongoing infrastructure management.

Contact A-Team Systems