How does one go about monitoring memcached stats in OpenNMS
memcachedmonitoringopennmsstats
I'd like to go about compiling data for size and hits…
Best Answer
Create the following script (and make it executable):
#!/bin/bash
exec 5<> /dev/tcp/127.0.0.1/11211
if [ $? -eq 0 ]; then
echo "stats" >&5
echo "quit" >&5
while read -u 5 -d $'\r' stat name value;
do
echo $value
done
exit 0
fi
exit 1
Mine is /usr/local/bin/memcached_stats.sh
It connects to the memcached daemon and spits out a sanitized version of the memcached stats command and output something like:
There's the already mentioned pgsnmpd but it doesn't seem to be maintained actively (last release in August 2007). I'd rather recommend using the check_postgres Nagios plugin with the NRPE plugin of OpenNMS.
When one of the server crashes, all entries owned by that server is lost. Higher resilience can be achieved by storing redundant copies of data in different servers. Memcached has no support for data replication. This has to be taken care by the application (or client lib).
Note that the default server hashing algorithm doesn't handle the growth and shrink of the number of servers very well. When the number of servers changes, the ownership equation (key mod N) will all be wrong. In other words, if the crashed server needs to be taken out from the pool, the total number of servers will be decreased by one and all the existing entries needs to be redistributed to different server. Effectively, the whole cache (among all server) is invalidated even when just one server crashes.
Best Answer
Create the following script (and make it executable):
Mine is /usr/local/bin/memcached_stats.sh
It connects to the memcached daemon and spits out a sanitized version of the memcached stats command and output something like:
Add the following to your /etc/snmp/snmpd.conf and restart snmpd:
This creates a table based on the output of the script where each line gets its own node.
If you want to confirm this run the following:
You should get something like:
From that you can extrapolate which node is which stat, but lucky for you I've done all that already.
In datacollection-config.xml add the following to the top, but after all the rrd config:
Then in the groups section add the following:
And finally further down you want to find the systemDef tags for Net-SNMP & Net-SNMP (UCD) and add the following within the collect tags:
Restart OpenNMS and and there you have it... when capsd rescans the hosts it'll start gathering these statistics
Below is a reference for the data that can be got from memcached:
All that is left is to build whatever graphing or reporting you'd like.
(Works on CentOS 5.2, OpenNMS 1.5.93-1, net-snmp 5.3.1, memcached 1.2.2)