Last update: February 24, 2022
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.
If you are looking for commercial support for this monitoring plugin, need customized modifications or in general customized monitoring plugins, contact us at Infiniroot.com.
1635 downloads so far...
Download plugin and save it in your Nagios/Monitoring plugin folder (usually /usr/lib/nagios/plugins, depends on your distribution). Afterwards adjust the permissions (usually chmod 755).
Community contributions welcome on GitHub repo.
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"
20220221: Replace jshon with jq
20220221: Improve output of detected replications
20220222: Handle "One Time" replications, add -i parameter (issue #5)
20220222: Improve all HTTP requests with a dedicated function
20220223: Add (basic) performance data when checking ALL replications
Parameter | Description |
-H* | Hostname or ip address of CouchDB Host (or Cluster IP) |
-P | Port (defaults to 5984) |
-S | Use secure http (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 |
-i | Include non-continuous (one time) replications in check (default: off) |
-h | Help! |
* mandatory parameter
+ Either -d for detection or -r is mandatory to check replication status (doc_id)
Usage:
./check_couchdb_replication.sh -H hostname [-P port] [-S] [-u user] [-p password] [-i] (-d|-r doc_id)
Example: 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,)
# '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$
}
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)"
}
"-i" = {
set_if = "$couchdb_include_one_time_replications$"
description = "iInclude 'One time' replications in check (default: off)"
}
"-r" = {
value = "$couchdb_replication$"
description = "Replication
ID to monitor (doc_id)"
}
}
vars.couchdb_address = "$address$"
vars.couchdb_port = "5984"
vars.couchdb_include_one_time_replications = false
}
In this example, 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.
# 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 this 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.
# 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"
}
The next example shows how 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.
# 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"
}