实现的方法大体类似:

多谢博主的文章,免了不少时间!

摘抄博文地址:https://www.cnblogs.com/sixiweb/p/6893858.html

https://www.cnblogs.com/configure/p/6253590.html

一、监控Redis

  1、创建采集脚本

vim /etc/zabbix/scripts/redis.sh

 #!/bin/bash
REDISPATH="/usr/local/bin/redis-cli"
HOST="127.0.0.1"
PORT=""
REDIS_PA="$REDISPATH -h $HOST -p $PORT info"
if [[ $# == ]];then
case $ in
cluster)
result=`$REDIS_PA|/bin/grep cluster|awk -F":" '{print $NF}'`
echo $result
;;
uptime_in_seconds)
result=`$REDIS_PA|/bin/grep uptime_in_seconds|awk -F":" '{print $NF}'`
echo $result
;;
connected_clients)
result=`$REDIS_PA|/bin/grep connected_clients|awk -F":" '{print $NF}'`
echo $result
;;
client_longest_output_list)
result=`$REDIS_PA|/bin/grep client_longest_output_list|awk -F":" '{print $NF}'`
echo $result
;;
client_biggest_input_buf)
result=`$REDIS_PA|/bin/grep client_biggest_input_buf|awk -F":" '{print $NF}'`
echo $result
;;
blocked_clients)
result=`$REDIS_PA|/bin/grep blocked_clients|awk -F":" '{print $NF}'`
echo $result
;;
#内存
used_memory)
result=`$REDIS_PA|/bin/grep used_memory|awk -F":" '{print $NF}'|awk 'NR==1'`
echo $result
;;
used_memory_human)
result=`$REDIS_PA|/bin/grep used_memory_human|awk -F":" '{print $NF}'|awk -F'K' '{print $1}'`
echo $result
;;
used_memory_rss)
result=`$REDIS_PA|/bin/grep used_memory_rss|awk -F":" '{print $NF}'`
echo $result
;;
used_memory_peak)
result=`$REDIS_PA|/bin/grep used_memory_peak|awk -F":" '{print $NF}'|awk 'NR==1'`
echo $result
;;
used_memory_peak_human)
result=`$REDIS_PA|/bin/grep used_memory_peak_human|awk -F":" '{print $NF}'|awk -F'K' '{print $1}'`
echo $result
;;
used_memory_lua)
result=`$REDIS_PA|/bin/grep used_memory_lua|awk -F":" '{print $NF}'`
echo $result
;;
mem_fragmentation_ratio)
result=`$REDIS_PA|/bin/grep mem_fragmentation_ratio|awk -F":" '{print $NF}'`
echo $result
;;
#rdb
rdb_changes_since_last_save)
result=`$REDIS_PA|/bin/grep rdb_changes_since_last_save|awk -F":" '{print $NF}'`
echo $result
;;
rdb_bgsave_in_progress)
result=`$REDIS_PA|/bin/grep rdb_bgsave_in_progress|awk -F":" '{print $NF}'`
echo $result
;;
rdb_last_save_time)
result=`$REDIS_PA|/bin/grep rdb_last_save_time|awk -F":" '{print $NF}'`
echo $result
;;
rdb_last_bgsave_status)
result=`$REDIS_PA|/bin/grep -w "rdb_last_bgsave_status" | awk -F':' '{print $2}' | /bin/grep -c ok`
echo $result
;;
rdb_current_bgsave_time_sec)
result=`$REDIS_PA|/bin/grep -w "rdb_current_bgsave_time_sec" | awk -F':' '{print $2}'`
echo $result
;;
#rdbinfo
aof_enabled)
result=`$REDIS_PA|/bin/grep -w "aof_enabled" | awk -F':' '{print $2}'`
echo $result
;;
aof_rewrite_scheduled)
result=`$REDIS_PA|/bin/grep -w "aof_rewrite_scheduled" | awk -F':' '{print $2}'`
echo $result
;;
aof_last_rewrite_time_sec)
result=`$REDIS_PA|/bin/grep -w "aof_last_rewrite_time_sec" | awk -F':' '{print $2}'`
echo $result
;;
aof_current_rewrite_time_sec)
result=`$REDIS_PA|/bin/grep -w "aof_current_rewrite_time_sec" | awk -F':' '{print $2}'`
echo $result
;;
aof_last_bgrewrite_status)
result=`$REDIS_PA|/bin/grep -w "aof_last_bgrewrite_status" | awk -F':' '{print $2}' | /bin/grep -c ok`
echo $result
;;
#aofinfo
aof_current_size)
result=`$REDIS_PA|/bin/grep -w "aof_current_size" | awk -F':' '{print $2}'`
echo $result
;;
aof_base_size)
result=`$REDIS_PA|/bin/grep -w "aof_base_size" | awk -F':' '{print $2}'`
echo $result
;;
aof_pending_rewrite)
result=`$REDIS_PA|/bin/grep -w "aof_pending_rewrite" | awk -F':' '{print $2}'`
echo $result
;;
aof_buffer_length)
result=`$REDIS_PA|/bin/grep -w "aof_buffer_length" | awk -F':' '{print $2}'`
echo $result
;;
aof_rewrite_buffer_length)
result=`$REDIS_PA|/bin/grep -w "aof_rewrite_buffer_length" | awk -F':' '{print $2}'`
echo $result
;;
aof_pending_bio_fsync)
result=`$REDIS_PA|/bin/grep -w "aof_pending_bio_fsync" | awk -F':' '{print $2}'`
echo $result
;;
aof_delayed_fsync)
result=`$REDIS_PA|/bin/grep -w "aof_delayed_fsync" | awk -F':' '{print $2}'`
echo $result
;;
#stats
total_connections_received)
result=`$REDIS_PA|/bin/grep -w "total_connections_received" | awk -F':' '{print $2}'`
echo $result
;;
total_commands_processed)
result=`$REDIS_PA|/bin/grep -w "total_commands_processed" | awk -F':' '{print $2}'`
echo $result
;;
instantaneous_ops_per_sec)
result=`$REDIS_PA|/bin/grep -w "instantaneous_ops_per_sec" | awk -F':' '{print $2}'`
echo $result
;;
rejected_connections)
result=`$REDIS_PA|/bin/grep -w "rejected_connections" | awk -F':' '{print $2}'`
echo $result
;;
expired_keys)
result=`$REDIS_PA|/bin/grep -w "expired_keys" | awk -F':' '{print $2}'`
echo $result
;;
evicted_keys)
result=`$REDIS_PA|/bin/grep -w "evicted_keys" | awk -F':' '{print $2}'`
echo $result
;;
keyspace_hits)
result=`$REDIS_PA|/bin/grep -w "keyspace_hits" | awk -F':' '{print $2}'`
echo $result
;;
keyspace_misses)
result=`$REDIS_PA|/bin/grep -w "keyspace_misses" | awk -F':' '{print $2}'`
echo $result
;;
pubsub_channels)
result=`$REDIS_PA|/bin/grep -w "pubsub_channels" | awk -F':' '{print $2}'`
echo $result
;;
pubsub_channels)
result=`$REDIS_PA|/bin/grep -w "pubsub_channels" | awk -F':' '{print $2}'`
echo $result
;;
pubsub_patterns)
result=`$REDIS_PA|/bin/grep -w "pubsub_patterns" | awk -F':' '{print $2}'`
echo $result
;;
latest_fork_usec)
result=`$REDIS_PA|/bin/grep -w "latest_fork_usec" | awk -F':' '{print $2}'`
echo $result
;;
connected_slaves)
result=`$REDIS_PA|/bin/grep -w "connected_slaves" | awk -F':' '{print $2}'`
echo $result
;;
master_link_status)
result=`$REDIS_PA|/bin/grep -w "master_link_status"|awk -F':' '{print $2}'|/bin/grep -c up`
echo $result
;;
master_last_io_seconds_ago)
result=`$REDIS_PA|/bin/grep -w "master_last_io_seconds_ago"|awk -F':' '{print $2}'`
echo $result
;;
master_sync_in_progress)
result=`$REDIS_PA|/bin/grep -w "master_sync_in_progress"|awk -F':' '{print $2}'`
echo $result
;;
slave_priority)
result=`$REDIS_PA|/bin/grep -w "slave_priority"|awk -F':' '{print $2}'`
echo $result
;;
#cpu
used_cpu_sys)
result=`$REDIS_PA|/bin/grep -w "used_cpu_sys"|awk -F':' '{print $2}'`
echo $result
;;
used_cpu_user)
result=`$REDIS_PA|/bin/grep -w "used_cpu_user"|awk -F':' '{print $2}'`
echo $result
;;
used_cpu_sys_children)
result=`$REDIS_PA|/bin/grep -w "used_cpu_sys_children"|awk -F':' '{print $2}'`
echo $result
;;
used_cpu_user_children)
result=`$REDIS_PA|/bin/grep -w "used_cpu_user_children"|awk -F':' '{print $2}'`
echo $result
;;
*)
echo "Usage:$0{uptime_in_seconds|connected_clients|client_longest_output_list|client_biggest_input_buf|blocked_clients|used_memory|used_memory_human|used_memory_rss|used_memory_peak|used_memory_peak_human|used_memory_lua|mem_fragmentation_ratio|rdb_changes_since_last_save|rdb_bgsave_in_progress|rdb_last_save_time|rdb_last_bgsave_status|rdb_current_bgsave_time_sec|aof_enabled|aof_rewrite_scheduled|aof_last_rewrite_time_sec|aof_current_rewrite_time_sec|aof_last_bgrewrite_status|aof_current_size|aof_base_size|aof_pending_rewrite|aof_buffer_length|aof_rewrite_buffer_length|aof_pending_bio_fsync|aof_delayed_fsync|rejected_connections|instantaneous_ops_per_sec|total_connections_received|total_commands_processed|expired_keys|evicted_keys|keyspace_hits|keyspace_misses|pubsub_channels|pubsub_patterns|latest_fork_usec|connected_slaves|master_link_status|master_sync_in_progress|master_last_io_seconds_ago|connected_slaves|slave_priority|used_cpu_user|used_cpu_sys|used_cpu_sys_children|used_cpu_user_children}"
;;
esac
#db0:key
elif [[ $# == ]];then
case $ in
keys)
result=`$REDIS_PA| /bin/grep -w "db0"| /bin/grep -w "$1" | /bin/grep -w "keys" | awk -F'=|,' '{print $2}'`
echo $result
;;
expires)
result=`$REDIS_PA| /bin/grep -w "db0"| /bin/grep -w "$1" | /bin/grep -w "expires" | awk -F'=|,' '{print $4}'`
echo $result
;;
avg_ttl)
result=`$REDIS_PA|/bin/grep -w "db0"| /bin/grep -w "$1" | /bin/grep -w "avg_ttl" | awk -F'=|,' '{print $6}'`
echo $result
;;
*)
echo "Usage:$0{db0 keys|db0 expires|db0 avg_ttl}"
;;
esac
fi

