Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Some Ways To Get Memcached Stats  (Read 9992 times)

0 Members and 1 Guest are viewing this topic.

Vineesh K P

  • Guest
Some Ways To Get Memcached Stats
« on: November 23, 2018, 03:23:13 pm »
In this article, we will check out some ways to get stats of Memcached.

For this to work, you need to have an ssh access to the server.

Method 1


  • SSH to the server which has Memcached.
  • Connect to Memcached port as shown below.
    telnet 127.0.0.1 11211
  • Once the connection has been established, type stats and hit enter.

An alternate way to do this is by using the nc command.
echo stats | nc 127.0.0.1 11211

You will get results similar to this.
Code: [Select]
STAT pid 22020
STAT uptime 3689364
STAT time 1227753109
STAT version 1.2.5
STAT pointer_size 64
STAT rusage_user 4543.071348
STAT rusage_system 8568.293421
STAT curr_items 139897
STAT total_items 51710845
STAT bytes 360147055
STAT curr_connections 40
STAT total_connections 66762
STAT connection_structures 327
STAT cmd_get 319992973
STAT cmd_set 51710845
STAT get_hits 280700485
STAT get_misses 39292488
STAT evictions 849165
STAT bytes_read 141320046298
STAT bytes_written 544357801590
STAT limit_maxbytes 402653184
STAT threads 4
END

Method 2

Here’s an easy “top” emulator for Memcached:

watch "echo stats | nc 127.0.0.1 11211"

If you don’t have netcat (nc), you can also use Bash’s built-in /proc/tcp magic if it’s enabled. Anything that can push a couple of characters to a TCP port and print the result to stdout will work. Or you can use something like this, if you must do it via PHP:

watch 'php -r '"'"'$m=new Memcache;$m->connect("127.0.0.1", 11211);print_r($m->getstats());'"'"

Hope you found some value in it.

Until next time, cheers!