diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 3b315b2..993e5c9 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build/ dist/ venv/ nagios_elasticsearch.egg-info/ +*.egg* +*.pyc \ No newline at end of file diff --git a/.travis.yml b/.travis.yml old mode 100644 new mode 100755 index f79e86b..5b1b32c --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,11 @@ python: - 2.7 install: - - pip install -r requirements.txt --use-mirrors + - pip install -r requirements.txt + before_script: - "pep8 ." + script: - python setup.py test + diff --git a/README.rst b/README.md old mode 100644 new mode 100755 similarity index 90% rename from README.rst rename to README.md index fc3d790..3782af7 --- a/README.rst +++ b/README.md @@ -1,16 +1,16 @@ -#Nagios-ElasticSearch +# Nagios-ElasticSearch A few simple scripts for checking the state of your [ElasticSearch] cluster using Nagios the endpoints of ElasticSearch [![Build -Status](https://secure.travis-ci.org/opentable/nagios-elasticsearch.png)](https://secure.travis-ci.org/opentable/nagios-elasticsearch.png) +Status](https://travis-ci.org/192dot/nagios-elasticsearch.svg?branch=master)](https://travis-ci.org/192dot/nagios-elasticsearch.svg?branch=master) -##How they work +## How they work These plugins work by submitting API requests to a local or remote ElasticSearch server via the [cluster-health] and [node stats] endpoints -###Check Nodes in Cluster +### Check Nodes in Cluster This can be used to specify the nodes that are expected in the cluster. Currently, the check will return as **CRITICAL** if there are any unaccounted for nodes @@ -29,7 +29,7 @@ Options: python check_es_nodes.py --host=myescluster.com --expected_nodes_in_cluster=13 ``` -###Check Cluster Health Status +### Check Cluster Health Status This plugin can be used to get the current cluster health. This will return OK for Green, Warning for Yellow and Critical for Red. @@ -47,7 +47,7 @@ Options: python check_es_cluster_status.py --host=myescluster.com ``` -###Check for Unassigned Nodes in Cluster +### Check for Unassigned Nodes in Cluster This plugin can be used to check for unassigned shards in the cluster. This can potentially indicate that a node is missing from the cluster. The alert will currently indicate a CRITICAL error if an unassigned shard is found @@ -65,7 +65,7 @@ Options: python check_es_unassigned_shards.py --host=myescluster.com ``` -###Check Node JVM Usage +### Check Node JVM Usage This plugin can be used to ensure that the nodes in the cluster are not approaching, or exceeding, the thresholds that we determine that the JVM needs to run at. Currently, if any of the nodes exceed the critical limt, then the cluster will throw a CRITICAL error. If no nodes exceed the critical threshold but a node exceeds the warning threshold, then the cluster will throw a WARNING. @@ -89,11 +89,11 @@ Options: python check_es_unassigned_shards.py --host=myescluster.com ``` -###Installation +### Installation -###Development +### Development -###License +### License This project is licensed under MIT [cluster-health]: http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html diff --git a/check_es_cluster_status.py b/check_es_cluster_status.py old mode 100644 new mode 100755 index e6878d4..54cd17b --- a/check_es_cluster_status.py +++ b/check_es_cluster_status.py @@ -42,7 +42,8 @@ def check(self, opts, args): cluster_status = es_cluster_health['status'].lower() if cluster_status == 'red': - raise Status("CRITICAL", "Cluster status is currently reporting as " + raise Status("CRITICAL", + "Cluster status is currently reporting as " "Red") elif cluster_status == 'yellow': raise Status("WARNING", "Cluster status is currently reporting as " diff --git a/check_es_nodes.py b/check_es_nodes.py old mode 100644 new mode 100755 index ba7c0a1..dba9702 --- a/check_es_nodes.py +++ b/check_es_nodes.py @@ -49,8 +49,9 @@ def check(self, opts, args): "reporting as '%s' but we expected '%s'" % (active_cluster_nodes, nodes_in_cluster)) else: - raise Status('OK', "Number of nodes in the cluster is '%s'" - "which is >= %s as expected" % (active_cluster_nodes, nodes_in_cluster)) + raise Status('OK', "Number of nodes in the cluster is '%s'" + "which is >= %s as expected" % (active_cluster_nodes, + nodes_in_cluster)) if __name__ == "__main__": ESNodesCheck().run() diff --git a/check_es_split_brain.py b/check_es_split_brain.py old mode 100644 new mode 100755 index e3643d6..9be7ab9 --- a/check_es_split_brain.py +++ b/check_es_split_brain.py @@ -48,8 +48,8 @@ def check(self, opts, args): if len(responding_nodes) == 0: raise Status('Unknown', - "All cluster nodes unresponsive:\r\n" - "%s" % (str("\r\n".join(failed_nodes)))) + "All cluster nodes unresponsive:\r\n" + "%s" % (str("\r\n".join(failed_nodes)))) elif len(masters) != 1: raise Status('Critical', "%d masters (%s) found in %s cluster" % (len(masters), @@ -59,14 +59,14 @@ def check(self, opts, args): else: if len(failed_nodes) == 0: raise Status('OK', "%d/%d nodes have same master" - % (len(responding_nodes), len(nodes))) + % (len(responding_nodes), len(nodes))) else: - raise Status('OK', "%d/%d nodes have same master\r\n" - "%d unresponsive nodes:\r\n%s" - % (len(responding_nodes), - len(nodes), - len(failed_nodes), - str("\r\n".join(failed_nodes)))) + raise Status('Warning', "%d/%d nodes have same master\r\n"" + "%d unresponsive nodes:\r\n%s" + % (len(responding_nodes), + len(nodes), + len(failed_nodes), + str("\r\n".join(failed_nodes)))) if __name__ == "__main__": ESSplitBrainCheck().run() diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 index 3324418..88eb166 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ nagioscheck==0.1.6 +pep8==1.7.0 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 35c3863..057d137 --- a/setup.py +++ b/setup.py @@ -9,13 +9,12 @@ def parse_requirements(filename): setup( name="nagios-elasticsearch", description="A selection of Nagios plugins to monitor ElasticSearch.", - long_description=open('README.rst').read(), + long_description=open('README.md').read(), version="0.1.4", packages=find_packages(), author='Paul Stack', author_email='public@paulstack.co.uk', url="https://github.com/stack72/nagios-elasticsearch", - download_url='http://github.com/stack72/nagios-elasticsearch/tarball/0.1.4', scripts=["check_es_nodes.py", "check_es_cluster_status.py", "check_es_jvm_usage.py",