redis.sh

  2、设置权限

chmod  redis.sh
chown root.zabbix redis.sh

  3、编辑agent的主配置文件

#redis
UserParameter=redis.status,/usr/bin/redis-cli -h 127.0.0.1 -p ping |grep -c PONG
UserParameter=redis_info[*],/etc/zabbix/scripts/redis.sh $ $

  4、重启服务

systemctl restart zabbix-agent.service
systemctl enable zabbix-agent.service

  5、zabbix-service 导入模板

模板下载地址:https://pan.baidu.com/s/1AoI-_OkWqKaOc56GYe9Ong 密码:msx5

  6、导入后套接到对应的主机即可!

  7、效果展示

zabbix日常监控(监控缓存)的更多相关文章

  1. zabbix日常监控项java(四)

    yum install net-tools netstat命令 yum -y install bash-completion 命令自动补全包 https://github.com/qiueer/zab ...

  2. zabbix日常监控项java(四又分之一)

    因zabbix自带监控JMX的模板通用性差的问题,需要我们自己新建一个属于自己的模板,于是本文就出现了.... 大部分都是参考网上其他博主的文档,在此作为梳理.总结:以方便自己日后使用查询.

  3. zabbix日常监控项nginx(五)

    1.开启nginx监控 2.编写脚本来进行数据采集 3.设置用户自定义参数 4.重启zabbix-agent 5.添加item.创建图形.创建触发器 6.创建模板 注:第一次使用可以按需求制定好模板, ...

  4. zabbix 内网监控云服务器

    今天 搞监控碰到了一个问题就是.内网机器搭建的zabbix服务器去监控云服务器agent的时候,agent 需要写服务端的IP地址. 我的思路是内网服务器映射自己公网IP地址的zabbix的端口100 ...

  5. zabbix模板化监控

    zabbix模板化监控 1. 实验简述 在zabbix监控中,有很多组的概念,具体有以下几种: 1. 主机和主机组,相同类型/应用的主机,可以归属于同一个主机组 2. item和application ...

  6. Zabbix 添加端口监控链接

    zabbix 添加端口监控 连接数: zabbix  配置  添加 监控项: 其他检测 方式也是 示例: zabbix 客户端配置文件添加: 编辑 zabbix_agentd.conf  添加  端口 ...

  7. zabbix实现自定义监控

    实现自定义监控项实例 .创建主机组 .创建主机 .创建监控项 .到需要监控的主机的agent中添加自定义的监控项目 cd /etc/zabbix/zabbix_agentd.d vi userpara ...

  8. zabbix使用jmx监控tomcat

    zabbix监控Tomcat/JVM实例性能(115) – 运维生存时间http://www.ttlsa.com/zabbix/zabbix-use-jmx-monitor-tomcat/ zabbi ...

  9. 24 Zabbix系统配置日志监控告警--关键字触发

    点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 24 Zabbix系统配置日志监控告警--关键字触发 trapper是被监控主机主动发送数据给za ...

  10. 给zabbix添加percona监控模板

    简单说明一下给zabbix添加的percona的监控模板. 在percona官方网站有说明怎么安装,这里记录下步骤.首先搭建好的zabbix环境. 监控插件连接 : 链接:https://pan.ba ...

