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. HBuilder-svn安装与使用【原创】

    目录        安装        使用   步骤 1.安装 1.1工具/插件安装 1.2选择svn,点击安装 1.3完成后,重启即可     -------------------------- ...

  2. web 常用开发工具

    he把字符转化为实体字符 awesome-vue Vue资源 clipboard.js 粘贴板 Share.js 一键分享 nock 模拟异步数据 Clamp.js 限制文本最大行数 pinyin 将 ...

  3. Ubuntu上pip安装uwsgi失败的原因之一(未联网)

    ubuntu@ubuntu:~$ sudo pip install uwsgi 报错:The directory '/home/ubuntu/.cache/pip/http' or its paren ...

  4. Redis 应该是存放的数据超出了范围

    使用ServiceStack操作Redis 发生了 System.StackOverflowException HResult=0x800703E9 Source=<无法计算异常源> St ...

  5. php之变量和常量

    PHP中的变量用一个美元符号后面跟变量来表示.变量名是区分大小写的. 变量与PHP中其它的标签一样遵循相同的规则.一个有效的变量名有字母或者下划线开头,后面跟上任意数量的字母,数字,或者下划线. 按照 ...

  6. Java、mysql、html、css、js 注释&大小写

    java三种注释 原文链接:https://www.cnblogs.com/miys/p/4bf714ce33068dcf9ac6526309c9b5e6.html 单行注释:// 注释内容 多行注释 ...

  7. LeetCode 897 Increasing Order Search Tree 解题报告

    题目要求 Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the r ...

  8. LeetCode 977 Squares of a Sorted Array 解题报告

    题目要求 Given an array of integers A sorted in non-decreasing order, return an array of the squares of ...

  9. 《linux 用户管理》- useradd/userdel/usermod/groupadd/who/w

    一:概念 在 Linux 中,使用一个 32位整数 来记录每一个用户(USER ID 简单 UID),这意味着在 Linux 中,可以有 40亿 个不同的用户. 系统. 在 /etc/passwd  ...

  10. Maven基本介绍及安装

    什么是Maven 是一个跨平台的项目管理工具. 跨平台是指它几乎可以在现有所有流行的操作系统中运行 maven不仅可以构建项目,还可以依赖管理和项目信息管理 Maven解决了什么问题 maven解决了 ...