Original works, allow reprint, please be sure to use hyperlinks in the form of the original source of the article, author information and this statement. Otherwise, the legal liability will be investigated. HTTP://STORYSKY.BLOG.51CTO.COM/628458/244962 recently deployed the Memcached service on a server based on programmer needs, although it was used, but not very well known to him. He began to collect and collate his information, part of which was his monitoring.
At the moment I know about the following methods of monitoring:
First, memcache.php this east is the simplest, as long as the support PHP environment can be used, put this file in your Web page storage directory You can access the method http://ip/memcache.php
Http://livebookmark.net/memcachephp/memcachephp.zip
Http://blogimg.chinaunix.net/blog/upfile2/081230231118.zip
Note that there are several options that you need to modify before using
Vim memcache.php
.....
Define (' Admin_username ', ' memcache '); Define user Name
Define (' Admin_password ', ' PASSWORD '); Define Password
.....
$MEMCACHE _servers[] = ' mymemcache-server:11211 '; Define the IP and port to view
$MEMCACHE _servers[] = ' mymemcache-server2:11212 '; You can add multiple
Other content slightly
The above figure is the effect of the visit, is not very intuitive?
Second, use Memcached's own command to check
telnet localhost 11211
Trying 127.0.0.1 ...
Connected to Localhost.localdomain (127.0.0.1).
Escape character is ' ^] '.
Stats
STAT PID 24567
STAT Uptime 6576
STAT Time 1261035123
STAT version 1.4.3
.....
STAT bytes 64035
STAT Curr_items 41
STAT Total_items 96
STAT Evictions 0
END
But this method I feel inconvenient, from the Internet to find another good way, that is, using Nagios's Check_tcp (Mixi method)
Check_tcp-h localhost-p 11211-t 5-e-S ' stats\r\nquit\r\n '-e ' uptime '-m crit output results similar to the above
TCP OK-0.001 Second response time on port 11211 [STAT pid 10663
STAT Uptime 76444
STAT Time 1259641750
STAT version 1.4.2
..... Middle omitted
STAT bytes 1385408560
STAT Curr_items 227799
STAT Total_items 5012750
STAT Evictions 0
End]|time=0.001142s;;;0. 000000;5.000000
So we can add a command to Nagios to see his running state.
But this is not enough, I also need to memcached in the event of a problem in the mail or text to notify me, below to introduce a better way
Iii. the check_memcached of Nagios
:
Http://search.cpan.org/CPAN/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz
Http://cpan.uwinnipeg.ca/cpan/authors/id/Z/ZI/ZIGOROU/Nagios-Plugins-Memcached-0.02.tar.gz
This script is made in Perl, so you have to make sure you have a Perl environment in your machine, but it will usually be installed by default.
[email protected] soft]# which Perl
/usr/bin/perl
Download down after install
[Email protected] soft]# tar xzvf nagios-plugins-memcached-0.02.tar.gz
[Email protected] soft]# CD nagios-plugins-memcached-0.02
[Email protected] nagios-plugins-memcached-0.02]# Perl makefile.pl
After execution, there will be some hints for you to choose, to follow your own ideas or to return to the same pass
[[email protected] nagios-plugins-memcached-0.02]# make
Then he downloads something that needs to be run.
[[email protected] nagios-plugins-memcached-0.02]# make install
By default, the check_memcached file is placed in the/usr/bin/check_memcached
It's okay to copy him under Nagios's libexec.
Add a few in the commands.cfg (here I did not put check_memcached on the memcached server, but through Nagios check_memcached directly to access the memcached server 11211 port , of course, you can also install him on the memcached server using Check_nrpe to fetch his value)
Define Command {
Command_name check_memcached_11211
Command_line $USER 1$/check_memcached-h 192.168.1.139:11211--size-warning--size-critical 90
}
The above is to monitor the memcached memory usage ratio
Define Command {
Command_name memcached_response_11211
Command_line/usr/local/bin/check_memcached-h 192.168.1.139-w 300-c 500
}
This is used to monitor whether memcached has a response.
Define Command {
Command_name Check_memcached_hit
Command_line/usr/local/bin/check_memcached-h 192.168.1.139--hit-warning--size-critical 5
}
This is the hit rate.
Finally, add something to the services.cfg.
Define Service{
HOST_NAME XmanWeb1
Service_description memcached_11211
Check_command check_memcached_11211
Max_check_attempts 3
Normal_check_interval 3
Retry_check_interval 2
Check_period 24x7
Notification_interval 10
Notification_period 24x7
Notification_options W,u,c,r
Contact_groups Babelgroup
}
The others can be added according to their own requirements.
Okay, let's restart the Nagios service.
/etc/init.d/nagios restart
Look at the results
Oh well, Nagios monitoring memcached Basic is done.
Also according to Check_tcp-h Localhost-p 11211-t 5-e-S ' stats\r\nquit\r\n '-e ' uptime '-M crit
The output of the results of their own script to detect memcached, here I will not say more ...
You can also use the results of check_tcp combined with cacti to make memcached traffic views, of course cacti also have a template specifically for memcached (but my template has not been able to catch data ...)
I hope that after reading my article can be convenient to achieve memcached monitoring O (∩_∩) o~
This article is from the "Story Sky" blog, be sure to keep this source http://storysky.blog.51cto.com/628458/244962
Several methods of memcached monitoring (Nagios, etc.)