Otter-水獭社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 549|回复: 0

zabbix 监控 elasticsearch监

[复制链接]

32

主题

33

帖子

218

积分

中级会员

Rank: 3Rank: 3

积分
218
发表于 2019-3-29 14:54:51 | 显示全部楼层 |阅读模式
curl -u user:123456 -sXGET http://127.0.0.1:9200/_cluster/health/?pretty
#测试连通性,密码信息请根据情况修改


shell 脚本:
mkdir /usr/local/zabbix/shell
cd /usr/local/zabbix/shell
vi es_status.sh
#!/bin/bash
case $1 in
        cluster_name)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\" '/cluster_name/ {print $4}' ;;
        status)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\" 'NR==3 {print $4}' ;;
        timed_out)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==4 {print $1}' |awk -F: '{print $2}' ;;
        number_nodes)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==5 {print $1}' |awk -F: '{print $2}' ;;
        data_nodes)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==6 {print $1}' |awk -F: '{print $2}' ;;
        active_primary_shards)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==7 {print $1}' |awk -F: '{print $2}' ;;
        active_shards)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==8 {print $1}' |awk -F: '{print $2}' ;;
    relocating_shards)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==9 {print $1}' |awk -F: '{print $2}' ;;
    initializing_shards)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==10 {print $1}' |awk -F: '{print $2}' ;;
    unassigned_shards)
        curl  -u user:123456 -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty' |awk -F\, 'NR==11 {print $1}' |awk -F: '{print $2}' ;;
    *)
        echo "Usage: $0 { cluster_name | status | timed_out | number_nodes | data_nodes | active_primary_shards | active_shards | relocating_shards | initializing_shards | unassigned_shards}" ;;
esac

chmod +x es_status.sh

vi /usr/local/zabbix/etc/zabbix_agentd.conf #尾部加入以下
UnsafeUserParameters=1
UserParameter=cluster_name,/usr/local/zabbix/shell/es_status.sh cluster_name
UserParameter=status,/usr/local/zabbix/shell/es_status.sh status
UserParameter=timed_out,/usr/local/zabbix/shell/es_status.sh timed_out
UserParameter=number_nodes,/usr/local/zabbix/shell/es_status.sh number_nodes
UserParameter=data_nodes,/usr/local/zabbix/shell/es_status.sh data_nodes
UserParameter=active_primary_shards,/usr/local/zabbix/shell/es_status.sh active_primary_shards
UserParameter=active_shards,/usr/local/zabbix/shell/es_status.sh active_shards
UserParameter=relocating_shards,/usr/local/zabbix/shell/es_status.sh relocating_shards
UserParameter=initializing_shards,/usr/local/zabbix/shell/es_status.sh initializing_shards
UserParameter=unassigned_shards,/usr/local/zabbix/shell/es_status.sh unassigned_shards

service zabbix_agentd restart

zabbix面板上添加host,链接到模板(模板参考附件)。
https://www.cnop.net/uploadfile/down/zabbix-es.zip


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|Otter-水獭社区 ( 豫ICP备14008196号

GMT+8, 2019-8-24 14:39 , Processed in 1.098376 second(s), 26 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表