# HG changeset patch # User Tomas Zeman # Date 1304688424 -7200 # Node ID 5183f2628cd2eea57776fda9fc6ea8c52d33a96e # Parent 8c143dccc517625125406aa41ffaa1c9ef1485c8 couchdb replication monitoring diff -r 8c143dccc517 -r 5183f2628cd2 scripts/couchdb_check_replication --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/couchdb_check_replication Fri May 06 15:27:04 2011 +0200 @@ -0,0 +1,28 @@ +#!/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 diff -r 8c143dccc517 -r 5183f2628cd2 scripts/couchdb_start_replication --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/couchdb_start_replication Fri May 06 15:27:04 2011 +0200 @@ -0,0 +1,2 @@ +#!/bin/sh +curl -X POST http://localhost:5985/_replicate -d '{"source":"http://127.0.0.1:25984/tt2sloane/", "target":"miracle2sppt", "continuous":true}'