zabbix监控memcached服务
zabbix监控memcached服务
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.安装并配置memcached服务
1>.使用yum方式安装memcached
[root@node201.yinzhengjie.org.cn ~]# yum -y install memcached
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.aliyun.com
* updates: mirrors.tuna.tsinghua.edu.cn
base | 3.6 kB ::
docker-ce-stable | 3.5 kB ::
extras | 2.9 kB ::
kubernetes | 1.4 kB ::
updates | 2.9 kB ::
zabbix | 2.9 kB ::
zabbix-non-supported | B ::
Resolving Dependencies
--> Running transaction check
---> Package memcached.x86_64 :1.4.-.el7_3. will be installed
--> Finished Dependency Resolution Dependencies Resolved ==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
memcached x86_64 1.4.-.el7_3. base k Transaction Summary
==============================================================================================================================================================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
memcached-1.4.-.el7_3..x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : memcached-1.4.-.el7_3..x86_64 /
Verifying : memcached-1.4.-.el7_3..x86_64 / Installed:
memcached.x86_64 :1.4.-.el7_3. Complete!
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# yum -y install memcached
2>.查看memcached的配置文件
[root@node201.yinzhengjie.org.cn ~]# cat /etc/sysconfig/memcached
PORT=""
USER="memcached"
MAXCONN=""
CACHESIZE=""
OPTIONS=""
[root@node201.yinzhengjie.org.cn ~]#
3>.启动memcached服务
[root@node201.yinzhengjie.org.cn ~]# systemctl start memcached.service
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# systemctl enable memcached.service
Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# ss -ntl | grep
LISTEN *: *:*
LISTEN ::: :::*
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]#
二.zabbix agent端配置监控memcached的脚本
1>.在命令行中查看数据memcached的监控指标
[root@node201.yinzhengjie.org.cn ~]# yum -y install nc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.aliyun.com
* updates: mirrors.tuna.tsinghua.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package nmap-ncat.x86_64 :6.40-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ==============================================================================================================================================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================================================================================================================================
Installing:
nmap-ncat x86_64 :6.40-.el7 base k Transaction Summary
==============================================================================================================================================================================================================================================================================
Install Package Total download size: k
Installed size: k
Downloading packages:
nmap-ncat-6.40-.el7.x86_64.rpm | kB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : :nmap-ncat-6.40-.el7.x86_64 /
Verifying : :nmap-ncat-6.40-.el7.x86_64 / Installed:
nmap-ncat.x86_64 :6.40-.el7 Complete!
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# yum -y install nc #安装nc工具
[root@node201.yinzhengjie.org.cn ~]# echo -e "stats\nquit" | nc 127.0.0.1 ""
STAT pid
STAT uptime
STAT time
STAT version 1.4.
STAT libevent 2.0.-stable
STAT pointer_size
STAT rusage_user 0.014680
STAT rusage_system 0.014680
STAT curr_connections
STAT total_connections
STAT connection_structures
STAT reserved_fds
STAT cmd_get
STAT cmd_set
STAT cmd_flush
STAT cmd_touch
STAT get_hits
STAT get_misses
STAT delete_misses
STAT delete_hits
STAT incr_misses
STAT incr_hits
STAT decr_misses
STAT decr_hits
STAT cas_misses
STAT cas_hits
STAT cas_badval
STAT touch_hits
STAT touch_misses
STAT auth_cmds
STAT auth_errors
STAT bytes_read
STAT bytes_written
STAT limit_maxbytes
STAT accepting_conns
STAT listen_disabled_num
STAT threads
STAT conn_yields
STAT hash_power_level
STAT hash_bytes
STAT hash_is_expanding
STAT bytes
STAT curr_items
STAT total_items
STAT expired_unfetched
STAT evicted_unfetched
STAT evictions
STAT reclaimed
END
[root@node201.yinzhengjie.org.cn ~]#
2>.编写脚本获取memcached的监控项数据
[root@node201.yinzhengjie.org.cn ~]# cat /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
#!/bin/bash
#
#********************************************************************
#Author: yinzhengjie
#QQ:
#Date: --
#FileName: shell/menu.sh
#URL: http://www.cnblogs.com/yinzhengjie
#Description: The test script
#Copyright notice: original works, no reprint! Otherwise, legal liability will be investigated.
#******************************************************************** function memcached_status(){
M_PORT=$
M_COMMAND=$
echo -e "stats\nquit" | nc 127.0.0.1 "$M_PORT" | grep "STAT $M_COMMAND " | awk '{print $3}'
} function main(){
case $ in
memcached_status)
memcached_status $ $
;;
esac
} main $ $ $
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# bash /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh memcached_status curr_connections [root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# bash /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh memcached_status reserved_fds [root@node201.yinzhengjie.org.cn ~]#

3>.给自定义的脚本添加可执行权限
[root@node201.yinzhengjie.org.cn ~]# ll /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
-rw-r--r-- root root Feb : /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# chmod +x /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# ll /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
-rwxr-xr-x root root Feb : /etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]#
4>.修改zaibbix agent的配置文件
[root@node201.yinzhengjie.org.cn ~]# grep ^Include /etc/zabbix/zabbix_agentd.conf
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@node201.yinzhengjie.org.cn ~]#
[root@node201.yinzhengjie.org.cn ~]# cat /etc/zabbix/zabbix_agentd.d/yinzhengjie_monitoring.conf
UserParameter=tcp_status_monitoring[*],/etc/zabbix/zabbix_agentd.d/tcp_status_monitoring.sh $1 $2
UserParameter=memcached_monitoring[*],/etc/zabbix/zabbix_agentd.d/memcached_monitoring.sh $1 $2 $3
[root@node201.yinzhengjie.org.cn ~]#
5>.重启zabbix agent服务使得配置生效
[root@node201.yinzhengjie.org.cn ~]# systemctl restart zabbix-agent.service

