kikinteractive/nagios-plugins

Name: nagios-plugins

Owner: Kik Interactive

Description: Advanced Nagios Plugins - Hadoop & NoSQL - Redis, Elasticsearch, Solr, HBase, Cassandra & DataStax OpsCenter, MongoDB, MySQL, Kafka, Riak, Memcached, Couchbase, Mesos, Spark, Neo4j, Datameer, H2O, WanDisco, Yarn, HDFS, Impala, Apache Drill, ZooKeeper, Cloudera, Hortonworks, MapR, IBM BigInsights, Infrastructure - Linux, DNS, Whois, SSL Certs etc

Forked from: HariSekhon/nagios-plugins

Created: 2016-02-16 23:58:48.0

Updated: 2016-02-16 23:58:49.0

Pushed: 2016-03-28 17:38:03.0

Homepage: http://www.linkedin.com/in/harisekhon

Size: 2396

Language: Perl

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Advanced Nagios Plugins Collection Build Status

Largest and most advanced collection of unified production-grade Nagios monitoring code in the wild.

Largest collection of Hadoop & NoSQL monitoring code, written by a former Clouderan (Cloudera was the first Hadoop Big Data vendor).

Hadoop and extensive API integration with all major Hadoop vendors (Hortonworks, Cloudera, MapR, IBM).

Python plugins will be moving to their own repo in the near future as this repo has become too large

I've been developing this Nagios Plugin Collection since 2006. The basic Nagios plugins collection that you get with Nagios is a great base to start from to cover some of the basics, while this extends Nagios monitoring capabilities significantly further especially in to the application layer, APIs etc.

It's a treasure trove of essentials for every single “DevOp”, sysadmin or engineer, with extensive goodies for those running Web, Hadoop and NoSQL technologies (Cassandra, HBase, MongoDB, Riak, Couchbase, Memcached, Redis, Solr, SolrCloud, ElasticSearch…), Mesos etc.

These programs can also be run standalone on the command line as tools and used in scripts as well as run via Nagios.

This should be the next stop after installing Nagios with it's basic plugins.

I also take suggestions for interesting new plugins or those involving interesting open source technologies.

Github pull requests for patches and features are more than welcome.

Hari Sekhon

Big Data Contractor, United Kingdom

http://www.linkedin.com/in/harisekhon

Make sure you run `make updateif updating and not just ``git pull``` as you will often need the latest library submodule and possibly new upstream libraries.
Quick Start
clone https://github.com/harisekhon/nagios-plugins
agios-plugins

Don't copy plugins out as most require the co-located libraries I've written so you should copy this directory as a whole after building it - it's simpler than trying to extract bits and pieces.

