Showing posts with label memcached. Show all posts
Showing posts with label memcached. Show all posts

Oct 1, 2010

Zabbix's template to monitor Memcached

Today's topic is about monitoring Memcached instance. There are several ways/tools to monitor Memcached such as Munin, Nagios and Zabbix. I used to work with several monitoring tools but the most effective & my favorite one is Zabbix. I will discuss my impression about Zabbix later.

How to monitor Memcached's instance by using Zabbix
  1. Import Memcached's template from this link to your Zabbix server
  2. Modify /etc/zabbix/zabbix_agentd.conf and add the following UserParameter (on the Memcached server)
    UserParameter=memcached_stats[*],echo -e "stats\nquit" | nc 127.0.0.1 $1 | grep "STAT $2 " | awk '{print $$3}'
  3. Restart Zabbix agentd service
  4. Link Mecached template to Memcached server
  5. Check the latest data (Application: memcached)
What are inside this template
  • 38 Items (default type is Zabbix Agent Active)
  • 1 trigger
  • 4 graphs
Note
  • This template tries to monitor Memcached instance that running on port 11211
  • If your Memcached instance is running in different port, you could simply replace 11211 with your port number before importing this template
  • If you run more than one Memcached instances, you could simply copy this and modify port number.

Sep 27, 2010

Running multiple instances of Memcached on CentOS

If you install Memcached via Yum or RPM, you will get the following main scripts

  1. memcached binary (may be at /usr/bin/memcached)
  2. /etc/sysconfig/memcached which is the main configuration of memcached
  3. /etc/init.d/memcached which is the startup script of memcached
The above files could run only one instance of memcached, i usually ignore those scripts (no: 2,3) and use direct command line to run multiple instancs of memcached. However this method lacks system administration and is too difficult to maintain. You have to put your multiple command lines into /etc/rc.local. 

Another solution to support this idea is, modify /etc/init.d/memcached to read all configuration of /etc/sysconfig/memcached_* and use those information to start the daemon.

Here is the link to /etc/init.d/memcached

Here is the link to /etc/sysconfig/memcached_11211

After upload the scripts to the server, please
  • Create a folder at /var/run/memcached
  • Change owner of /var/run/memcached to "nobody" and change mode to 755
Usage:
  • Startup command
    # /etc/init.d/memcached start
    # /etc/init.d/memcached start memcached_11211
  • Status command
    # /etc/init.d/memcached status
    # /etc/init.d/memcached status memcached_11211
  • Stop command
    # /etc/init.d/memcached stop
    # /etc/init.d/memcached stop memcached_11211
Note
  • You could create more than one instances of memcached by using 1 startup script by copy & modify /etc/sysconfig/memcached_11211 to memcached_PORT 
  • Don't forget to change the startup parameters inside that file especially the port number
  • Original version of /etc/init.d/memcached is modified from here
  • The block layout of /etc/init.d/memcached is not so good, but it works for me.