Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glynnbird/replication_monitor
Simple Cloudant replication monitor command-line tool
https://github.com/glynnbird/replication_monitor
Last synced: 5 days ago
JSON representation
Simple Cloudant replication monitor command-line tool
- Host: GitHub
- URL: https://github.com/glynnbird/replication_monitor
- Owner: glynnbird
- Created: 2024-08-13T15:32:03.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-16T13:35:23.000Z (3 months ago)
- Last Synced: 2024-10-12T22:12:54.864Z (about 1 month ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# replication_monitor
A simple Cloudant replication monitor that polls a single replication doc to see if the replication is working. It uses two Cloudant API calls to do this:
1. [Get a replication scheduler doc](https://cloud.ibm.com/apidocs/cloudant?code=node#getschedulerdocument)
2. [Get replication scheduler job](https://cloud.ibm.com/apidocs/cloudant?code=node#getschedulerjob)This repository is designed to be a jumping off point to allow you to create your own monitoring solution. You may wish to perform some action when a replication is found to have failed (look in source code for comments).
## Installation
Clone this repo. Install dependencies with:
```sh
cd replication_monitor
npm install
```## Configuring
The Cloudant configuration is picked up from environment variables as [described here](https://github.com/IBM/cloudant-node-sdk?tab=readme-ov-file#authentication-with-environment-variables) e.g.
```sh
export CLOUDANT_URL="https://MY_CLOUDANT_SERVICE.cloudant.com"
export CLOUDANT_APIKEY="MY_IAM_APIKEY"
```
## RunningRun the application with:
```sh
npm run start
```where `` is `_id` of a document in Cloudant's `_replicator` database.
e.g.
```sh
npm run start my_replication_doc_id
```If everything is working, the output should be of the form:
```sh
Replication is working: job id someid+continuous+create_target
{
"database": "_replicator",
"docId": "my_replication_doc_id",
"history": [
{
"timestamp": "2024-08-12T10:03:49Z",
"type": "started"
},
{
"timestamp": "2024-08-12T10:03:49Z",
"type": "added"
}
],
"id": "someid+continuous+create_target",
"info": {
"changesPending": 0,
"checkpointedSourceSeq": "23564-g1AAAAgTe",
"docWriteFailures": 0,
"docsRead": 5,
"docsWritten": 5,
"missingRevisionsFound": 5,
"revisionsChecked": 23541,
"sourceSeq": "23564-g1AAAAgTe",
"throughSeq": "23564-g1AAAAgTe"
},
"node": "[email protected]",
"pid": "<0.17912.4439>",
"source": "https://MY_CLOUDANT_SERVICE.cloudant.com/cities/",
"startTime": "2024-08-12T10:03:49Z",
"target": "https://MY_CLOUDANT_SERVICE.cloudant.com/cities4/",
"user": null
}
```## Error codes
The command line tool will return the following exit codes:
- 0 - ok. The replication is running.
- 1 - Missing docID parameter.
- 2 - Cannot fetch replication scheduler doc.
- 3 - Cannot fetch replication scheduler job.
- 4 - The replication is not running. Take action.