20150612

How to query a memcache top using shell script

In case you want to watch the most important parameters of your memcache installation you can use this basic shell script:

watch "echo stats | nc 127.0.0.1 11211 |grep -v conn_yields |grep -v time|grep -v cmd|grep -v threads \
|grep -v evictions|grep -v reclaimed|grep -v auth|grep -v pointer_size|grep -v accepting_conns \
|grep -v bytes_read|grep -v bytes_written|grep -v badval|grep -v structures|grep -v pid \
|grep -v version|grep -v rusage|grep -v incr|grep -v decr|grep -v listen|grep -v cas \
|grep -v total_connections|grep -v delete|grep -v total_items|grep -v END"

It shows the most important parameters every two seconds ignoring the other ones, you can tune the showed params removing grep -v commands at your will.

Enjoy!