Zabbix 监控redis
Zabbix 监控redis
1.监控脚本,github上的
[root@localhost ~]# cat /etc/zabbix/script/redis-status.sh
#!/bin/bash #Redis status METRIC="$2"
SERV="$1"
DB="$3" PORT="" if [[ -z "$1" ]]; then
echo "Please set server"
exit
fi CACHETTL=""
CACHE="/tmp/redis-status-`echo $SERV | md5sum | cut -d" " -f1`.cache" if [ -s "$CACHE" ]; then
TIMECACHE=`stat -c"%Z" "$CACHE"`
else
TIMECACHE=
fi TIMENOW=`date '+%s'` if [ "$(($TIMENOW - $TIMECACHE))" -gt "$CACHETTL" ]; then
(echo -en "INFO\r\n"; sleep ;) | nc -w1 $SERV $PORT > $CACHE || exit
fi FIRST_ELEMENT=
function json_head {
printf "{";
printf "\"data\":[";
} function json_end {
printf "]";
printf "}";
} function check_first_element {
if [[ $FIRST_ELEMENT -ne ]]; then
printf ","
fi
FIRST_ELEMENT=
} function databse_detect {
json_head
for dbname in $LIST_DATABSE
do
local dbname_t=$(echo $dbname| sed 's!\n!!g')
check_first_element
printf "{"
printf "\"{#DBNAME}\":\"$dbname_t\""
printf "}"
done
json_end
} case $METRIC in
'redis_version')
cat $CACHE | grep "redis_version:" | cut -d':' -f2
;;
'redis_git_sha1')
cat $CACHE | grep "redis_git_sha1:" | cut -d':' -f2
;;
'redis_git_dirty')
cat $CACHE | grep "redis_git_dirty:" | cut -d':' -f2
;;
'redis_mode')
cat $CACHE | grep "redis_mode:" | cut -d':' -f2
;;
'arch_bits')
cat $CACHE | grep "arch_bits:" | cut -d':' -f2
;;
'multiplexing_api')
cat $CACHE | grep "multiplexing_api:" | cut -d':' -f2
;;
'gcc_version')
cat $CACHE | grep "gcc_version:" | cut -d':' -f2
;;
'uptime_in_seconds')
cat $CACHE | grep "uptime_in_seconds:" | cut -d':' -f2
;;
'lru_clock')
cat $CACHE | grep "lru_clock:" | cut -d':' -f2
;;
'connected_clients')
cat $CACHE | grep "connected_clients:" | cut -d':' -f2
;;
'client_longest_output_list')
cat $CACHE | grep "client_longest_output_list:" | cut -d':' -f2
;;
'client_biggest_input_buf')
cat $CACHE | grep "client_biggest_input_buf:" | cut -d':' -f2
;;
'used_memory')
cat $CACHE | grep "used_memory:" | cut -d':' -f2
;;
'used_memory_peak')
cat $CACHE | grep "used_memory_peak:" | cut -d':' -f2
;;
'mem_fragmentation_ratio')
cat $CACHE | grep "mem_fragmentation_ratio:" | cut -d':' -f2
;;
'loading')
cat $CACHE | grep "loading:" | cut -d':' -f2
;;
'rdb_changes_since_last_save')
cat $CACHE | grep "rdb_changes_since_last_save:" | cut -d':' -f2
;;
'rdb_bgsave_in_progress')
cat $CACHE | grep "rdb_bgsave_in_progress:" | cut -d':' -f2
;;
'aof_rewrite_in_progress')
cat $CACHE | grep "aof_rewrite_in_progress:" | cut -d':' -f2
;;
'aof_enabled')
cat $CACHE | grep "aof_enabled:" | cut -d':' -f2
;;
'aof_rewrite_scheduled')
cat $CACHE | grep "aof_rewrite_scheduled:" | cut -d':' -f2
;;
'total_connections_received')
cat $CACHE | grep "total_connections_received:" | cut -d':' -f2
;;
'total_commands_processed')
cat $CACHE | grep "total_commands_processed:" | cut -d':' -f2
;;
'instantaneous_ops_per_sec')
cat $CACHE | grep "instantaneous_ops_per_sec:" | cut -d':' -f2
;;
'rejected_connections')
cat $CACHE | grep "rejected_connections:" | cut -d':' -f2
;;
'expired_keys')
cat $CACHE | grep "expired_keys:" | cut -d':' -f2
;;
'evicted_keys')
cat $CACHE | grep "evicted_keys:" | cut -d':' -f2
;;
'keyspace_hits')
cat $CACHE | grep "keyspace_hits:" | cut -d':' -f2
;;
'keyspace_misses')
cat $CACHE | grep "keyspace_misses:" | cut -d':' -f2
;;
'pubsub_channels')
cat $CACHE | grep "pubsub_channels:" | cut -d':' -f2
;;
'pubsub_patterns')
cat $CACHE | grep "pubsub_patterns:" | cut -d':' -f2
;;
'latest_fork_usec')
cat $CACHE | grep "latest_fork_usec:" | cut -d':' -f2
;;
'role')
cat $CACHE | grep "role:" | cut -d':' -f2
;;
'connected_slaves')
cat $CACHE | grep "connected_slaves:" | cut -d':' -f2
;;
'used_cpu_sys')
cat $CACHE | grep "used_cpu_sys:" | cut -d':' -f2
;;
'used_cpu_user')
cat $CACHE | grep "used_cpu_user:" | cut -d':' -f2
;;
'used_cpu_sys_children')
cat $CACHE | grep "used_cpu_sys_children:" | cut -d':' -f2
;;
'used_cpu_user_children')
cat $CACHE | grep "used_cpu_user_children:" | cut -d':' -f2
;;
'key_space_db_keys')
cat $CACHE | grep $DB:|cut -d':' -f2|awk -F, '{print $1}'|cut -d'=' -f2
;;
'key_space_db_expires')
cat $CACHE | grep $DB:|cut -d':' -f2|awk -F, '{print $2}'|cut -d'=' -f2
;;
'list_key_space_db')
LIST_DATABSE=`cat $CACHE | grep '^db.:'|cut -d: -f1`
databse_detect
;;
*)
echo "Not selected metric"
exit
;;
esac
2.看看效果



