Tuesday, November 11, 2014

memcached-zabbix-template monitor

This is a minimal template to get info from your Memcached server from two possible places. Via zabbix-agentd in clients or via externalscripts in zabbix server. Choose your option.

Monitoring information by now:
  • 'bytes', 
  • 'cmd_get', 
  • 'cmd_set', 
  • 'curr_items', 
  • 'curr_connections', 
  • 'limit_maxbytes', 
  • 'uptime', 
  • 'get_hits', 
  • 'get_misses', 

And the special HIT-ratio in %:
  • 'ratio' 

Installation in the Zabbix Server

You should look for the external scripts directory in your Zabbix Server configuration file. In the CentOS 6.5 RPM Zabbix installation is: /usr/lib/zabbix/externalscripts

Copy the python script there. A chmod/chown to get execution permission is necessary.

Now, in your Zabbix frontend: Configuration-Templates section, Import bottom in the right side.

Choose the XML file and import.

Apply this new template to your Memcached servers.

You don't need to modify the template if you are using the standard port to access to the Memcached (port 11211).

It permits a fast configuration because of you can apply the same template to all your memcached servers without modification/installation in the agents.

Of course, it can be to work in the agent/client side too.




You can find it in my repo: https://github.com/vicendominguez/memcached-zabbix-template

:)

6 comments:

  1. I installed zabbix server 2.4 RPM package on Centos 6.3.

    The default config file on the zabbix server /usr/local/etc/zabbix_server.conf as below:
    412 ### Option: ExternalScripts
    413 # Full path to location of external scripts.
    414 # Default depends on compilation options.
    415 #
    416 # Mandatory: no
    417 # Default:
    418 # ExternalScripts=${datadir}/zabbix/externalscripts

    And i put getMemcachedInfo.py into the /usr/local/share/zabbix/externalscripts folder and changed mode bits of this file (-rwxrwxrwx 1 root zabbix 2661 11月 25 11:59 getMemcachedInfo.py)
    root@Localhost# ./getMemcachedInfo.py -h 172.27.4.56 -p 11211 -a uptime
    root@Localhost# 11329961
    Looks good so far.
    Next,I imported the template,linked to the hosts of memcached server, and the graph schema of memcached_key_info and memcached_memory_space shows up.
    BUT, there's still NO DATA on these graph after a few miniutes.
    I'm missed sth. ?

    ReplyDelete
  2. Hello 朱金贺 !!!! I don't see any problem there. Check this workflow:

    1.- one note: Not tested in 2.4 yet.
    2.- please you remember i am using {HOST.HOST} macro in the template.... check what should be the host.host field in your host configuration?
    3.- try to find the error log line in the zabbix server log file.
    4.- try to see if the plugin is in "supported" state in the host/template.

    Vicente

    ReplyDelete
  3. I think I've figured out the reason of the failuer under your guidance,BIG THANKS.
    There is no items defined on these hosts.
    Error log show just like running "./getMemcachedInfo.py -h {HOST.HOST} -p 11211 -a curr_items" command direcory.

    Here is the error log:
    Traceback (most recent call last):
    File "./getMemcachedInfo.py", line 96, in
    main(memcachedServer, memcachedPort)
    File "./getMemcachedInfo.py", line 89, in main
    items = data.read()
    File "./getMemcachedInfo.py", line 40, in read
    self._read_stats()
    File "./getMemcachedInfo.py", line 46, in _read_stats
    connection = Telnet(self._server, self._port)
    File "/usr/lib64/python2.6/telnetlib.py", line 209, in __init__
    self.open(host, port, timeout)
    File "/usr/lib64/python2.6/telnetlib.py", line 225, in open
    self.sock = socket.create_connection((host, port), timeout)
    File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    socket.gaierror: [Errno -2] Name or service not known

    Can you guide me how to define HOST.HOST items on my host/template?Cause I can find any default items of IP ADDRESS in this page [https://www.zabbix.com/documentation/2.4/manual/config/items/itemtypes/zabbix_agent]

    And,there are multi-network-interface on my hosts.
    zabbix_get -s 172.27.4.56 -k net.if.discovery
    {"data":[{"{#IFNAME}":"lo"},{"{#IFNAME}":"eth0"},{"{#IFNAME}":"eth1"}]}

    Looking forward to your share about definition of {HOST.HOST} items.

    朱金贺


    ReplyDelete
  4. As far I know {HOST.HOST} macro is supported in zabbix 2.4. It is automatic from the hostname/IP field of your host configuration. So be sure host is configured OK and memcache is reachable please. In any case, you can change the macro and put your memcache server IP in the template for testing.l it...

    ReplyDelete
  5. Changing HOST.HOST to HOST.CONN in the templato in git to avoid the 朱金贺 issues

    ReplyDelete