xinjiang 发表于 2019-1-19 09:44:58

添加zabbix计算类型项目Calculated items

  通过redis自带的info命令可以监控keyspace_hits和keyspace_misses这两个值,但是redis的命中率不能直接获取,可以通过zabbix的calculated items实现监控redis的命中率
  https://www.zabbix.com/documentation/2.2/manual/config/items/itemtypes/calculated
  zabbix从1.8.1开始支持这个功能
  在新建item时,需要选择type为Calculated。
  在Key一栏填入新key的名称
  在Formula栏填入新key的计算表达式
  

  func(|,,,...)
  

  func是https://www.zabbix.com/documentation/2.2/manual/appendix/triggers/functions 文档中所支持的函数
  key 是需要使用到的其他item,最好用双引号""将key值扩住,如果key值中间有引号需要用\转义。

  parameter 需要使用的其他参数

  

  示例:
  1.zabbix计算最近的磁盘空余空间和磁盘总空间的比率。
  100*last("vfs.fs.size[/,free]",0)/last("vfs.fs.size[/,total]",0)
  2.计算平均10分钟内zabbix处理的值
  avg("Zabbix Server:zabbix",600)
  计算类型的item,如果获取间隔时间过长会影响zabbix server的性能
  3.计算eth0总的带宽
  last("net.if.in",0)+last("net.if.out",0)
  4.计算入口流量的比例
  100*last("net.if.in",0)/(last("net.if.in",0)+last("net.if.out",0))
  5.
  last("grpsum[\"video\",\"net.if.out\",\"last\",\"0\"]",0) / last("grpsum[\"video\",\"nginx_stat.sh\",\"last\",\"0\"]",0)
  

  

  经过测试如果Formula表达式内有宏定义如{#REDISPORT},整个表达式需要用括号()扩住。所以添加表达式的时候可以把整个表达式都用()扩住,不管是否有宏定义。
  

http://s3.运维网.com/wyfs02/M02/4A/1B/wKiom1QitfnwxBvuAAGwId9A-eQ395.jpg
  

  

  

  




页: [1]
查看完整版本: 添加zabbix计算类型项目Calculated items