简单命令监控elasticsearch集群状态



原理:

使用curl命令模拟访问任意一个es节点可以反馈的集群状态,集群的状态需要为green

curl -sXGET http://serverip:9200/_cluster/health/?pretty



{

  "cluster_name" : "yunva-es",

  "status" : "green",

  "timed_out" : false,

  "number_of_nodes" : 7,

  "number_of_data_nodes" : 6,

  "active_primary_shards" : 66,

  "active_shards" : 132,

  "relocating_shards" : 0,

  "initializing_shards" : 0,

  "unassigned_shards" : 0,

  "delayed_unassigned_shards" : 0,

  "number_of_pending_tasks" : 0,

  "number_of_in_flight_fetch" : 0,

  "task_max_waiting_in_queue_millis" : 0,

  "active_shards_percent_as_number" : 100.0

}



前端使用了nginx验证,需要模拟登陆

curl模拟用户登录命令格式:

curl -u username:password -sXGET http://serverip:9200/_cluster/health/?pretty | grep "status"|awk -F '[ "]+' '{print $4}'



1.修改客户端zabbix配置:

vim /etc/zabbix/zabbix_agentd.conf



UserParameter=es_status,curl -u elkadmin:elkpass -sXGET http://serverip/_cluster/health/?pretty | grep "status"|awk -F '[ "]+' '{print $4}'|grep -c 'green'



重启zabbix-agent使配置生效

service zabbix-agent restart



在zabbix-server端测试

zabbix_get -s ip -p 10050 -k es_status



2.在zabbix的web页面添加对应的监控:



添加监控项item

Confuguration --> Hosts --> 找到对应的主机,点开 Items --> Create item



创建触发器:

Name

es_status_check

es_cluster_status is not green

3.针对es集群中的每个节点做进程监控,如果进程挂了自动重启

配置监控进程item

配置触发器

配置action,看参考

zabbix系列(九)zabbix3.0实现自动触发zabbix-agent端shell脚本任务

http://blog.csdn.net/reblue520/article/details/52315154

触发脚本:

/usr/local/zabbix-agent/scripts/start_es.sh

#!/bin/bash
# if elasticsearch exists kill it
source /etc/profile
count_es=`ps -ef|grep elasticsearch|grep -v grep|wc -l`
if [ $count_es -gt 1 ];then
ps -ef|grep elasticsearch|grep -v grep|/bin/kill `awk '{print $2}'`
fi
# start it su yunva -c "cd /data/elasticsearch-5.0.1/bin && /bin/bash elasticsearch &"

执行:

sudo /bin/bash /usr/local/zabbix-agent/scripts/start_es.sh

报错:

which: no java in (/sbin:/bin:/usr/sbin:/usr/bin)

Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME



解决办法:

在脚本中添加

source /etc/profile



以root用户运行elasticsearch



报错:

can not run elasticsearch as root



网上的方法,针对elasticsearch5.1不起作用

解决方法1:

在执行elasticSearch时加上参数-Des.insecure.allow.root=true,完整命令如下



./elasticsearch -Des.insecure.allow.root=true  

解决办法2:

用vi打开elasicsearch执行文件,在变量ES_JAVA_OPTS使用前添加以下命令



ES_JAVA_OPTS="-Des.insecure.allow.root=true"  



解决办法:

su yunva -c "cd /data/elasticsearch-5.0.1/bin && /bin/bash elasticsearch &"



自动拉起kibana服务的脚本:

cat /usr/local/zabbix/scripts/restart_kibana.sh

#!/bin/bash

# if kibana exists kill it



count_kibana=`ps -ef|grep kibana|grep -v grep|wc -l`

if [ $count_kibana -eq 1 ];then

    ps -ef|grep kibana|grep -v grep|/bin/kill `awk '{print $2}'`

fi

# start it

排错思路:

针对每台es的节点进行检查,发现有无法访问的,问题就出在这里了

# curl http://10.27.1.10:9200/

curl: (56) Recv failure: Connection reset by peer

