Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161332
  • 博文数量: 51
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 471
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-11 10:24
文章分类

全部博文(51)

文章存档

2018年(3)

2017年(22)

2016年(9)

2015年(17)

我的朋友

分类: 系统运维

2015-09-29 11:14:19

主要使用宏变量由客户端将要监控的主机通过宏变量传递给zabbbixserver

编辑配置文件zabbix_agentd.conf

UnsafeUserParameters=1
UserParameter=tag.cluster.ip,/opt/zabbix/script/check-tag-cluster_everyipmem discovery
UserParameter=tag.cluster.ip.mem[*],/opt/zabbix/script/check-tag-cluster_everyipmem check $1
重启服务
/opt/zabbix/script/check-tag-cluster_everyipmem
#!/bin/bash
#author: LG
TAG_CLUSTER_IP_discovery(){
TAG_CLUSTER_IP=(`cat /opt/online_deploy/hosts/tag-cluster.ip`) 
first=1
printf '{\n'
printf '\t"data":[\n'
for((i=0;i<${#TAG_CLUSTER_IP[@]};i++))
 {
  num=$(echo $((${#TAG_CLUSTER_IP[@]}-1)))
  if [ "$i" != ${num} ];then
   if [ $first -eq 0 ]
   then
    printf "\t,\n"
   fi
   printf "\t{\n"
   printf "\t\t\"{#TAGIP}\":\"${TAG_CLUSTER_IP[$i]}\"\n"
   printf "\t}\n"
  else
   printf "\t,\n"
   printf "\t{\n"
   printf "\t\t\"{#TAGIP}\":\"${TAG_CLUSTER_IP[$num]}\"\n"
   printf "\t}\n"
   printf "\t]\n"
   printf "}\n"
  fi
  first=0
 }
}
check_memory(){
 /usr/local/bin/redis-cli -h $1 -p 7500 info memory |grep used_memory_human | awk -F ':' '{print int($2)}'
}
case "$1" in
 discovery)
 TAG_CLUSTER_IP_discovery
 ;;
 check)
 check_memory $2
 ;;
 *)
 echo "Usage:$0 {tag.cluster.ip.mem[IP]}"
esac
创建discovery rules


{#TAGIP}要与客户端写的脚本中的宏变量一致
创建 ITem prototype

创建图形

自动创建10个item和graph

阅读(1148) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~