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的更多相关文章

  1. Zabbix应用六:Zabbix监控Redis

    利用Zabbix监控Redis Zabbix监控redis就比较简单了,因为zabbix官方提供了监控redis的模版和脚本,而且脚本有nodejs和python两种,下载地址:https://git ...

  2. Zabbix监控redis status

    概述 zabbix采用Trapper方式监控redis status 原理 redis-cli info命令得到redis服务器的统计信息,脚本对信息分两部分处理: (1)# Keyspace部分为Z ...

  3. 01:zabbix监控redis

    一.zabbix 自动发现并监控redis多实例 1.1 编写脚本 1.1.1 redis_low_discovery.sh 用于发现redis多实例 [root@redis02 homed]# ca ...

  4. 最新 centos7下zabbix 监控redis状态

    准备 先准备两台服务器,已经部署好了zabbix-sever和zabbix-agent zabbix-server 192.168.1.70 centos7.2 zabbix-agent 192.16 ...

  5. zabbix监控redis多实例(low level discovery)

    对于多实例部署的tomcat.redis等应用,可以利用zabbix的low level discovery功能来实现监控,减少重复操作.  注:Zabbix版本: Zabbix 3.0.2 一.服务 ...

  6. zabbix监控redis

    导入监控模板 点击[configuration]-->[templates]-->[import],导入xml监控模板. 配置客户端key 在被监控的主机上,新建/etc/zabbix/z ...

  7. zabbix监控redis性能

    创建采集脚本 mkdir -p /etc/zabbix/scripts chown -R zabbix.root /etc/zabbix/scripts vim redis_status.sh  #! ...

  8. (十二)zabbix监控redis

    1)agent端配置 安装redis yum install epel-release -y yum install redis -y 配置认证密码 #vim /etc/redis.conf requ ...

  9. zabbix 监控redis python3脚本

    一:安装redis-python模块 wge  thttps://pypi.python.org/packages/source/r/redis/redis-2.9.1.tar.gz tar xf r ...

随机推荐

  1. SpringFox Swagger2注解基本用法

    一切参数说明,参考官方API文档:http://docs.swagger.io/swagger-core/current/apidocs/index.html?io/swagger/annotatio ...

  2. 19、Java并发性和多线程-嵌套管程锁死

    以下内容转自http://ifeve.com/nested-monitor-lockout/: 嵌套管程锁死类似于死锁, 下面是一个嵌套管程锁死的场景: 线程1获得A对象的锁. 线程1获得对象B的锁( ...

  3. 15、Java并发性和多线程-线程通讯

    以下内容转自http://ifeve.com/thread-signaling/: 线程通信的目标是使线程间能够互相发送信号.另一方面,线程通信使线程能够等待其他线程的信号. 例如,线程B可以等待线程 ...

  4. 【转】keyCode对照表及JS监听组合按键

    原文: http://blog.csdn.net/qq_21386275/article/details/67640576 有一些需求,html 页面上的input 框只允许输入数字,  只允许输入小 ...

  5. LeetCode 7. Reverse Integer (倒转数字)

    Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Examp ...

  6. 如何在 webpack 项目中使用绝对路径

    react 小白编程 本项目是使用 create-react-app 脚手架构建的react项目 找到 config 配置文件下的 webpack.config.dev.js 和 webpack.co ...

  7. python 执行shell

    一.import os ex: 1.os.system('ls') ----并不能得到返回值 2.output = os.popen('ls') res = output.read() ----能得到 ...

  8. 第四章、TIny4412 U-BOOT移植四 配置时钟频率源码分析【转】

    本文转载自:http://blog.csdn.net/eshing/article/details/37542459 版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   上 ...

  9. 收集主机OS相关数据

    #!/usr/bin/ksh touch hostinfo$(date +%Y%m%d).csv filename=hostinfo$(date +%Y%m%d).csv >${filename ...

  10. Web开发必须知道的知识点

    Web前端必须知道 一.常用那几种浏览器测试.有哪些内核(Layout Engine) 1.浏览器:IE,Chrome,FireFox,Safari,Opera. 2.内核:Trident,Gecko ...