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. php 类型转换

    PHP数据类型转换 PHP的数据类型转换属于强制转换,允许转换的PHP数据类型有: •(int).(integer):转换成整形 •(float).(double).(real):转换成浮点型 •(s ...

  2. nodejs shell

    REPL (Read-eval-print loop),即输入—求值—输出循环.如果你用过 Python,就会知道在终端下运行无参数的 python 命令或者使用 Python IDLE 打开的 sh ...

  3. 去除ckeditor上传图片预览中的英文字母

    去除ckeditor上传图片预览中的英文字母 CKEDITOR.replace('text', { filebrowserImageUploadUrl : 'upload_img.do', langu ...

  4. Workspace in use or cannot be created, choose a different one.--错误解决的方法

    eclipse 使用一段时间后.有时会由于一些故障自己就莫名奇异的关闭了,再打开时有时没有问题,有时有会提示错误 Workspace Unavailable: Workspace in use or ...

  5. 七、备忘录模式Memento(行为型模式)

    其目的是,在不违反封装原则的前提下.採集和备份一个对象的内部状态以便这个对象能够在以后恢复到之前的某个状态. 在Memento模式中,有例如以下角色: 1.Memento (备忘录) * 存储Orig ...

  6. 分布式消息服务DMS如何实现死信消息的消费

    本文部分内容节选自华为云帮助中心的分布式消息服务(DMS)服务的产品介绍 死信消息是什么 死信消息是指无法被正常消费的消息.分布式消息服务DMS支持对消息进行异常处理.当消息进行多次重复消费仍然失败后 ...

  7. nodejs初步

    nodejs是啥? 看名字,很容易认为它是一种开发语言,实质上,它更像是一种WEB服务器,一种工具.因为nodejs的作用,在于在服务器端解释.运行javascript.node.js本身不是开发语言 ...

  8. Codeforces Round #273 (Div. 2) B . Random Teams 贪心

    B. Random Teams   n participants of the competition were split into m teams in some manner so that e ...

  9. 20170623_oracle备份和恢复_常见问题

    1 为什么需要备份?备份分类? 1)故障.迁移.误操作 2)备份分类: 物理与逻辑角度:物理备份.逻辑备份 备份策略角度:完全备份.增量备份.差异备份 2 使用导入导出进行备份和恢复及其四种模式:其他 ...

  10. 继承自TWinControl的控件不能在设计期间接受子控件,用代码设置子控件却可以(它的自绘是直接改写PaintWindow虚函数,而不是覆盖Paint函数——对TWinControl.WMPaint又有新解了)

    这个控件直接继承自TWinControl,因此不是改写Paint;函数,而是直接改写PaintWindow虚函数,它在VCL框架里被直接调用,直接就把自己画好了(不用走给控件Perform(WM_Pa ...