MEMCACHED

Memcached Multi - A Plugin to monitor Memcached Servers (Multigraph)

 The common difference between this memcached Munin plugin and others that exists, is that
 others don't expose slab information from memcached, so you can better tune your memcached
 interaction / stability / etc. With this plugin we leverage multigraph capabilities in
 Munin to "hide" the slab information underneath of their parent graphs.

MUNIN NODE CONFIGURATION

The following configuration information can be overridden by placing environment definitions like shown here, in a file located in /etc/munin/plugin-conf.d

[memcached_multi_*] env.host 127.0.0.1 *default* env.port 11211 *default* env.timescale 3 *default* env.cmds get set delete incr decr touch *default* env.leitime -1 *default*

MUNIN NODE ENVIRONMENT CONFIGURATION EXPLANATION

 host = host we are going to monitor, this can be used to specify a unix socket.
 port = port we are connecting to, in order to gather stats
 timescale = what time frame do we want to format our graphs too
 cmds = cmd types to display on cmd graph, remove cmds you don't want displayed from list.
 leitime = setting this to 1 will re-enable slab eviction time graphs, see note below.

BASIC TROUBLESHOOTING

Please make sure you can telnet to your memcache servers and issue the following commands: stats, stats settings, stats items and stats slabs.

PLUGIN INFORMATION

Available Graphs contained in this Plugin

bytes => This graphs the current network traffic in and out

commands => MULTIGRAPH This graphs the current commands being issued to the memcache machine. Multigraph breaks this down to per slab.

conns => This graphs the current, max connections as well as avg conns per sec avg conns per sec and is derived from total_conns / uptime.

evictions => MULTIGRAPH This graphs the current evictions on the node. Multigraph breaks this down to per slab.

items => MULTIGRAPH This graphs the current items and total items in the memcached node. Multigraph breaks this down to per slab.

memory => MULTIGRAPH This graphs the current and max memory allocation. Multigraph breaks this down to per slab.

unfetched => MULTIGRAPH This graphs the number of items that were never touched by a get/incr/append/etc before being evicted or expiring from the cache. Multigraph breaks this down to per slab.

ADDITIONAL INFORMATION

NOTE: The slab plugin for LEI has been disabled since I believe the counters to be inaccurate, or perhaps not being updated as often I thought they would be. They can be re-enabled by setting an environment variable, see munin configuration section at the top.

You will find that some of the graphs have LEI on them. This was done in order to save room on space for text and stands for Last Evicted Item.

The Timescale variable formats certain graphs based on the following guidelines. 1 => Seconds 2 => Minutes 3 => Hours *Default* 4 => Days

ACKNOWLEDGEMENTS

Thanks to dormando for putting up with me ;)

AUTHOR

Matt West < https://github.com/mhwest13/Memcached-Munin-Plugin >

LICENSE

GPLv2

MAGIC MARKERS

#%# family=auto #%# capabilities=autoconf suggest

Variable Declarations

    This section of code is to declare the variables used throughout the plugin
    Some of them are imported as environment variables from munin plugin conf.d
    file, others are hashes used for storing information that comes from the
    stats commands issued to memcached.

Graph Declarations

    This block of code builds up all of the graph info for all root / subgraphs.

    %graphs: is a container for all of the graph definition information. In here is where you'll
             find the configuration information for munin's graphing procedure.
    Format:

    $graph{graph_name} => {
        config => {
            You'll find the main graph config stored here
            { key => value },
            { ... },
        },
        datasrc => [
            Name: name given to data value
            Attr: Attribute and value, attribute must be valid plugin argument
            { name => 'Name', info => 'info about graph', ... },
            { ... },
        ],
    }

Munin Checks

    These checks look for config / autoconf / suggest params

Config Check

    This block of code looks at the argument that is possibly supplied,
    should it be config, it then checks to make sure the plugin
    specified exists, assuming it does, it will run the do_config
    subroutine for the plugin specified, otherwise it dies complaining
    about an unknown plugin.

