scripts/couchdb_check_replication
author Tomas Zeman <tzeman@volny.cz>
Tue, 09 Jul 2013 12:08:33 +0200
changeset 25 4cbcc8af8481
parent 10 5183f2628cd2
permissions -rwxr-xr-x
Fix #1: Commit 4bccc75 broke .cz domains

#!/usr/bin/env python
# -*- coding: latin1 -*-

"""
CouchDB replication status checker.

Checks output of curl _active_tasks and returns number of running replication tasks.
Invocation:

    curl -s -X GET http://localhost:5984/_active_tasks | ./check_replication

"""

import re
import simplejson as json
import sys

try:
    d = json.load(sys.stdin)
    cnt = 0
    for e in d:
        if e["type"] == "Replication" and re.search("Processed source update", e["status"]):
            cnt += 1
    print cnt
except Exception:
    print 0

# vim: et:ts=4:sw=4