简单命令监控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. jar的打包与共享

    做成jar包的,有个弊处,打包apk时会暴露源码,当然也有解决方案,放在最后讲. 先来解释如何生成jar: 新建工程,将工程编译至无错,右键工程Export... 在弹出的提示框中选择Java文件夹下 ...

  2. HTMLUnit web测试

    httpClient不能动态执行网页中的js,这样无法获取js生成的动态网页.htmlUnit是个解决方法. if you’re considering web application testing ...

  3. Python基础学习(四)

    菜鸟咀嚼python基础之继续. 一.返回函数 第三章已经简单操作了Python的高阶函数,目前继续练手函数作为返回值的特效:通常,高阶函数除了可以接收函数作为参数外,还可以把函数作为结果值返回. 案 ...

  4. java.lang.OutOfMemoryError: unable to create new native thread 居然是MQ问题

    问题: 开发环境,之前一直正常,某天突然用tomcat启动项目后时不时报如下错误: java.lang.OutOfMemoryError: unable to create new native th ...

  5. SQL SERVER与C#数据类型对照表

    分类 SQL SERVER类型 类型说明 C#类型 精确数字 bigint 从 -2^63 (-9223372036854775808) 到 2^63-1 (9223372036854775807)  ...

  6. HDU2072 tri树/map/set/字符串hash

    lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题 水题 就是用来试试字符串算法的 tri树 ...

  7. SVM的两个参数 C 和 gamma

    SVM模型有两个非常重要的参数C与gamma.其中 C是惩罚系数,即对误差的宽容度.c越高,说明越不能容忍出现误差,容易过拟合.C越小,容易欠拟合.C过大或过小,泛化能力变差 gamma是选择RBF函 ...

  8. 附录A Spring Boot应用启动器

    spring Boot应用启动器基本的一共有44种,具体如下: 1)spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置.日志和YAML. 2)spring- ...

  9. js/jquery控制页面动态加载数据 滑动滚动条自动加载事件--转他人的

    js/jquery控制页面动态加载数据 滑动滚动条自动加载事件--转他人的 相信很多人都见过瀑布流图片布局,那些图片是动态加载出来的,效果很好,对服务器的压力相对来说也小了很多 有手机的相信都见过这样 ...

  10. idea常用快捷键及自定义快捷键汇总

    以下都是挨个进行验证过的 生成get和set方法为:alt+insert 自动补全返回值,自动补全变量名称和属性名称:ctrl+alt+v 输入System.out.println()的快捷方法是:输 ...