Be aware this will install yum rpms / apt debs automatically as well as a load of CPAN modules for Perl. If you don't want all that stuff automatically installed you must follow the Manual Setup section instead. You may need to install the GNU make system package if the `makecommand isn't found (``yum install make` /apt-get install make``)

Also be aware this has become quite a large project and will take at least 10 minutes to build. Just be glad it's automated and tested on RHEL/CentOS 5/6/7 & Debian/Ubuntu systems. Build will work on Mac OS X too but will not handle system package dependencies.

This automated build will use 'sudo' to install all required Perl modules from CPAN and then initialize my library git repo as a submodule. If you want to install some of the common Perl CPAN modules such as Net::DNS and LWP::* using your OS packages instead of installing from CPAN then follow the Manual Setup section instead.

If wanting to use any of ZooKeeper znode checks for HBase/SolrCloud etc based on check_zookeeper_znode.pl or any of the check_solrcloud*zookeeper.pl programs you will also need to install the zookeeper libraries which has a separate build target due to having to install C bindings as well as the library itself on the local system. This will explicitly fetch the tested ZooKeeper 3.4.6, you'd have to update the `ZOOKEEPER_VERSION` variable in the Makefile if you want a different version.

 zookeeper

This downloads, builds and installs the ZooKeeper C bindings which Net::ZooKeeper needs. To clean up the working directory afterwards run:

 clean-zookeeper
Usage –help

All plugins come with –help which lists all options as well as giving a program description, often including a detailed account of what is checked in the code.

Some common options also support optional environment variables for convenience to reduce repeated –switch usage or to hide them from being exposed in the process list. These are indicated in the –help descriptions in brackets next to each option eg. $HOST, $PASSWORD or more specific ones with higher precedence like $ELASTICSEARCH_HOST, $REDIS_PASSWORD etc.

Make sure to install the required Perl CPAN modules first before calling –help.

A Sample of cool Nagios Plugins in this collection

… and there are many more.

This code base is under active development and there are many more cool plugins pending import.

Kerberos Security Support

For HTTP based plugins Kerberos is implicitly supported by LWP as long as the LWP::Authen::Negotiate CPAN module is installed (part of the automated `make` build). This will look for a valid TGT in the environment and if found will use it for SPNego.

Quality

Most of the plugins I've read from Nagios Exchange and Monitoring Exchange (now Icinga Exchange) in the last decade have not been of the quality required to run in production environments I've worked in (ever seen plugins written in Bash with little validation, or mere 200-300 line plugins without robust input/output validation and error handling, resulting in “UNKNOWN: (null)” when something goes wrong - right when you need them - then you know what I mean). That prompted me to write my own plugins whenever I had an idea or requirement.

That naturally evolved in to this, a relatively Advanced Collection of Nagios Plugins, especially when I began standardizing and reusing code between plugins and improving the quality of all those plugins while doing so.

Goals

Several plugins have been merged together and replaced with symlinks to the unified plugins bookmarking their areas of functionality, similar to some plugins from the standard nagios plugins collection.

Some plugins such as those relating to Redis and Couchbase also have different modes and expose different options when called as different program names, so those symlinks are not just cosmetic. An example of this is write replication, which exposes extra options to read from a slave after writing to the master to check that replication is 100% working.

ePN optimization is not supported at this time by any of the plugins as I ran 13,000 checks per Nagios server years ago without ePN optimization - it's not worth the effort.

Contributions

Patches, improvements and even general feedback are welcome in the form of GitHub pull requests and issue tickets.

Examples of your usage and outputs are also welcome for the Wiki as some of these plugins allow a great diversity of checks to be created - for example, free form MySQL queries or ZooKeeper contents checks can be used to check pretty much anything that advanced DBAs and applications/operations personnel can think of with a just a few command line –switches.

Library

Having written a large number of Nagios Plugins in the last several years in a variety of languages (Python, Perl, Ruby, Bash, VBS) I abstracted out common components of a good robust Nagios Plugin program in to a library of reusable components that I leverage very heavily in all my modern plugins and other programs found under my other repos here on GitHub, which are now mostly written in Perl using this library, for reasons of both concise rapid development and speed of execution.

This Library enables writing much more thoroughly validated production quality code, to achieve in a quick 200 lines of Perl what might otherwise take 1500-2000 lines (including some of the more complicated supporting code such as robust validation functions with long complex regexs, configurable self-timeouts, warning/critical threshold range logic, common options and generated usage, multiple levels of verbosity, debug mode etc), dramatically reducing the time to write high quality plugins down to mere hours and at the same time vastly improving the quality of the final code through code reuse, as well as benefitting from generic future improvements to the library.

This gives each plugin the appearance of being very short, because only the core logic of what you're trying to achieve is displayed in the plugin itself, mostly composition of utility functions, and the error handling is often handled in a library too, so it may appear that a simple one line 'curl()' or 'open_file()' utility function call has no error handling at all around it but under the hood the error handling is handled inside the function inside a library, same for HBase Thrift API connection, Redis API connection etc so the client code as seen in the top level plugins knows it succeeded or otherwise the framework would have errored out with a specific error message such as “connection refused” etc… there is a lot of buried error checking code and a lot of utility functions so many operations become one-liners at the top level instead of huge programs that are hard to read and maintain.

I've tried to keep the quality here high so a lot of plugins I've written over the years haven't made it in to this collection, there are a lot still pending import, a couple others `check_nsca.pland ``check_syslog-ng_stats.pl``` are in the more/ directory until I get round to reintegrating and testing them with my current framework to modernize them, although they should still work with the tiny utils.pm from the standard nagios plugins collection.

I'm aware of Nagios::Plugin but my library has a lot more utility functions in it and I've written it to be highly convenient for me to develop with.

Older Plugins

Some older plugins (especially those written in languages other than Perl) may not adhere to all of the criteria above so most have been filed away under the older/ directory (they were used by people out there in production so I didn't want to remove them entirely). Older plugins also indicate that I haven't run or made updates to them in a few years so those may require tweaks and updates.

If you're new remember to check out the older/ directory for more plugins that are less current but that you might find useful.

Manual Setup

Fetch my library repo which is included as a submodule (it's shared between these Nagios Plugins and other programs I've written over the years).

clone https://github.com/harisekhon/nagios-plugins
agios-plugins
submodule init
submodule update

Then install the Perl CPAN and Python modules as listed in the next sections.

Perl CPAN Modules

If installing the Perl CPAN modules via your package manager or by hand instead of running the 'make' command as listed in Quick Setup, then read the 'Makefile' file for the list of Perl CPAN modules that you need to install.

Net::ZooKeeper (for various ZooKeeper content checks for Kafka, HBase, SolrCloud etc)
k_zookeeper_znode.pl
k_zookeeper_child_znodes.pl
k_hbase_*_znode.pl
k_solrcloud_*_zookeeper.pl

The above listed programs require the Net::ZooKeeper Perl CPAN module but this is not a simple `cpan Net::ZooKeeper`, that will fail. Follow these instructions precisely or debug at your own peril:

stall C client library
rt ZOOKEEPER_VERSION=3.4.7
 zookeeper-$ZOOKEEPER_VERSION.tar.gz ] || wget -O zookeeper-$ZOOKEEPER_VERSION.tar.gz http://www.mirrorservice.org/sites/ftp.apache.org/zookeeper/zookeeper-$ZOOKEEPER_VERSION/zookeeper-$ZOOKEEPER_VERSION.tar.gz
zxvf zookeeper-$ZOOKEEPER_VERSION.tar.gz
ookeeper-$ZOOKEEPER_VERSION/src/c
nfigure

 make install

w install Perl module using C library with the correct linking
./contrib/zkperl
 Makefile.PL --zookeeper-include=/usr/local/include/zookeeper --zookeeper-lib=/usr/local/lib
UN_PATH=/usr/local/lib make
 make install

After this check it's properly installed by doing

h should return no errors if successful.

Other Dependencies ###

 plugins, especially ones under the older/ directory such as those that check 3ware/LSI raid controllers, SVN, VNC etc require external binaries to work, but the plugins will tell you if they are missing. Please see the respective vendor websites for 3ware, LSI etc to fetch those binaries and then re-run those plugins.

```check_puppet.rb``` plugin uses Puppet's native Ruby libraries to parse the Puppet config and as such will only be run where Puppet is properly installed.

```check_logserver.py``` "Syslog to MySQL" plugin will need the Python MySQL module to be installed which you should be able to find via your package manager. If using RHEL/CentOS do:

sudo yum install MySQL-python

ry install via pip, but this requires MySQL to be installed locally in order to build the Python egg...

sudo easy_install pip sudo pip install MySQL-python

 Configuration for Strict Domain / FQDN validation ####

ct validations include host/domain/FQDNs using TLDs which are populated from the official IANA list. This is done via the [Lib](https://github.com/harisekhon/lib) submodule - see there for details on configuring this to permit custom TLDs like ```.local``` or ```.intranet``` (both supported by default).

Updating ###

```make update```. This will git pull and then git submodule update which is necessary to pick up corresponding library updates.

ou update often and want to just quickly git pull + submodule update but skip rebuilding all those dependencies each time then run ```make update-no-recompile``` (will miss new library dependencies - do full ```make update``` if you encounter issues).

# Bugs & Workarounds #####

## Kafka dependency NetAddr/IP/InetBase autoload bug ######

ou encounter the following error when trying to use ```check_kafka.pl```:

This is an upstream bug related to autoloader, which you can work around by editing `NetAddr/IP/InetBase.pmand adding the following line explicitly near the top just after ``package NetAddr::IP::InetBase;```:

may also need to install Socket6 from CPAN.

## MongoDB dependency Readonly library bug ######

MongoDB Perl driver from CPAN doesn't seem to compile properly on RHEL5 based systems. PyMongo rewrite was considered but the extensive library of functions results in better code quality for the Perl plugins, it's easier to just upgrade your OS to RHEL6.

MongoDB Perl driver does compile on RHEL6 but there is a small bug in the Readonly CPAN module that the MongoDB CPAN module uses. When it tries to call Readonly::XS, a MAGIC_COOKIE mismatch results in the following error:

Readonly::XS is not a standalone module. You should not use it directly. at /usr/local/lib64/perl5/Readonly/XS.pm line 34.

workaround is to edit the Readonly module and comment out the ```eval 'use Readonly::XS'``` on line 33 of the Readonly module.

 is located here on Linux:

/usr/local/share/perl5/Readonly.pm

here on Max OS X:

/Library/Perl/5.16/Readonly.pm

## IO::Socket::SSL doesn't respect ignoring self-signed certs in recent version(s) eg. 2.020 #####

nt version(s) of IO::Socket::SSL (2.020) seem to fail to respect options to ignore self-signed certs. The workaround is to create the hidden touch file below in the same top-level directory as the library to make this it include and use Net::SSL instead of IO::Socket::SSL.

touch .use_net_ssl

Support for Bugs or Feature Requests ###

se raise a ticket on Github for any bugs or problems encountered in the use of this code (Issues near the top right).

se make sure you have run ```make``` first to pull the latest library submodule and build the necessary CPAN modules, (see [Quick Setup](https://github.com/harisekhon/nagios-plugins#quick-setup) above).

 sure you run the code by hand on the command line with the ```-vvv``` switch for additional debug output and paste the full output in to the issue ticket. If you want to anonymize your hostnames/IP addresses etc you may use the ```scrub.pl``` found in my [Tools](https://github.com/harisekhon/tools) repo.

Contributions ###

ributions are more than welcome with patches accepted in the form of Github pull requests, for which you will receive attribution automatically as Github tracks these merges.

Further Utilities ###

ls](https://github.com/harisekhon/tools) & [PyTools](https://github.com/harisekhon/pytools) repos - contains 30+ programs including useful tools such as:
ve / Pig => Elasticsearch / SolrCloud indexers
doop HDFS performance debugger, native checksum extractor, file retention policy script, HDFS file stats, XML & running Hadoop cluster config differ
`watch_url.pl``` for debugging load balanced web farms
ols for Ambari, Pig, Hive, Spark + IPython Notebook, Solr CLI
de reCaser for SQL / Pig / Neo4j / Hive HQL / Cassandra / MySQL / PostgreSQL / Impala / MSSQL / Oracle / Dockerfiles
`scrub.pl``` anonymizes configs / logs for posting online - replaces hostnames/domains/FQDNs, IPs, passwords/keys in Cisco/Juniper configs, custom extensible phrases like your name or your company name
`validate_json/yaml/xml.py``` - validates JSON, XML, YAML including recursive directories, standard input and even multi-record JSON as found in MongoDB and Hadoop / Big Data systems.
Spark JSON => Parquet converter

See Also ###

y Perl library](https://github.com/harisekhon/lib) - used throughout this code as a submodule to make the programs in this repo short
y Python library](https://github.com/harisekhon/pylib) - Python version of the above library
park => Elasticsearch](https://github.com/harisekhon/spark-apps) - Scala application to index from Spark to Elasticsearch. Used to index data in Hadoop clusters or local data via Spark standalone. This started as a Scala Spark port of my ```pig-text-to-elasticsearch.pig``` from [Tools](https://github.com/harisekhon/tools)

# Weblinks #####

ficial Nagios Homepage: https://www.nagios.org/
gios Command Configuration: http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#command
gios Service Configuration: http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#service

inga (newer alternative to Nagios): https://www.icinga.org/

## Datameer ######

meer plugins referenced from Datameer docs in the Weblinks section along with the official Nagios links. See here for more information on Datameer monitoring with Nagios:

tp://www.datameer.com/documentation/display/DAS30/Monitoring+Hadoop+and+Datameer+using+Nagios

r trying the 1 example plugin there, return to try the 9 plugins in this collection to extend your Datameer monitoring further.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.