zabbix通过简单shell命令监控elasticsearch集群状态的更多相关文章

  1. zabbix通过简单命令监控elasticsearch集群状态

    简单命令监控elasticsearch集群状态 原理: 使用curl命令模拟访问任意一个es节点可以反馈的集群状态,集群的状态需要为green curl -sXGET http://serverip: ...

  2. 如何监控 Elasticsearch 集群状态?

    Marvel 让你可以很简单的通过 Kibana 监控 Elasticsearch.你可以实时查看你 的集群健康状态和性能,也可以分析过去的集群.索引和节点指标.

  3. Linux简单Shell脚本监控MySQL、Apache Web和磁盘空间

    Linux简单Shell脚本监控MySQL.Apache Web和磁盘空间 1. 目的或任务 当MySQL数据库.Apache Web服务器停止运行时,重新启动运行,并发送邮件通知: 当服务器磁盘的空 ...

  4. zabbix监控Elasticsearch集群

    本节以 zabbix 为例,介绍如何使用监控系统完成 Elasticsearch 的监控报警. github 上有好几个版本的 ESZabbix 仓库,都源自 Elastic 公司员工 unterge ...

  5. Prometheus监控elasticsearch集群(以elasticsearch-6.4.2版本为例)

    部署elasticsearch集群,配置文件可"浓缩"为以下: cluster.name: es_cluster node.name: node1 path.data: /app/ ...

  6. 6.监控elasticsearch集群---放弃采用(获取不到数据),建议看另一篇文章:监控elasticsearch

    prometheus监控es,同样采用exporter的方案. 项目地址: elasticsearch_exporter:https://github.com/justwatchcom/elastic ...

  7. zabbix的简单操作(监控客户端MySQL数据包库)

    环境准备: 192.168.175.102    zabbix服务端 192.168.175.106    zabbix客户端(监控MySQL) 命令:iptables -F        #清空防火 ...

  8. ElasticSearch集群状态查看命令大全

    Elasticsearch中信息很多,同时ES也有很多信息查看命令,可以帮助开发者快速查询Elasticsearch的相关信息. _cat $ curl localhost:9200/_cat =^. ...

  9. shell脚本监控k8s集群job状态,若出现error通过触发阿里云的进程监控报警

    #!/bin/bash while [ 1 ] do job_error_no=`kubectl get pod -n weifeng |grep -i "job"|grep -c ...

随机推荐

  1. CF603E Pastoral Oddities

    CF603E Pastoral Oddities 度数不好处理.转化题意:不存在连通块为奇数时候就成功了(自底向上调整法证明) 暴力:从小到大排序加入.并查集维护.全局变量记录奇数连通块的个数 答案单 ...

  2. 【POJ3694】Network

    题目大意:给定一个 N 个点,M 条边的无向图,支持 Q 次操作,每次可以向该无向图中加入一条边,并需要回答当前无向图中桥的个数. 题解:(暴力:Q 次 Tarjan) 先进行一次 Tarjan 求出 ...

  3. 使用babel将ES6编译成ES5

    现在ES6已经非常成熟了,我的需求很明确,就是只需要将ES6编译成ES5. 项目目录为 借鉴的博客链接为https://blog.csdn.net/suwu150/article/details/77 ...

  4. Quartz-中断正在执行的任务

    转: Quartz-中断正在执行的任务 2017年11月15日 21:19:17 小小工匠 阅读数:6715更多 所属专栏: Quartz手札   版权声明:[show me the code ,ch ...

  5. JS模块化开发(二)——构建工具grunt

    gruntJs——构建工具:代码压缩.文件合并 安装流程: 1.到nodeJs官网下载安装nodeJs(附带了npm包管理工具) 2.cmd命令行:npm install -g grunt-cli / ...

  6. C# 多窗体之间方法调用

    看似一个简单的功能需求,其实很多初学者处理不好的,很多朋友会这么写: //父窗体是是frmParent,子窗体是frmChildA //在父窗体中打开子窗体 frmChildA child = new ...

  7. 20190312 Windows安装Kafka

    1. 下载 使用版本2.1.1 官网下载地址 2. 安装 2.1. 前提 已安装ZooKeeper,可参考 20190311 Windows安装ZooKeeper 进行安装ZooKeeper 2.2. ...

  8. 版本控制工具Git工具快速入门-Windows篇

    版本控制工具Git工具快速入门-Windows篇 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 最近在学习Golang语言,之前的开发环境在linux上开发的,后来由于办公用的是w ...

  9. python---redis的python使用

    set以及相关: r.set("foo","bar") print(r.get("foo"))#b'bar' #在Redis中设置值,默认, ...

  10. VirtualBox设置共享文件夹

    前提是已经正确安装增强工具,在安装增强工具时,没有faile的,全部done 1.添加共享文件夹(已经在lmg下创建过目录 /mnt/bdshare ) sudo mount -t vboxsf Ba ...