三.zabbix WebUI配置
1>.在zabbix server测试是否可以获取memcached的监控数据
[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/bin/zabbix_get -s node201.yinzhengjie.org.cn -p -k "memcached_monitoring[memcached_status 11211 curr_connections]" [root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]#
[root@zabbix203.yinzhengjie.org.cn ~]# /yinzhengjie/softwares/zabbix/bin/zabbix_get -s node201.yinzhengjie.org.cn -p -k "memcached_monitoring[memcached_status 11211 reserved_fds]" [root@zabbix203.yinzhengjie.org.cn ~]#
2>.自定义memcached的模板

3>.自定义memecached模板监控项图形

4>.自定义触发器

5>.将自定义的memcached模板和对应的zabbix agent主机进行关联

6>.查看图形

zabbix监控memcached服务的更多相关文章
- 监控memcached服务
#!/bin/bash #监控memcached服务 printf "del key\r\n" | nc 127.0.0.1 11211 &>/dev/null #使 ...
- Zabbix监控虚拟机服务-告警与自动恢复-模板化
上一篇文章测试了服务的告警与自动恢复:Zabbix监控虚拟机服务-告警与自动恢复 但是我是直接为某一个主机增加的监控项和触发器, 如果要让某一个自定义的监控项和触发器被很多机器共用,则需要创建模板 1 ...
- 使用Zabbix监控ZooKeeper服务的健康状态
一 应用场景描述 在目前公司的业务中,没有太多使用ZooKeeper作为协同服务的场景.但是我们将使用Codis作为Redis的集群部署方案,Codis依赖ZooKeeper来存储配置信息.所以做好Z ...
- 【zabbix告警监控】配置zabbix监控nginx服务
zabbix监控nginx,nginx需要添加--with-http_stub_status模块 使用zabbix监控nginx,首先nginx需要配置开启ngx_status.但是我这边nginx安 ...
- Zabbix 监控常见服务
监控Apache性能 1.客户端编译安装Apache服务,并在编译选项中开启监控页面功能. [root@localhost ~]# yum install -y gcc openssl openssl ...
- 使用Zabbix监控Nginx服务实战案例
使用Zabbix监控Nginx服务实战案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.编译安装nginx步骤详解并开启状态页 博主推荐阅读: https://www.cn ...
- Zabbix监控虚拟机服务-告警与自动恢复
今天稍微空闲,使用下zabbix的5.0版本,目前生产环境是4.x版本 今天就只实现一个目的:监控任意一个服务(示例中监控的是docker.service),如果服务挂了,自动给恢复,先看一个动图 搭 ...
- 使用Zabbix监控rabbitmq服务
添加rabbitmq脚本 [root@controller rabbitmq]# cd /etc/zabbix/script/rabbitmq [root@controller rabbitmq]# ...
- 【zabbix监控】zabbix监控tomcat服务
服务器配置(zabbix_server) 1. 安装jdk 版本需要1.7以上,我这边安装的是1.8的,可以参考我jdk安装的文章 # 上传到zabbix_server服务端.安装(jdk-8u171 ...
随机推荐
- 基础总结篇之八:创建及调用自己的ContentProvider
转自:http://blog.csdn.net/wellsoho/article/details/49494141 若不能坚持到底,即使是朽木也不能折断:只要坚持不停地用刀刻,就算是金属玉石也可以雕出 ...
- 【降维】主成分分析PCA推导
本博客根据 百面机器学习,算法工程师带你去面试 一书总结归纳,公式都是出自该书. 本博客仅为个人总结学习,非商业用途,侵删. 网址 http://www.ptpress.com.cn 目录: PCA最 ...
- 每个 JavaScript 开发者都该懂的 Unicode
英文原文标题:what-every-javascript-developer-should-know-about-unicode (译者注:本文含有Unicode辅助平面的特殊字符,部分浏览器可能无法 ...
- Java基础知识笔记第九章:组件及事件处理
java Swing 图形用户界面(GUI : Graphics User Interface) 窗口 JFrame常用方法 JFrame()创建一个无标题的窗口. JFrame(String s)创 ...
- spring mvc注解之@RequestBody和@RequestParm
@RequestBody http://localhost:8080/user/login { "username":"jack", "passwar ...
- leetcode 390. 消除游戏
{20-01-29 19:22} class Solution { public int lastRemaining(int n) { return help(n); } public static ...
- 三大JavaScript框架对比——AngularJS、BackboneJS和EmberJS
<三大JavaScript框架对比——AngularJS.BackboneJS和EmberJS> 本文转载自 作者:chszs,博客主页:http://blog.csdn.net/chs ...
- redis5.0版本集群搭建
模式简介 Redis 集群是一个可以在多个 Redis 节点之间进行数据共享的设施(installation). Redis 集群不支持那些需要同时处理多个键的 Redis 命令,比如:mget, 因 ...
- UniGui安装(01)
UniGui安装.Delphi10和uniGUI1.90.0.1509 1]下载 2]安装 3]目录说明 1]下载 在我百度网盘里 uniGUI1-90-0-1509.zip https://pan ...
- 笔记||Pyhton3进阶之多线程原理
# 多线程 # 一个进程相当于一个或多个线程 # 当没有多线程编程时,一个进程也是一个主线程 # 但有多线程编程时,一个进程包含多个线程,包括主线程 # 使用线程 可以实现程序的并发 # python ...