随机推荐

  1. lucene源码分析(1)基本要素

    1.源码包 core: Lucene core library analyzers-common: Analyzers for indexing content in different langua ...

  2. JAVA-4NIO之Channel之间的数据传输

    转载:自并发编程网ifeve.com 在Java NIO中,如果两个通道中有一个是FileChannel,那你可以直接将数据从一个channel(译者注:channel中文常译作通道)传输到另外一个c ...

  3. linux使用mail命令发送邮件

    在工作中使用linux,偶尔也会需要使用mail命令来进行发邮件.    从上面的命令看,系统已经安装了mail,对些我们还需要设置一下mail,让它使用外面的邮箱进行发邮件.设置文件是 /etc/m ...

  4. BG.Sqoop

    1. 下载 Sqoop,并复制到虚拟机 http://sqoop.apache.org/ 2. 安装Sqoop tar zxf sqoop-1.4.6.bin__hadoop-2.0.4-alpha. ...

  5. 长期更新系列:C#知识点

    PS:写这个主要是基础差,写这么一个主要是为了自己查漏补缺,不会的搞会了.会了搞的更会.顺便整理知识. 目录 1.C#知识点:值类型和引用类型 2.C#知识点:I/0 3.C#知识点:is和as 4. ...

  6. [日常] Go语言圣经-命令行参数

    1.编译 go build hello.go 2.go get gopl.io/ch1/helloworld 命令,就会从网上获取代码,并放到对应目录中 下载的代码会放在$GOPATH/src/gop ...

  7. Storm框架:如何实现crontab定时任务

    Storm除了能对消息流进行处理,还能实现crontab定时任务. 只要在bolt中配置TOPOLOGY_TICK_TUPLE_FREQ_SECS项即可实现. @Override public Map ...

  8. HDFS要点剖析

    谈到大数据,不得不提的一个名词是"HDFS".它是一种分布式文件存储系统,其系统架构图如下图所示: 从图中可以了解到的几个关键概念 元数据(MetaData) 机架(Rock) 块 ...

  9. Oracle-检查原因并重新编译无效的存储过程

    1.查看存储过程编译无效的原因 show errors procedure hr.getperson; 2.指定一个存储过程进行编译 alter procedure  hr.getperson com ...

  10. C# 新建文档CreateNewDocument

    // Copyright 2010 ESRI// // All rights reserved under the copyright laws of the United States// and ...