Zabbix监控memcache示例

一、创建memcached-tool脚本

参见http://www.linuxidc.com/Linux/2014-08/105157.htm

mkdir /scripts && cd /scripts && vim memcache-tool.pl
将脚本copy进入memcache-tool.pl
chmod +x /scripts/memcache-tool.pl


二、用脚本查看memcache的各类统计数据

/scripts/memcache-tool.pl 127.0.0.1:11211 stats
#127.0.0.1:11211   Field       Value
         accepting_conns           1
             auth_cmds           0
            auth_errors           0
                bytes           0
             bytes_read          94
             bytes_written        5261
            cas_badval           0
              cas_hits           0
             cas_misses           0
              cmd_flush           0
               cmd_get           0
               cmd_set           0
              cmd_touch           0
            conn_yields           0
      connection_structures          11
         curr_connections          10
             curr_items           0
              decr_hits           0
            decr_misses           0
            delete_hits           0
           delete_misses           0
        evicted_unfetched           0
              evictions           0
         expired_unfetched           0
               get_hits           0
              get_misses           0
                 hash_bytes      524288
         hash_is_expanding           0
          hash_power_level          16
              incr_hits           0
             incr_misses           0
               libevent        2.0.21-stable
           limit_maxbytes        134217728
        listen_disabled_num           0
                    pid       10459
             pointer_size          64
               reclaimed           0
             reserved_fds          20
              rusage_system    0.121024
               rusage_user    0.045384
               threads           4
                   time      1426727521
         total_connections          18
             total_items           0
              touch_hits           0
            touch_misses           0
                  uptime        2574
                 version      1.4.15

三、在zabbix_agent.conf中自定义UserParameter

修改以下的参数:

UnsafeUserParameters=1
UserParameter=MemcacheStats[*],/scripts/memcache-tool.pl 127.0.0.1:11211 stats|grep $1 |awk ‘{print $NF}‘

然后重启zabbix_agent进程


四、在zabbix中添加item

例如,添加当前“curr_connections”

技术分享

保存即可。


*如果出现“Not supported by Zabbix Agent”的错误,

通过下面的命令得到详细的信息:

zabbix_agent -t MemcacheStats[curr_connections]]

或者修改zabbix_server.conf中的

Timeout=3  #将这个值调整的大一点

本文出自 “缘随心愿” 博客,请务必保留此出处http://281816327.blog.51cto.com/907015/1622063

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。