Header RSS Feed
 
» Monitoring Plugins

Monitoring Plugin: check_couchdb_replication

Last Update: March 26, 2018

This is a plugin to monitor the status of CouchDB replications. Use the -d parameter to list all available replications and monitor them with -r parameter.

Jump to...
Download
Version History
Requirements
Definition of parameters
Command definition
Nagios and Icinga 1 service definition examples
Icinga 2 service definition examples
Screenshots

------------------------

Download
Download check_couchdb_replication check_couchdb_replication.sh
Download plugin and save it in your Nagios/Icinga plugin folder (e.g. /usr/local/nagios/libexec)
Contribute on https://github.com/Napsty/check_couchdb_replication
185 downloads so far...

------------------------

Version History
# 20180105: Created plugin
# 20180108: Added -d detection
# 20180326: Input sanitation (either -d or -r are required)
# 20180326: Avoid confusion about wrong credentials (issue 4)
# 20180326: Add possibility to check all replications at once (-r ALL)
# 20180326: Handle authentication error "You are not a server admin."

------------------------

Requirements
- curl command (SUSE: zypper in curl, Debian/Ubuntu: apt-get install curl)
- jshon command (SUSE: search for jshon, Debian/Ubuntu: apt-get install jshon)
- Other bash relevant commands as tr (plugin checks for its existance)

------------------------

Definition of parameters

Parameter Description
-H * Hostname or ip address of CouchDB Host (or Cluster IP)
-P Port (defaults to 5984)
-S Use https
-u Username if authentication is required
-p Password if authentication is required
-r ** Replication ID to monitor (doc_id) or "ALL" to check all replications
-d ** Dynamically detect and list all available replications
-h Help!

*-H is mandatory for all ways of running the script
**Either -d for detection or -r is mandatory to check replication status (doc_id)

------------------------

Usage

Here are some examples when the plugin is run on the command line.

Check the status of replication "rep_db1":

# ./check_couchdb_replication.sh -H mycouchdb.example.com -u admin -p mysecretpass -r rep_db1
COUCHDB REPLICATION OK - Replication rep_db1 is "running"

If there is no such replication with this doc_id (rep_db1), the plugin will return:

# ./check_couchdb_replication.sh -H mycouchdb.example.com -u admin -p mysecretpass -r rep_db3
COUCHDB REPLICATION CRITICAL - Replication for rep_db3 not found

If you're not sure or you forgot the name (doc_id) of a replication, run the plugin with the -d (detect) parameter:

# ./check_couchdb_replication.sh -H mycouchdb.example.com -d
COUCHDB AVAILABLE REPLICATIONS: "rep_db1" "rep_db2"

In the background, the plugin uses "/_active_tasks" the find the available replications.

Since version 20180326 it is also possible to check all replications (discovered with -d) at once using "-r ALL":

# ./check_couchdb_replication.sh -H mycouchdb.example.com -u admin -p mysecretpass -r ALL
COUCHDB REPLICATION CRITICAL - 2 replications not running ("doc_id":"claudioreptest" "state":"crashing" "info":"unauthorized: unauthorized to access or create database http://admin:*****@localhost:5984/db99/","doc_id":"claudioreptest333" "error_count":1 "info":"Replication `c7d010d31ab268968f22f4d71c5766bf+continuous+create_target` specified by document `claudioreptest333` already started,)

------------------------

Command definition in Nagios and Icinga 1

# 'check_couchdb_replication' command definition
define command{
command_name check_couchdb_replication
command_line $USER1$/check_couchdb_replication.sh -H $ARG1$ -u $ARG2$ -p $ARG3$ -r $ARG4$
}

Command definition in Icinga 2

object CheckCommand "check_couchdb_replication" {
  import "plugin-check-command"
  command = [ PluginContribDir + "/check_couchdb_replication.sh" ]

   arguments = {
      "-H" = {
        value = "$couchdb_address$"
        description = "Hostname or IP Address of CouchDB host or cluster"
      }

      "-P" = {
        value = "$couchdb_port$"
        description = "Port number (default: 5984)"
      }

      "-S" = {
        set_if = "$couchdb_ssl$"
        description = "Use https"
      }

      "-u" = {
        value = "$couchdb_user$"
        description = "Username if authentication is required"
      }

      "-p" = {
        value = "$couchdb_password$"
        description = "Password if authentication is required"
      }

      "-d" = {
        set_if = "$couchdb_detect_replications$"
        description = "Detect and list available replications to monitor (should not be used in Icinga2, only on command line)"
      }

      "-r" = {
        value = "$couchdb_replication$"
        description = "Replication ID to monitor (doc_id)"
      }
  }

  vars.couchdb_address = "$address$"
  vars.couchdb_port = "5984"
}

------------------------

Nagios and Icinga 1 service check examples

# Check CouchDB Replication db1
define service{
  use generic-service
  host_name mycouchdb
  service_description CouchDB Replication DB1
  check_command check_couchdb_replication!mycouchdb!admin!password!rep_db1
}

In the above example, the plugin checks for the current status of the replication with the "doc_id" of "rep_db1". If the status is not "running", the script will exit with a CRITICAL status and returns the current status of the replication.

Nagios and Icinga 1 service check examples

# Check CouchDB Replications
define service{
  use generic-service
  host_name mycouchdb
  service_description CouchDB Replications
  check_command check_couchdb_replication!mycouchdb!admin!password!ALL
}

In the example above, the plugin checks for the current status of all replications found on the given CouchDB host. If the status is not "running", the script will exit with a CRITICAL status and returns the current status and some additional information about the failed replications.

------------------------

Icinga 2 service check examples

# Check CouchDB Replication db1
object Service "CouchDB Replication DB1" {
  import "generic-service"
  host_name = "mycouchdb"
  check_command = "check_chouchdb_replication"
  vars.couchdb_user = "admin"
  vars.couchdb_password = "password"
  vars.couchdb_replication = "rep_db1"
}

In the example above, the plugin checks for the current status of the replication with the "doc_id" of "rep_db1". If the status is not "running", the script will exit with a CRITICAL status and returns the current status of the replication.

# Check CouchDB Replication ALL
object Service "CouchDB Replications" {
  import "generic-service"
  host_name = "mycouchdb"
  check_command = "check_chouchdb_replication"
  vars.couchdb_user = "admin"
  vars.couchdb_password = "password"
  vars.couchdb_replication = "ALL"
}

In the example above, the plugin checks for the current status of all replications found on the given CouchDB host. If the status is not "running", the script will exit with a CRITICAL status and returns the current status and some additional information about the failed replications.

------------------------

Screenshots


Go to Homepage home
Linux Howtos how to's
Monitoring Plugins monitoring plugins
Links links

Valid HTML 4.01 Transitional
Valid CSS!
[Valid RSS]

7121 Days
until Death of Computers
Why?