ElasticSearch  可以直接使用zabbix官方的模板

模板地址:

https://github.com/mkhpalm/elastizabbix

通过zabbix server 直接监控

1、下载模板文件导入模板

2、把模板关联到zabbix server

3、添加自定义KEY

vim /etc/zabbix/scripts/elastizabbix.py

#!/usr/bin/python
import os
import sys
import json
import urllib2
import time
import errno ttl = 60 stats = {
'cluster': 'http://localhost:9200/_cluster/stats',
'nodes' : 'http://localhost:9200/_nodes/stats',
'indices': 'http://localhost:9200/_stats',
'health' : 'http://localhost:9200/_cluster/health'
} def created_file(name):
try:
fd = os.open(name, os.O_WRONLY | os.O_CREAT | os.O_EXCL)
os.close(fd)
return True
except OSError, e:
if e.errno == errno.EEXIST:
return False
raise def is_older_then(name, ttl):
age = time.time() - os.path.getmtime(name)
return age > ttl def get_cache(api):
cache = '/tmp/elastizabbix-{0}.json'.format(api)
lock = '/tmp/elastizabbix-{0}.lock'.format(api)
should_update = (not os.path.exists(cache)) or is_older_then(cache, ttl)
if should_update and created_file(lock):
try:
d = urllib2.urlopen(stats[api]).read()
with open(cache, 'w') as f: f.write(d)
except Exception as e:
pass
if os.path.exists(lock):
os.remove(lock)
if os.path.exists(lock) and is_older_then(lock, 300):
os.remove(lock)
ret_data = {}
try:
with open(cache) as data_file:
ret_data = json.load(data_file)
except Exception as e:
ret_data = json.loads(urllib2.urlopen(stats[api]).read())
return ret_data def get_stat(api, stat):
d = get_cache(api)
keys = []
for i in stat.split('.'):
keys.append(i)
key = '.'.join(keys)
if key in d:
d = d.get(key)
keys = []
return d def discover_nodes():
d = {'data': []}
for k,v in get_stat('nodes', 'nodes').iteritems():
d['data'].append({'{#NAME}': v['name'], '{#NODE}': k})
return json.dumps(d) def discover_indices():
d = {'data': []}
for k,v in get_stat('indices', 'indices').iteritems():
d['data'].append({'{#NAME}': k})
return json.dumps(d) if __name__ == '__main__':
api = sys.argv[1]
stat = sys.argv[2]
if api == 'discover':
if stat == 'nodes':
print discover_nodes()
if stat == 'indices':
print discover_indices() else:
stat = get_stat(api, stat)
if isinstance(stat, dict):
print ''
else:
print stat
vim /etc/zabbix/zabbix_agentd.d/es.conf

UserParameter=elastizabbix[*],/etc/zabbix/scripts/elastizabbix.py $1 $2

  

zabbix 监控 ElasticSearch的更多相关文章

  1. zabbix监控Elasticsearch集群

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

  2. zabbix监控elasticsearch

    1.环境概述 虚拟机系统:CentOS Linux release 7.3.1611 (Core) 宿主机系统:Mac Sierra version 10.12.3 nginx:1.10.3 php: ...

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

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

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

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

  5. zabbix监控实战<1>

    第一章 监控家族 1.1 为什么选择监控? 因为在一个IT集群中或者是一个大环境中,包括各种硬件设备.软件设备等系统的构成也是极其复杂的. 多种应用构成负载的IT业务系统,保证这些资源的正常运转,是一 ...

  6. Zabbix监控实例

    本节内容: zabbix web添加主机 定义Items 创建graph 创建template 一.zabbix web添加主机 1. 进入zabbix web界面,点击配置—>主机—>创 ...

  7. 使用Zabbix监控Oracle数据库

    Orabbix介绍 监控Oracle数据库我们需要安装第三方提供的Zabbix插件,我们先测试比较有名的Orabbix,http://www.smartmarmot.com/product/orabb ...

  8. Zabbix监控nginx-rtmp status(json版)

    与前面的文章 zabbix监控nginx-rtmp status(html版)区别只在于取值的页面不一样 http://127.0.0.1:81/control/get/all_streams sta ...

  9. Zabbix监控mysql performance

    介绍 zabbix监控mysql性能,使用zabbix自带的mysql监控模板,可以监控以下内容OPS(增删改查).mysql慢查询数量.mysql请求\响应流量带宽 配置 新建mysql监控用户 G ...

随机推荐

  1. TIScript 代码Demo

    var filelist = null; function alert(msg) { view.msgbox(null,msg); } self.on("click", " ...

  2. linux远程安装和使用

    Putty:一个Telnet.SSH.rlogin.纯TCP以及串行接口连接软件,体积小.完全免费.使用方便快捷,基本的功能都有.有点不好的地方:在一界面上一次只能打开一个窗口,对于快速查看和操作不太 ...

  3. 使用 vm 加载文件中的数据到变量里面

    .json 不能写注释, 还需要严格的双引号 或者使用 .json5 // test.db [ // name {name: 1} ] // test.js const fs = require('f ...

  4. ELK之使用filebeat收集java运行日志

    安装filebeat修改配置文件/etc/filebeat/filebeat.yml filebeat.prospectors: - type: log enabled: true #日志路径 pat ...

  5. LDAP - 轻量目录访问协议

    LDAP是轻量目录访问协议,英文全称是Lightweight Directory Access Protocol,一般都简称为LDAP

  6. C和C指针小记(二)-注释,三字母词,编译选项

    课后的几个问题: 1) int x/*blah blah*/y; 会有什么问题? 答:编译器报错,语句中不应该有多行注释 单行注释也应该放到语句后面或者独自占一行. 2)打出下面一行字符串(包括引号) ...

  7. android&sqlsever

    http://blog.csdn.net/chaoyu168/article/details/51910601

  8. Chap4:探究操作系统[The Linux Command Line]

    1 learn some more commands: (1) ls-List directory contents (2) file -Determine file type (3) less-Vi ...

  9. Aspects源码解析(转载)

    文章来源:https://www.jianshu.com/p/2c93446d86bd

  10. 2018/05/11 PHP 设计模式之 适配器模式

    什么是适配器模式? 简单来说,我想买一根充电线,我买一根安卓的?还是买一根苹果的? 我也不确定,因为我以可能会换手机,对于我的形式我也不确定. 所以,我要买一根可以同时适配 安卓/苹果 的线. 所谓适 ...