Thursday, April 22, 2010

Installing the memcached Munin plugin

Munin doesn't ship with a memcached plugin. Almost all links that point to that plugin on the Munin wiki are broken. I finally found it here. Here's what I did to get it to work:
  • Download raw text of the plugin. I saved it as "memcached_". Replace @@PERL@@ variable at the top of the file with the path to perl on your system. Make memcached_ executable.
On the munin node that you want to get memcached stats for (ideally you'd add these steps to your automated deployment scripts; I added them in a fabric file called fab_munin.py):
  • Copy memcached_ in /usr/share/munin/plugins (or equivalent for your system)
  • Make 3 symlinks in /etc/munin/plugins to the memcached_ file, but name each symlink according to the metric that will be displayed in the munin graphs:
    • ln -snf /usr/share/munin/plugins/memcached_ memcached_bytes
    • ln -snf /usr/share/munin/plugins/memcached_ memcached_counters
    • ln -snf /usr/share/munin/plugins/memcached_ memcached_rates
  • Install the Perl Cache::Memcached module (you can do it via the cpan cmdline utility)
  • Restart the munin-node service
At this point you should see 3 graphs for memcached on the munin dashboard:
  • "Network traffic" (from the 'bytes' symlink)
  • "Current values" such as bytes allocated/current connections/current items (from the 'counters' symlink)
  • "Commands" such as cache misses/cache hits/GETs/SETs (from the 'rates' symlink).

10 comments:

Yashh said...

sweet! just followed your instructions and got them running. Thanks.... Keep sharing your experiences, they are very helpful

pauloamgomes said...

many thanks, i follow your instructions and got it work..

Anonymous said...

very helpful, thanks!

Anonymous said...

Thanks a lot, very simple to understand!!

Anonymous said...

very helpful!
thank you!

P.S. this errors means that plugin can't connect to memcached (on my problem this was caused by firewall)


Use of uninitialized value $sock in ref-to-glob cast at /usr/share/perl5/Cache/Memcached.pm line 362.
Use of uninitialized value in vec at /usr/share/perl5/Cache/Memcached.pm line 362.
Use of uninitialized value $sock in ref-to-glob cast at /usr/share/perl5/Cache/Memcached.pm line 369.
Use of uninitialized value in vec at /usr/share/perl5/Cache/Memcached.pm line 369.
Use of uninitialized value $sock in ref-to-glob cast at /usr/share/perl5/Cache/Memcached.pm line 370.
send() on unopened socket at /usr/share/perl5/Cache/Memcached.pm line 370.
Use of uninitialized value $res in numeric gt (>) at /usr/share/perl5/Cache/Memcached.pm line 373.
Use of uninitialized value $sock in hash element at /usr/share/perl5/Cache/Memcached.pm line 180.
Use of uninitialized value $sock in hash element at /usr/share/perl5/Cache/Memcached.pm line 167.

Anonymous said...

Thanks for the write-up. Worked great.

Michael said...

Installing via debian packages is simpler for ubuntu:
apt-get install libcache-memcached-perl

Anonymous said...

on ubuntu you can install the memcached plugin like this:

apt-get install munin-plugins-extra

Glenn Plas said...

Thanks for the pointers, worked like a charm on 4 machines in as many minutes.

Unknown said...

Getting Bad Exit when fetching

CentOS 5.8

yum install perl-Cache-Memcached.noarch

Fixed it

Modifying EC2 security groups via AWS Lambda functions

One task that comes up again and again is adding, removing or updating source CIDR blocks in various security groups in an EC2 infrastructur...