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 ...
随机推荐
- [bzoj1293][SCOI2009]生日礼物(单调队列)
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1293 分析: 问题的关键就是选择每种颜色的哪一个好.可以先把每种颜色的第一个一起,更新 ...
- 23、Java并发性和多线程-重入锁死
以下内容转自http://ifeve.com/reentrance-lockout/: 重入锁死与死锁和嵌套管程锁死非常相似.锁和读写锁两篇文章中都有涉及到重入锁死的问题. 当一个线程重新获取锁,读写 ...
- 数学之路-python计算实战(17)-机器视觉-滤波去噪(中值滤波)
Blurs an image using the median filter. C++: void medianBlur(InputArray src, OutputArray dst, int ks ...
- shell 切割文件
[root@hadoop2 xiaole_chk_url]# cat looh.index.splitfile.sh loop_c=0loop_step=10001loop_tag=0str_head ...
- How do browser cookie domains work?
https://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work 答案一 Although there is ...
- VS2010中使用AnkhSvn
VS2010中使用AnkhSvn 今天想到要在自己的开发环境IDE(Visual Studio 2010)中安装一个代码管理器的插件,本人在使用VS2005的时候一直都是使用AnkhSvn-2.1 ...
- Codeforces--597A--Divisibility(数学)
DivisibilityCrawling in process... Crawling failed Time Limit:1000MS Memory Limit:262144KB ...
- 【POJ 3784】 Running Median
[题目链接] http://poj.org/problem?id=3784 [算法] 对顶堆算法 要求动态维护中位数,我们可以将1-M/2(向下取整)小的数放在大根堆中,M/2+1-M小的数放在小根堆 ...
- 第一周 Leetcode 57. Insert Interval (HARD)
Insert interval 题意简述:给定若干个数轴上的闭区间,保证互不重合且有序,要求插入一个新的区间,并返回新的区间集合,保证有序且互不重合. 只想到了一个线性的解法,所有区间端点,只要被其 ...
- QT Creater环境搭建
需要的软件包: 1.qt-win-opensource-4.8.5-mingw.exe //Qt库 2.MinGW-gcc440_1.zip //QT编译器 3.qt-creator-opensour ...