Giter Site home page Giter Site logo

jakub50 / nagios-plugin-kafka Goto Github PK

View Code? Open in Web Editor NEW

This project forked from harisekhon/nagios-plugin-kafka

0.0 0.0 0.0 391 KB

Kafka Scala API CLI / Advanced Nagios Plugin, with Kerberos support (uses Kafka 0.9+ native Java API)

Home Page: https://www.linkedin.com/in/HariSekhon

License: Other

Makefile 12.88% Scala 52.33% Shell 23.42% Groovy 7.56% Java 3.81%

nagios-plugin-kafka's Introduction

Kafka Scala API - Advanced Nagios Plugin / CLI Tool with Kerberos support

Codacy CodeFactor Quality Gate Status Maintainability Rating Reliability Rating Security Rating GitHub stars GitHub forks

Linux Mac Docker DockerHub Pulls DockerHub Build Automated Docker Build Status MicroBadger CI Builds Overview

Travis CI AppVeyor Drone CircleCI Codeship Status for HariSekhon/Nagios-Plugin-Kafka Shippable Codefresh Wercker BuildKite buddy pipeline Cirrus CI Concourse GoCD Jenkins

Azure DevOps Pipeline BitBucket Pipeline GitLab Pipeline Repo on GitHub Repo on GitLab Repo on BitBucket

CI Mac CI Ubuntu CI Ubuntu 16.04 CI Ubuntu 18.04 CI Debian CI Debian 9 CI Debian 10 CI CentOS CI CentOS 6 CI CentOS 7 CI CentOS 8 CI Fedora CI Alpine CI Alpine 3

CI Maven CI SBT CI Gradle

Kafka 0.9+ API CLI Tester & Advanced Nagios Plugin with Kerberos support, written in Scala.

Tested on Hortonworks HDP 2.4.0 with Kerberos + Ranger ACLs and Apache Kafka 0.8.x / 0.9.0.1 docker images with regular ACLs.

You may need to change the Kafka library version in pom.xml / build.sbt / build.gradle before building to match your deployed Kafka server / cluster otherwise it may hang when run due to version / protocol mismatch.

See The Advanced Nagios Plugins Collection for many more related enterprise monitoring programs.

Hari Sekhon

Cloud & Big Data Contractor, United Kingdom

(ex-Cloudera, former Hortonworks Consultant)

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

