zabbix通过简单shell命令监控elasticsearch集群状态
简单命令监控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集群状态的更多相关文章
- zabbix通过简单命令监控elasticsearch集群状态
简单命令监控elasticsearch集群状态 原理: 使用curl命令模拟访问任意一个es节点可以反馈的集群状态,集群的状态需要为green curl -sXGET http://serverip: ...
- 如何监控 Elasticsearch 集群状态?
Marvel 让你可以很简单的通过 Kibana 监控 Elasticsearch.你可以实时查看你 的集群健康状态和性能,也可以分析过去的集群.索引和节点指标.
- Linux简单Shell脚本监控MySQL、Apache Web和磁盘空间
Linux简单Shell脚本监控MySQL.Apache Web和磁盘空间 1. 目的或任务 当MySQL数据库.Apache Web服务器停止运行时,重新启动运行,并发送邮件通知: 当服务器磁盘的空 ...
- zabbix监控Elasticsearch集群
本节以 zabbix 为例,介绍如何使用监控系统完成 Elasticsearch 的监控报警. github 上有好几个版本的 ESZabbix 仓库,都源自 Elastic 公司员工 unterge ...
- Prometheus监控elasticsearch集群(以elasticsearch-6.4.2版本为例)
部署elasticsearch集群,配置文件可"浓缩"为以下: cluster.name: es_cluster node.name: node1 path.data: /app/ ...
- 6.监控elasticsearch集群---放弃采用(获取不到数据),建议看另一篇文章:监控elasticsearch
prometheus监控es,同样采用exporter的方案. 项目地址: elasticsearch_exporter:https://github.com/justwatchcom/elastic ...
- zabbix的简单操作(监控客户端MySQL数据包库)
环境准备: 192.168.175.102 zabbix服务端 192.168.175.106 zabbix客户端(监控MySQL) 命令:iptables -F #清空防火 ...
- ElasticSearch集群状态查看命令大全
Elasticsearch中信息很多,同时ES也有很多信息查看命令,可以帮助开发者快速查询Elasticsearch的相关信息. _cat $ curl localhost:9200/_cat =^. ...
- shell脚本监控k8s集群job状态,若出现error通过触发阿里云的进程监控报警
#!/bin/bash while [ 1 ] do job_error_no=`kubectl get pod -n weifeng |grep -i "job"|grep -c ...
随机推荐
- 解决centos6.5不能识别NTFS格式的移动硬盘或U盘问题
0.说明 从windows8拷了一些东西到移动硬盘,然后转到新安装的centos6.5系统上,但是插上移动硬盘的时候发现不能识别,无法正常挂载移动硬盘.到网上一搜,发现原来centos系统默认不识别N ...
- 快速幂&快速乘法
尽管快速幂与快速乘法好像扯不上什么关系,但是东西不是很多,就一起整理到这里吧 快速幂思想就是将ax看作x个a相乘,用now记录当前答案,然后将指数每次除以2,然后将当前答案平方,如果x的2进制最后一位 ...
- asp 调用 vb(activex dll) ,参数传递(传引用)需要注意
今天上午测试 vb 与 c(dll) 之间交互,传递参数的时候,没遇到什么太大的问题. 下午在asp中调用vb(activex dll)时, 在asp代码中传参数到 vb(dll)中时,遇到问题了. ...
- 2018 ACM 网络选拔赛 北京赛区
A Saving Tang Monk II #include <bits/stdc++.h> using namespace std; ; struct node { int x,y,z, ...
- 有意思的undefined columns selected,源于read.table和read.csv
输入以下语法时: read.table(site_file,header=T)->data data<-data[which(data[,5]=="ADD"),] 出现 ...
- EOJ2018.10 月赛(A 数学+思维题)
传送门:Problem A https://www.cnblogs.com/violet-acmer/p/9739115.html 题意: 能否通过横着排或竖着排将 1x p 的小姐姐填满 n x m ...
- 2018acm-icpc江苏邀请赛后记
这场比赛可真难. 不得不说矿大的环境大大出乎了我的意料,无论是校园面积还是基础设施都很好,唯一美中不足的大概是吃了一顿晚饭每个菜都有辣,幸好饭票发的很多,一个人四张饭票,一张饭票可以换3根香蕉,于是我 ...
- LightOJ - 1246 Colorful Board(DP+组合数)
http://lightoj.com/volume_showproblem.php?problem=1246 题意 有个(M+1)*(N+1)的棋盘,用k种颜色给它涂色,要求曼哈顿距离为奇数的格子之间 ...
- JMS学习(七)-ActiveMQ消息的持久存储方式之KahaDB存储
一,介绍 自ActiveMQ5.4以来,KahaDB成为了ActiveMQ默认的持久化存储方式.相比于原来的AMQ存储方式,官方宣称KahaDB使用了更少的文件描述符,并且提供了更快的存储恢复机制. ...
- Seafile 网络磁盘
Seafile 个人 网盘 1.安装 Seafile 1.安装依赖环境 使用 yum 安装 Python 及 MySQL: yum install python python-setuptools p ...