MemcachedMonitor has issues (from package org.opennms.netmgt.poller.monitors)

Description

The class has 3 issues:
1) Bug: the code removes all "" before inserting the keys in a HashMap: key = key.replaceAll("", "");
So Memcached results containing "_" such as "curr_items" are never collected.
2) Bug: all of the data is stored as GAUGE but some of the values would be better stored as COUNTER instead.
For this issue the workaround would be to manually create the RRD file with different specs and replace the RRD files created by OpenNMS manually.
3) Enhancement: Memcached 1.4.5 stats has more interesting results that what is listed at:
private static final String[] m_keys = new String[] {
"uptime", "rusageuser", "rusage_system",
"curr_items", "totalitems", "bytes",
"currconnections", "totalconnections", "connectionstructure",
"cmdget", "cmdset", "gethits", "getmisses", "evictions",
"bytesread", "byteswritten", "threads"
(such as: delete_misses, delete_hits)

I've seen some people running scripts through Net-SNMP to collect the data via SNMP instead of using this class. In addition, others suggested using the HTTP collector.

I believe this class would be a less expensive way to do the collection, and it would work for environments where we don't have login-access (root) to the Memcached server and therefore can't use the Net-SNMP nor the HTTP collectors (which is my case), or for cases where Net-SNMP and HTTPd are run with minimal permissions (can't execute external scripts and external commands) for security purposes.

1) Please fix the code.

2) Proposed workaround:
rrdtool create memcached.rrd --start 1309804789 --step 300 \ DS:uptime:COUNTER:600:U:U \ DS:rusageuser:GAUGE:600:U:U \ DS:rusage_system:GAUGE:600:U:U \ DS:curr_items:GAUGE:600:U:U \ DS:totalitems:GAUGE:600:U:U \ # this could be a COUNTER too
DS:bytes:GAUGE:600:U:U \ DS:currconnections:GAUGE:600:U:U \ DS:totalconnections:GAUGE:600:U:U \ # this could be a COUNTER too
DS:connectionstructure:GAUGE:600:U:U \ DS:cmdget:COUNTER:600:U:U \ DS:cmdset:COUNTER:600:U:U \ DS:gethits:COUNTER:600:U:U \ DS:getmisses:COUNTER:600:U:U \ DS:evictions:GAUGE:600:U:U \ DS:bytesread:COUNTER:600:U:U \ DS:byteswritten:COUNTER:600:U:U \ DS:threads:GAUGE:600:U:U \ DS:memcached:GAUGE:600:U:U \ RRA:AVERAGE:0.5:1:2016 \ RRA:AVERAGE:0.5:12:1488 \ RRA:AVERAGE:0.5:288:366 \ RRA:MAX:0.5:288:366 \ RRA:MIN:0.5:288:366

Proposed change: let the user configure what stats to collect data for and the type of the data (GAUGE, COUNTER, etc) in a similar fashion to datacollection-config.xml

Memcached 1.4.5 currently has:
STAT pid 2423
STAT uptime 2401955
STAT time 1310485691
STAT version 1.4.5
STAT pointer_size 64
STAT rusage_user 2.430630
STAT rusage_system 1.840720
STAT curr_connections 5
STAT total_connections 29902
STAT connection_structures 12
STAT cmd_get 297
STAT cmd_set 22
STAT cmd_flush 2
STAT get_hits 273
STAT get_misses 24
STAT delete_misses 0
STAT delete_hits 2
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 365550
STAT bytes_written 24035501
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 6816
STAT curr_items 5
STAT total_items 19
STAT evictions 0
STAT reclaimed 4

Environment

Solaris 10 / Sparc 64-bit

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Zeca Stevenson August 2, 2011 at 2:37 PM

There is a quick-fix for this issue that can be done before any improvements are developed - declaring m_keys as:

private static final String[] m_keys = new String[] {
"uptime", "rusageuser", "rusagesystem",
"curritems", "totalitems", "bytes",
"currconnections", "totalconnections", "connectionstructure",
"cmdget", "cmdset", "gethits", "getmisses", "evictions",
"bytesread", "byteswritten", "threads"

(removing "_" from the strings)

I've been having a hard time to configure Git at my PC at work for 2 reasons:
1) I'm used with Netbeans and I don't know how to configure Eclipse (now the EGit plugin is installed though)
2) the network here is very restrictive (I only have access to the Web via proxy servers - HTTP Only)

Would you mind making this small change a compiling it in the next build?

Thanks,
Zéca.

Tarus Balog July 14, 2011 at 7:41 AM

This was started in but I've closed that and moved it here. I think all of these should be counters:

The following values should be counters:

bytesread
byteswritten
rusageuser
rusage_system
cmdget
cmdset
gethits
getmisses
evictions

Details

Assignee

Reporter

Affects versions

Priority

PagerDuty

Created July 12, 2011 at 11:53 AM
Updated July 26, 2023 at 2:19 PM