(you're welcome to connect with me on LinkedIn)

Intro

This project builds a single self-contained Java jar file with all dependencies included and can simply be run on the command line with full switch option support:

java -jar check_kafka.jar --help

and there is an optional convenience shell wrapper script at the top level to make commands shorter:

./check_kafka --help

Run against one or more Kafka brokers, comma separated:

./check_kafka --brokers localhost:9092 --topic test
OK: Kafka broker successfully returned unique message via topic 'test' partition '0', write time = 0.185s, read time = 0.045s, total time = 1.729s | write_time=0.185s read_time=0.045s total_time=1.729s

Use the --verbose switch to also show the brokers list that were tested. If you have specified one of the kerberos switches (or edited the consumer/producer properties files to do so) then the output will additionally contain the marker with sasl authentication to let you know that it was a secure configuration that was tested (originally I called this with kerberos but technically it may not be in future).

OK: Kafka broker '<hortonworks_host>:6667' successfully returned unique message via topic 'topic3' partition '0' with sasl authentication, write time = 0.148s, read time = 0.043s, total time = 0.691s | write_time=0.148s read_time=0.043s total_time=0.691s
Kafka 0.9+ API Caveats

This program only supports Kafka 0.9+ as the API changed (again) and Kerberos security was only added in the 0.9 API. For Kafka versions before 0.9 you can find Python and Perl versions of this program in the Advanced Nagios Plugins Collection that support 0.8 onwards (they dosn't support Kafka <= 0.7 as the API changed in 0.8 too and the underlying libraries in those languages don't support Kakfa <= 0.7).

It appears that several errors are caught too early in the new Kafka Java API and result in embedded looping retry behaviour on encountering errors (visible in debug level logging of the base library).

I haven't found a great way of handle that behaviour as it's not exposed to the client code so it ends up being handled via my generic default self timeout mechanism that I apply to all my tools. Hence if you specify an incorrect --brokers <host>:<port> or the Kafka brokers are down you or fail to negotiate the protocol due to security settings you will only receive a generic UNKNOWN: self timed out after 10 secs message as the code self terminates.

Otherwise the Kafka API would just hang there indefintely as it keeps retrying deeper in the library. I've tried various settings to get it to time out but nothing worked and I even posted to the Kafka users mailing list without answer. If you know of a setting that will make the Kafka Client library time out and return the more specific error then please let me know and I'll update this code accordingly.

Keberos Support

See the conf/ directory for JAAS kerberos configurations.

If you're running the code on a Hortonworks Kafka broker it'll auto-detect the HDP configuration and use that.

Build

Quick Start - Docker

A Dockerized pre-built version is available on DockerHub.

If you have docker installed this one command will download and run it:

docker run harisekhon/nagios-plugin-kafka check_kafka --help

Automated Build from Source

Maven, Gradle and SBT automated builds are all provided.

A self-contained jar file with all dependencies will be created and symlinked to check_kafka.jar at the top level.

The Maven and Gradle builds are best as they will auto bootstap and run with no prior installed dependencies other than Java and make to kick it off.

The default make build will trigger a Gradle bootstrap from scratch with has an embedded checksum for security:

make

You can call any one of the 3 major build systems explicitly instead, which will recurse to build the library submodule using the same mechanism:

Maven:

make mvn

Gradle:

make gradle

SBT:

make sbt
Custom TLDs

If using bespoke internal domains such as .local, .intranet, .vm, .cloud etc. that aren't part of the official IANA TLD list then this is additionally supported via a custom configuration file lib/resources/custom_tlds.txt containing one TLD per line, with support for # comment prefixes. Just add your bespoke internal TLD to the file and it will then pass the host/domain/fqdn validations.

Testing

Continuous Integration is run on this repo with tests for success and failure scenarios:

To trigger all tests run:

make test

which will start with the underlying libraries, then move on to top level integration tests and functional tests using docker containers if docker is available.

Kafka 0.8 support - Alternative Perl & Python Kafka API Nagios Plugins

The Advanced Nagios Plugins Collection has both Perl and Python predecessors to this program which work with Kafka 0.8+. The main differenitator with this Scala version is that it uses the new native 0.9+ Java API which has Kerberos support (the dynamic language versions were built on libraries for Kafka 0.8).

See Also

  • DevOps Python Tools - 80+ DevOps CLI tools for AWS, Hadoop, HBase, Spark, Log Anonymizer, Ambari Blueprints, AWS CloudFormation, Linux, Docker, Spark Data Converters & Validators (Avro / Parquet / JSON / CSV / INI / XML / YAML), Elasticsearch, Solr, Travis CI, Pig, IPython

  • The Advanced Nagios Plugins Collection - 450+ programs for Nagios monitoring your Hadoop & NoSQL clusters. Covers every Hadoop vendor's management API and every major NoSQL technology (HBase, Cassandra, MongoDB, Elasticsearch, Solr, Riak, Redis etc.) as well as message queues (Kafka, RabbitMQ), continuous integration (Jenkins, Travis CI) and traditional infrastructure (SSL, Whois, DNS, Linux)

  • DevOps Bash Tools - 200+ DevOps Bash scripts, advanced .bashrc, .vimrc, .screenrc, .tmux.conf, .toprc, Utility Code Library used by CI and all my GitHub repos - includes code for AWS, Kubernetes, Kafka, Docker, Git, Code & build linting, package management for Linux / Mac / Perl / Python / Ruby / Golang, and lots more random goodies

  • DevOps Perl Tools - 25+ DevOps CLI tools for Hadoop, HDFS, Hive, Solr/SolrCloud CLI, Log Anonymizer, Nginx stats & HTTP(S) URL watchers for load balanced web farms, Dockerfiles & SQL ReCaser (MySQL, PostgreSQL, AWS Redshift, Snowflake, Apache Drill, Hive, Impala, Cassandra CQL, Microsoft SQL Server, Oracle, Couchbase N1QL, Dockerfiles, Pig Latin, Neo4j, InfluxDB), Ambari FreeIPA Kerberos, Datameer, Linux...

  • HAProxy-configs - 80+ HAProxy Configs for Hadoop, Big Data, NoSQL, Docker, Elasticsearch, SolrCloud, HBase, Cloudera, Hortonworks, MapR, MySQL, PostgreSQL, Apache Drill, Hive, Presto, Impala, ZooKeeper, OpenTSDB, InfluxDB, Prometheus, Kibana, Graphite, SSH, RabbitMQ, Redis, Riak, Rancher etc.

  • Dockerfiles - 50+ DockerHub public images for Docker & Kubernetes - Hadoop, Kafka, ZooKeeper, HBase, Cassandra, Solr, SolrCloud, Presto, Apache Drill, Nifi, Spark, Mesos, Consul, Riak, OpenTSDB, Jython, Advanced Nagios Plugins & DevOps Tools repos on Alpine, CentOS, Debian, Fedora, Ubuntu, Superset, H2O, Serf, Alluxio / Tachyon, FakeS3

nagios-plugin-kafka's People

Contributors

harisekhon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.