Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log Memcached Activity

Tags:

memcached

I'm looking to log all activity going on in my memcached server. All reads and writes.

This is going to be used as a distributed daemon for lots of remote php apps in the cloud and need a way to SSH in and check out the activity going on, on the daemon.

I've googled extensively and can't find a single way to do this.

The Redis equivalent would be logging into the interactive console and typing MONITOR.

Thanks in advance.

like image 852
Paul Dragoonis Avatar asked Mar 19 '12 11:03

Paul Dragoonis


People also ask

How do I view memcached logs?

If memcached is crashed, you can look into system logs /var/log/messages and /var/log/syslog to check for possible error conditions.

Where is memcached config file?

The default Memcached configuration file is located in the /etc/sysconfig directory.


2 Answers

You can do this using memcached's telnet stats command as such :

  • enable capturing information : stats detail on
  • wait a while
  • disable capturing : stats detail off
  • dump the information : stats detail dump

telnet yourhost 11211 and run the sequence above. Note that this will impact greatly the performance.

Also you could check out phpmemcacheadmin - it's a really nice tool for monitoring memcached pools.

like image 194
capi Avatar answered Sep 27 '22 19:09

capi


You can start your memcached using the -vv parameter:

-vv           very verbose (also print client commands/reponses)

The output is similar to this:

Dec 12 10:33:12 hostname memcached[18350]: <33 new auto-negotiating client connection
Dec 12 10:33:12 hostname memcached[18350]: 33: Client using the ascii protocol
Dec 12 10:33:12 hostname memcached[18350]: <33 set your.key.1 3 300 525
Dec 12 10:33:12 hostname memcached[18350]: >33 STORED
Dec 12 10:33:12 hostname memcached[18350]: <33 get your.key.2
Dec 12 10:33:12 hostname memcached[18350]: >33 sending key your.key.2
Dec 12 10:33:12 hostname memcached[18350]: >33 END

The output is sent to stdout, so you might want to redirect it to some file.

like image 35
falmp Avatar answered Sep 27 '22 18:09

falmp