首页 > 文章 > 杂文

zabbix 监控 elasticsearch监
时间:2019-03-29 14:41:35  点击: 来源:  作者:

curl -u user:123456 -sXGET http://127.0.0.1:9200/_cluster/health/?pretty

#测试连通性,密码信息请根据情况修改



shell 脚本:mkdir /usr/local/zabbix/shellcd /usr/local/zabbix/shellvi es_status.sh ...

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
”您可通过以下微信二维码,赞赏作者“
 
 
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
windows如何挂载webdav?
windows如何挂载webda
linux服务器同步互联网时间
linux服务器同步互联
亚马逊云lightsail服务器使用教程 | 亚马逊云lightsail使用指南
亚马逊云lightsail服
hostdare 4折优惠,直接降价60% 美国洛杉矶低至 $10.4/年 768M内存/1核/10gNVMe/500g流量
hostdare 4折优惠,直接
相关文章
栏目更新
栏目热门

关于我们 | 广告服务 | 联系我们 | 网站地图 | 免责声明 | WAP | RSS


Copyright © 运维之家 2013-2024