How to Monitor Memcached Service with Nagios

Nagios Memcached monitoring
Nagios Memcached monitoring

Monitor Memcached Service with Nagios

In this article, we are going to learn how to monitor the Memcached service with the Nagios application.

I hope you already install the Nagios server and NRPE Service. If not or you are new who just started working on Nagios then refer to the below links which help you to clear your doubts regarding Nagios Application.

With the default, Nagios installation will provide only some basics plugins which helps to monitor the general/standard services and application on the server.

In such a case, we need to install custom plugins that help us to monitor particular services and applications on Server.

What is Memcached?

Memcached is a very important part of the caching mechanism. It will help to improve the speed of your website as well as performance. It is our duty to keep an eye on services that are running properly or not.

Nagios will help us with the custom plugin that can monitor the Memcached service.

Below are the important parameters we are going to monitor about Memcached:

  • Total-free-memory
  • Current_items
  • Current_connections
  • Total_connections
  • Limit_maxbytes

Configuration of Custom Memcached Plugin

Step 1: Install dependency packages

To run the custom plugin of Memcache you need to first install the dependency package on the server which supports the Memcached plugin.

Run below command to install package,

$ apt-get install libcache-memcached-perl

Step 2: Download Custom Memcached Plugin

Now download the Memcache custom plugin which is used to fetch or monitor Memcache service on the host server.

Download Plugin and paste it to below path,

$ cd /usr/local/nagios/libexec

$ wget https://www.linuxgrow.com/wp-content/uploads/check_memcached.pl.zip

Step 3: Give Permissions

Give executable permission to check_memcached.pl plugin using the below commands,

$ chmod +x check_memcached.pl

Step 4: Configure Memcached Plugin

Open file “nrpe.cfg” which basically resides under /etc/nagios directory.

Add below Memcached monitoring command which helps to fetch information from the host server and send it to the Nagios server.

vim /etc/nagios/nrpe.cfg

command[check_memcached]=/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip -p 11211 -t ping

command[check_memcached_threads]=/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip –threads=WARN:5,CRIT:8

Save and close the file.

You can also use the below parameters for monitoring use threshold values of warning and critical as per your requirement.

/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip --total_free=WARN:value,CRIT:value

/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip --curr_items=WARN:value,CRIT:value

/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip --total_connections=WARN:value,CRIT:value

/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip --curr_connections=WARN:value,CRIT:value

/usr/local/nagios/libexec/check_memcached.pl -H memcached-ip --limit_maxbytes=WARN:value,CRIT:value

Note: To check some other parameters with their threshold values use the below help command.

/usr/local/nagios/libexec/check_memcached.pl -help

Step 5: Configuration on Nagios Server

Now come to Nagios server and go to the “/usr/local/nagios/etc/” directory. Create a file under the remote host directory which I already explained in the previous article.

For more understanding refer link,

Here i have created file in “/usr/local/nagios/etc/clients” directory with name of “memcached-service-hosts.cfg”.

vim /usr/local/nagios/etc/clients/memcached-service-hosts.cfg

define service {
             use  generic-service
             host_name   nagios_host
             service_description   Memcached Processes
             check_command   check_nrpe!check_memcached
}
define service {
             use   generic-service
             host_name   nagios_host
             service_description   Memcached Memory Usage
             check_command   check_nrpe!check_memcached_threads
}

Save and close the file.

Step 6: Verify Configuration & Restart Nagios Service

Give permission to created files and restart the nrpe and Nagios service.

$ chown -R nagios.nagioscmd memcached-service-hosts.cfg

$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

$ /etc/init.d/nagios-nrpe-server restart

$ /etc/init.d/nagios restart
Memcached Monitoring

If you’re facing any difficulties while configuring Memcached service monitoring. Please do comment on your queries or problem via the comment section, till then stay tuned to Linuxgrow.com for more such valuable articles.

Thank You 🙂

Prashant

Welcome to Linuxgrow. I'm Prashant, a tech-blogger from Mumbai, India. I started Linuxgrow as a passion and to share my knowledge about technologies. Here at Linuxgrow, I write about Linux technologies, Aws Cloud, Wordpress blogging and scripting knowledge. You can read more about me at About us page. Thank You :)

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Facebook