Zabbix 监控redis的更多相关文章
- Zabbix应用六:Zabbix监控Redis
利用Zabbix监控Redis Zabbix监控redis就比较简单了,因为zabbix官方提供了监控redis的模版和脚本,而且脚本有nodejs和python两种,下载地址:https://git ...
- Zabbix监控redis status
概述 zabbix采用Trapper方式监控redis status 原理 redis-cli info命令得到redis服务器的统计信息,脚本对信息分两部分处理: (1)# Keyspace部分为Z ...
- 01:zabbix监控redis
一.zabbix 自动发现并监控redis多实例 1.1 编写脚本 1.1.1 redis_low_discovery.sh 用于发现redis多实例 [root@redis02 homed]# ca ...
- 最新 centos7下zabbix 监控redis状态
准备 先准备两台服务器,已经部署好了zabbix-sever和zabbix-agent zabbix-server 192.168.1.70 centos7.2 zabbix-agent 192.16 ...
- zabbix监控redis多实例(low level discovery)
对于多实例部署的tomcat.redis等应用,可以利用zabbix的low level discovery功能来实现监控,减少重复操作. 注:Zabbix版本: Zabbix 3.0.2 一.服务 ...
- zabbix监控redis
导入监控模板 点击[configuration]-->[templates]-->[import],导入xml监控模板. 配置客户端key 在被监控的主机上,新建/etc/zabbix/z ...
- zabbix监控redis性能
创建采集脚本 mkdir -p /etc/zabbix/scripts chown -R zabbix.root /etc/zabbix/scripts vim redis_status.sh #! ...
- (十二)zabbix监控redis
1)agent端配置 安装redis yum install epel-release -y yum install redis -y 配置认证密码 #vim /etc/redis.conf requ ...
- zabbix 监控redis python3脚本
一:安装redis-python模块 wge thttps://pypi.python.org/packages/source/r/redis/redis-2.9.1.tar.gz tar xf r ...
随机推荐
- cogs——1786. 韩信点兵
1786. 韩信点兵 ★★★ 输入文件:HanXin.in 输出文件:HanXin.out 简单对比 时间限制:1 s 内存限制:256 MB [题目描述] 韩信是中国军事思想“谋战” ...
- Mysql修改自增主键的起始值及查询自增主键的下一个值
MySQL [xxx_mall]> alter table shop_base_info AUTO_INCREMENT=11000;Query OK, 0 rows affected (0.0 ...
- 常见的各品牌路由器默认IP地址汇总清单
常见的各品牌路由器默认IP地址汇总清单 下面是各常见品牌路由器的默认IP清单: 如果您使用的设备品牌不在上述列表中,也可以试着访问下RouterIPAddress.com或SetupRouter.co ...
- 第一章--linux基础
(一):linux系统根文件夹结构 Unix-like系统中的"文件系统"的概念包含两个意思,第一个是"根文件系统",第二个是"存储类文件系统&quo ...
- UVA 11748 - Rigging Elections(dfs)
UVA 11748 - Rigging Elections option=com_onlinejudge&Itemid=8&page=show_problem&category ...
- border-image 和 border-color 不能同时使用问题
遇到如下问题: UI 给的设计,某部分,上边框为 图片,下边框为灰色横线. 看到这个的第一反应是,上边框用 border-image ,为了只让上边框显示图片,所以只给上边框宽度为所需宽度,我的图是 ...
- apache ua Custom Log Formats
RewriteEngine OnRewriteBase / RewriteCond %{HTTP_USER_AGENT} (android|bb\d+|meego).+mobile|avantgo|b ...
- 【NYOJ42】一笔画问题
一笔画问题 时间限制:3000 ms | 内存限制:65535 KB 难度:4 Position:http://acm.nyist.net/JudgeOnline/problem.php?pid= ...
- bzoj 3721 Final Bazarek
题目大意: n个数 选k个使和为奇数且最大 思路: 可以先将这n个数排序 然后先去最大的k个数 若和为奇数则直接输出 为偶数可以用没选的最大的奇数替换选了的最小的偶数或用没选的最大的偶数替换选了的最小 ...
- 洛谷P2744 [USACO5.3]量取牛奶Milk Measuring
题目描述 农夫约翰要量取 Q(1 <= Q <= 20,000)夸脱(夸脱,quarts,容积单位--译者注) 他的最好的牛奶,并把它装入一个大瓶子中卖出.消费者要多少,他就给多少,从不有 ...