Autoconf Check

    This block of code looks at the argument that is possibly supplied,
    should it be autoconf, we will attempt to connect to the memcached
    service specified on the host:port, upon successful connection it
    prints yes, otherwise it prints no.

Suggest Check

    This block of code looks at the argument that is possibly supplied,
    should it be suggest, we are going to print the possible plugins
    which can be specified. Note we only specify the root graphs for the
    multigraphs, since the rest of the subgraphs will appear "behind" the
    root graphs. It also attempts to connect to the memcached service to
    verify it is infact running.

Output Subroutines

    Output Subroutine calls to output data values

fetch_output

    This subroutine is the main call for printing data for the plugin.
    No parameters are taken as this is the default call if no arguments
    are supplied from the command line.

print_root_output

    This subroutine prints out the return values for our non-multigraph root graphs.
    It takes one parameter $plugin and returns when completed.

        $plugin;    graph we are calling up to print data values for

    Example: print_root_output($plugin);

print_rootmulti_output

    This subroutine prints out the return values for our multigraph root graphs.
    It takes one parameter $plugin and returns when completed.

        $plugin;    root graph we are calling up to print data values for

    Example: print_rootmulti_output($plugin);

print_subrootmulti_output

    This subroutine prints out the return values for our multigraph root graphs, only this set of
    data will display on the subpage made by the multigraph capabilities of munin and the plugin.
    It takes one parameter $plugin and returns when completed.

        $plugin;    root graph we are calling up to print data values for

    Example: print_rootmulti_output($plugin);

print_submulti_output

    This subroutine prints out the return values for our multigraph subgraphs. It takes
    three parameters $slabid, $plugin, @subgraphs and then rReturns when completed.

        $slabid;    slab id that we will use to grab info from and print out
        $plugin;    root graph being called, used for multigraph output and slab id
        @subgraphs; graphs we are actually trying to print data values for

    Example: print_submulti_output($slabid,$plugin,@subgraphs);

Config Subroutines

    These subroutines handle the config portion of munin calls.

do_config

    This is the main call issued assuming we call up config and plugin specified exists
    The subroutine takes one parameter $plugin, and returns when completed.

        $plugin; root graph being called

    Example: do_config($plugin);

print_root_config

    This subroutine prints out the config information for all of the non-multigraph root graphs.
    It takes one parameter, $plugin, returns when completed.

        $plugin;    root graph used for multigraph call

    Example:  print_root_config($plugin);

print_rootmulti_config

    This subroutine prints out the config information for all of the multigraph root graphs.
    It takes one parameter, $plugin, returns when completed.

        $plugin;    root graph used for multigraph call

    Example:  print_rootmulti_config($plugin);

print_subrootmulti_config

    This subroutine prints out the config information for all of the multigraph root graph, only this
    graph of the data will display on the subpage made by the multigraph capabilities of munin and
    the plugin. It takes one parameter, $plugin, returns when completed.

        $plugin;    root graph used for multigraph call

    Example:  print_rootmulti_config($plugin);

print_submulti_config

    This subroutine prints out the config information for all of the multigraph subgraphs.
    It takes three parameters, $slabid, $plugin and @subgraphs, returns when completed.

        $slabid;    slab id that we will use to grab info from and print out
        $plugin;    root graph being called, used for multigraph output and slab id
        @subgraphs; graphs we are actually trying to print data values for

    Example:  print_submulti_config($slabid,$plugin,@subgraphs);

Misc Subroutines

    These subroutines are misc ones, and are referenced inside of the code. They
    should never be called up by Munin.

get_conn

    This subroutine returns a socket connection

fetch_stats

    This subroutine fetches the information from memcached and stores it into our
    hashes for later referencing throughout the graph. Returns when completed

time_scale

    This subroutine is here for me to adjust the timescale of the time graphs
    for last evicted item and age of eldest item in cache.

        Please note, after long usage I have noticed these counters may not
        be accurate, I believe the developers are aware and have submitted
        a patch upstream.

buildglobalmap

    This subroutine looks at the specified commands inputted, and generates
    a hashref containing two arrays, one for global command keys and one for
    slab command keys.