ejimz / elasticsearch-zabbix Goto Github PK
View Code? Open in Web Editor NEWElasticsearch template and script for zabbix
Elasticsearch template and script for zabbix
Hi, I am using elasticsearch version 2.3.4 and 2.4.0 and Python 2.7.9 and when i run the script i got:
Traceback (most recent call last):
File "./elastic.py", line 6, in
from elasticsearch import Elasticsearch
ImportError: No module named elasticsearch
Can you help with this ?
Hi,
It seems that cluster_stats is deprecated.
Now, ou need to use cluster.node_stats.
I had this error :
/etc/zabbix/scripts/ESzabbix.py cluster index_total
Traceback (most recent call last):
File "/etc/zabbix/scripts/ESzabbix.py", line 40, in <module>
nodestats = conn.cluster_stats()
AttributeError: 'ES' object has no attribute 'cluster_stats'
And I appliyed this patch :
diff --git a/ESzabbix.py b/ESzabbix.py
index 73df8b0..c3081d6 100755
--- a/ESzabbix.py
+++ b/ESzabbix.py
@@ -37,7 +37,7 @@ except Exception, e:
if sys.argv[1] == 'cluster':
if sys.argv[2] in clusterkeys:
- nodestats = conn.cluster_stats()
+ nodestats = conn.cluster.node_stats()
subtotal = 0
for nodename in nodestats['nodes']:
if sys.argv[2] in indexingkeys:
@@ -90,7 +90,7 @@ elif sys.argv[1] == 'service':
else: # Not clusterwide, check the next arg
- nodestats = conn.cluster_stats()
+ nodestats = conn.cluster.node_stats()
print nodestats
for nodename in nodestats['nodes']:
if sys.argv[1] in nodestats['nodes'][nodename]['name']:
[[email protected] es]# python ESzabbix.py cluster status
Traceback (most recent call last):
File "ESzabbix.py", line 6, in
from elasticsearch import *
File "/usr/lib/python2.6/site-packages/elasticsearch/init.py", line 17, in
from .client import Elasticsearch
File "/usr/lib/python2.6/site-packages/elasticsearch/client/init.py", line 4, in
from ..transport import Transport
File "/usr/lib/python2.6/site-packages/elasticsearch/transport.py", line 4, in
from .connection import Urllib3HttpConnection
File "/usr/lib/python2.6/site-packages/elasticsearch/connection/init.py", line 3, in
from .http_urllib3 import Urllib3HttpConnection
File "/usr/lib/python2.6/site-packages/elasticsearch/connection/http_urllib3.p y", line 2, in
import urllib3
File "/usr/lib/python2.6/site-packages/urllib3/init.py", line 10, in
from .connectionpool import (
File "/usr/lib/python2.6/site-packages/urllib3/connectionpool.py", line 31, in
from .connection import (
File "/usr/lib/python2.6/site-packages/urllib3/connection.py", line 45, in
from .util.ssl_ import (
File "/usr/lib/python2.6/site-packages/urllib3/util/init.py", line 4, in < module>
from .request import make_headers
File "/usr/lib/python2.6/site-packages/urllib3/util/request.py", line 5, in
from ..exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError
can anyone help me please?
Hi,
I can get any data out of this template/script.
Would someone point me to a possible way to investigate what's wrong ?
Here is an example of what zabbix-server says:
20386:20160623:102402.582 item "logdb-02:ESzabbix[{$NODENAME},size_in_bytes]" became not supported: Unsupported item key.
20386:20160623:102402.582 item "logdb-02:ESzabbix[service,status]" became not supported: Unsupported item key.
20384:20160623:102732.840 item "logdb-01:ESzabbix[cluster,active_primary_shards]" became not supported: Unsupported item key.
20385:20160623:102734.620 item "logdb-01:ESzabbix[cluster,active_shards]" became not supported: Unsupported item key.
20386:20160623:102737.844 item "logdb-01:ESzabbix[cluster,number_of_data_nodes]" became not supported: Unsupported item key.
20386:20160623:102737.844 item "logdb-01:ESzabbix[cluster,number_of_nodes]" became not supported: Unsupported item key.
20385:20160623:103014.860 item "logdb-02:ESzabbix[cluster,active_primary_shards]" became not supported: Unsupported item key.
20385:20160623:103014.861 item "logdb-02:ESzabbix[cluster,active_shards]" became not supported: Unsupported item key.
20385:20160623:103019.867 item "logdb-02:ESzabbix[cluster,number_of_data_nodes]" became not supported: Unsupported item key.
20385:20160623:103019.867 item "logdb-02:ESzabbix[cluster,number_of_nodes]" became not supported: Unsupported item key.
Jef
Getting below error and unable to start the zabbix agent
zabbix_agentd [15408]: invalid entry [from elasticsearch import Elasticsearch] (not following "parameter=value" notation) in config file [/etc/zabbix/zabbix_agentd.d/ESzabbix.py], line 7
After trying to deploy the template for ElasticSearch monitoring, I finally succeeded getting values from the template. However, I cannot find several items as below:
ES Cache (2 Items)
README contains these items in template but there's no ones from it.
Thanks,
Dear Sir,
post on github (https://github.com/serialsito/Elasticsearch-zabbix) regarding elasticsearch-zabbix, i tried a lot to get successfully monitor ES but failed, i thing m doing something wrong : i want to know where we have to put .py and .userparm file , is this will be configure over zabbix server or over ES-client which i want to monitor ?
by configuring .py and .userparm over zabbix-server i got this error :
item [test:ESzabbix[cluster,status]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.606 item [test:ESzabbix[cluster,unassigned_shards]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.607 item [test:ESzabbix[{$NODENAME},field_size_in_bytes]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.607 item [test:ESzabbix[{$NODENAME},filter_size_in_bytes]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.607 item [test:ESzabbix[{$NODENAME},index_total]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.607 item [test:ESzabbix[{$NODENAME},size_in_bytes]] became not supported: ZBX_NOTSUPPORTED
1299:20150409:110848.608 item [test:ESzabbix[service,status]] became not supported: ZBX_NOTSUPPORTED
https://github.com/mwmanley/Elasticsearch-zabbix/tree/tapad
This seems to work for me on my ES 1.5 clusters with python2.7 and the latest pyes modules.
I meant to create a PR. Meh.
Does anyone know a way to authenticate user created with Search Guard (or X-Pack, whatever)?
I have 3-node elasticsearch cluster. I installed Elasticsearch-zabbix and try to connect to ES cluster. But the problem is that Elasticsearch-zabbix does not have permission to get cluster stats or health. The problem is here:
# Try to establish a connection to elasticsearch
try:
conn = Elasticsearch('localhost:9200', sniff_on_start=False)
except Exception, e:
zbx_fail()
I tried something like that:
# Try to establish a connection to elasticsearch
try:
conn = Elasticsearch('admin:admin@localhost:9200', sniff_on_start=False)
except Exception, e:
zbx_fail()
But it does not work. Is there any way to walk around this issue?
With elasticsearch 2.3 I had to apply next patch:
# diff -uN /opt/scripts/zabbix/ESzabbix.orig /opt/scripts/zabbix/ESzabbix
--- /opt/scripts/zabbix/ESzabbix.orig 2016-06-29 19:11:35.469229468 +0200
+++ /opt/scripts/zabbix/ESzabbix 2016-06-29 19:12:12.893220325 +0200
@@ -46,15 +46,15 @@
for nodename in nodestats['nodes']:
try:
if sys.argv[2] in indexingkeys:
- indexstats = nodestats['nodes'][nodename]['indices']['indexing']
+ indexstats = nodestats['indices']['indexing']
elif sys.argv[2] in storekeys:
- indexstats = nodestats['nodes'][nodename]['indices']['store']
+ indexstats = nodestats['indices']['store']
elif sys.argv[2] in getkeys:
- indexstats = nodestats['nodes'][nodename]['indices']['get']
+ indexstats = nodestats['indices']['get']
elif sys.argv[2] in docskeys:
- indexstats = nodestats['nodes'][nodename]['indices']['docs']
+ indexstats = nodestats['indices']['docs']
elif sys.argv[2] in searchkeys:
- indexstats = nodestats['nodes'][nodename]['indices']['search']
+ indexstats = nodestats['indices']['search']
except Exception, e:
pass
try:
Thank you
Hi
I'm getting this error when exec ESzabbix.py:
root@elasticsearch02:/etc/zabbix# /etc/zabbix/zabbix_scripts/ESzabbix.py cluster index_total
Traceback (most recent call last):
File "/etc/zabbix/zabbix_scripts/ESzabbix.py", line 40, in
nodestats = conn.cluster.node_stats()
File "/usr/local/lib/python2.7/dist-packages/pyes/managers.py", line 620, in node_stats
return self.conn._send_request('GET', path)
File "/usr/local/lib/python2.7/dist-packages/pyes/es.py", line 470, in _send_request
raise_if_error(response.status, decoded)
File "/usr/local/lib/python2.7/dist-packages/pyes/convert_errors.py", line 85, in raise_if_error
raise excClass(msg, status, result, request)
pyes.exceptions.IndexMissingException: [_cluster] missing
This is my pyes version:
root@elasticsearch02:~# pip freeze |grep pyes
pyes==0.99.0
Hi,
I got the following error while importing the template:
Cannot find value map "ES Cluster State" used for item "ElasticSearch Cluster Status" on "Elasticsearch Cluster".
I removed the reference to the valuemap from the template:
<valuemap>
<name>ES Cluster State</name>
</valuemap>
And was able to import it properly.
I would like to fix the issue though, would you tell me what is wrong exactely ?
Hello!
I ran ES 1.7.1 and zabbix 2.4, I just install your monitor scripts and face such issue: when ES is down script returns an exception (but as I understand it should just return 0 in that case)
File "/etc/zabbix/scripts/ESzabbix.py", line 168, in <module>
if conn.ping():
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/utils.py", line 69, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.py", line 190, in ping
self.transport.perform_request('HEAD', '/', params=params)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/transport.py", line 307, in perform_request
status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
File "/usr/local/lib/python2.7/dist-packages/elasticsearch/connection/http_urllib3.py", line 89, in perform_request
raise ConnectionError('N/A', str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f2efa6ecf50>: Failed to establish a new connection: [Errno 111] Connection refused) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f2efa6ecf50>: Failed to establish a new connection: [Errno 111] Connection refused)
Because of that zabbix' trigger didn't switch.
Hi
When ESzabbix.py wait to long tor Elasticsearch to answer, zabbix-agent kills it, leaving lock file. This prevents any further invocations of ESzabbix.py to work. They are waiting for lock to release, and are killed as well by zabbix-agent after configured timeout.
Simple check a the beginning of script, that removes lock if it is as old as cache file should resolve issue:
if use_cache(lock_file): os.remove(loc_file)
Python script from this template doesn't work:
Traceback (most recent call last):
File "./ESzabbix.py", line 5, in
from pyes import *
File "/usr/lib/python2.6/site-packages/pyes/init.py", line 26, in
from .es import ES, file_to_attachment
File "/usr/lib/python2.6/site-packages/pyes/es.py", line 7, in
if six.PY2:
AttributeError: 'module' object has no attribute 'PY2'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.