A stat collection tool for CouchDB.
Last updated 13 days ago by garbados .
Proprietary · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @neighbourhoodie/opservatory-agent 
SYNC missed versions from official npm registry.


Build Status JS Standard Style Greenkeeper badge

A software agent for communicating information about a CouchDB installation to Opservatory.


You can get this tool via NPM:

$ npm i -g @neighbourhoodie/opservatory-agent

Alternatively, you can download binary releases for these environments:

Old versions are available at:

  • https://opservatory.fra1.digitaloceanspaces.com/archive/{version}/{file}

Once installed, you can try the tool like this:

$ opservatory-agent cron
    --couch-url http://admin:password@localhost:5984
    --node-name a.b.c.d
    --service-token ...

This will gather information and upload it to Opservatory.Once completed, it should give you a success message like this:

Investigation completed in ${seconds}s.
Investigation results posted to https://opservatory.app

Opservatory analyses the information reported by the agent and provides reports to users about the health and security of their CouchDB installations.

For more usage information, run opservatory-agent --help.


To protect values like your CouchDB credentials and analyser service access token, we recommend placing any configuration values for the collector into a config file. For example, consider this config.json:

  "couch-url": "http://USERNAME:PASSWORD@localhost:5984",
  "service-url": "http://localhost:5001",
  "service-token": "..."

To tell the agent to use this file, use the --config flag:

$ opservatory-agent cron --config config.json

By setting the config file's permission settings, you can appropriately lock it down for use only by authorized parties. As CouchDB often runs under a couchdb user, we recommend placing this config file in that user's purview, setting its access permissions to 400, and then setting up a cronjob under that user to run regularly. Here is an example of how to do that:

$ su couchdb
$ cd
$ touch config.json
# then, edit the config file appropriately
$ chmod 400 config.json

Now you can create a cronjob from the couchdb user which uses that file. A cronjob that investigates your cluster hourly would look like this:

0 * * * * /PATH/TO/opservatory-agent cron --config /PATH/TO/config.json

Task Files

The agent uses task files to conduct its investigation. By default, it uses the 'standard' task suite, contained in tasks/standard.json, a JSON file containing an array where each element is an object representing a task for the collector to execute.

Tasks have these recognizes properties:

  • access: an object containing keys with jsonpath expressions. Task results are passed through these expressions and the results are mapped to the associated keys. For example: given the results of querying /_all_dbs, the access object { db: '$.*'} will result in [{ db: '_replicator' }, ...]. This is used to template route and name in sub-tasks.
  • after: an array of other task objects to run after this one. Arguments parsed with access from the task's results are merged with the task's own arguments and passed to these sub-tasks.
  • name: a friendly identifier for the task. Defaults to the task's route, and so is useful when that information may not reliably indicate the task's nature or purpose. Like route, this property is templated using handlebars.
  • mode: an optional key that can be set to try in order to indicate that a task should be skipped if it fails. By default, a task that fails halts the investigation.
  • query: an object whose properties are converted into a querystring and used in the task's request.
  • route: a URL fragment indicating the path of the task's request. Like name, this property is templated using handlebars.
  • save: a boolean flag for whether or not the result of a task should be saved. Useful for running tasks solely to populate their sub-tasks.
  • version: a semver version identifier that is tested against a version argument (if it is present) which should be acquired by querying the cluster's root endpoint (/).

Name and Route Templating

The keys name and route are templated using handlebars and the variables gathered by running a task result through the access filter plus any variables from parent tasks. The e helper encodes the parameter using encodeURIComponent so that database and document names can be properly mapped to a URL. In the example, the task which gathers a database's design documents uses the name {{e db}}/_design_docs to indicate that its nature, whereas the route is {{e db}}/_all_docs.

For more task examples, check the collector's default task file.

The Output Object

A collector's investigation will produce a .json.gz archive containing an object with these keys:

  • date: A timestamp in milliseconds since the UNIX epoch for when the investigation occurred.
  • host: The host that was investigated. For example: localhost:5984
  • results: Object containing all the results of the investigation.
  • runTime: How long the collection process took, in milliseconds.
  • version: The version of the collector used in the investigation

The results key contains an object keyed with all the results of the investigation. Each key corresponds to the name of some task that was run, for example: _all_dbs will contain the results of querying /_all_dbs, and $DB_NAME/_design_docs will contain the results of the route named $DB_NAME/_design_docs.

The object behind each of these keys comes directly from the result of the task's HTTP query, so for example _all_dbs might look like this:

	"_all_dbs": ["_replicator", ... ],

The special _os key contains information about the system where the investigation was performed and includes data about system CPU, RAM, network, and disk. Here is an example output:

  "cpus": [
      "model": "Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz",
      "speed": 3174,
      "times": {
        "user": 2265800,
        "nice": 10800,
        "sys": 703400,
        "idle": 12098800,
        "irq": 0
  "disk": {
    "diskPath": "/",
    "free": 10341093376,
    "size": 110863347712
  "network": {
    "lo": [
        "address": "",
        "netmask": "",
        "family": "IPv4",
        "mac": "NO AWOO $350 PENALTY",
        "internal": true,
        "cidr": ""
  "platform": "linux",
  "ram": {
    "free": 11225653248,
    "total": 16538009600
  "release": "4.15.0-36-generic"

The NodeJS built-in library os can be used, by passing the --os flag, to investigate the host system. Here are the methods used to populate the results object:

Development & Testing

Get and build the tool locally with Git:

$ git clone git@github.com:neighbourhoodie/opservatory-agent.git
$ cd opservatory-agent
$ npm install

Now you can run the test suite like this:

$ npm test


Proprietary. Use only with permission of Neighbourhoodie Software GmbH.

Current Tags

  • 2.20.6                                ...           latest (13 days ago)

29 Versions

  • 2.20.6                                ...           13 days ago
  • 2.20.5                                ...           13 days ago
  • 2.20.4                                ...           20 days ago
  • 2.20.3                                ...           2 months ago
  • 2.20.2                                ...           2 months ago
  • 2.20.1                                ...           2 months ago
  • 2.20.0                                ...           4 months ago
  • 2.19.0                                ...           4 months ago
  • 2.18.0                                ...           5 months ago
  • 2.17.1                                ...           6 months ago
  • 2.17.0                                ...           7 months ago
  • 2.16.11                                ...           7 months ago
  • 2.16.10                                ...           8 months ago
  • 2.16.9                                ...           8 months ago
  • 2.16.8                                ...           9 months ago
  • 2.16.7                                ...           9 months ago
  • 2.16.6                                ...           10 months ago
  • 2.16.5                                ...           10 months ago
  • 2.16.4                                ...           10 months ago
  • 2.16.3                                ...           10 months ago
  • 2.16.2                                ...           10 months ago
  • 2.16.1                                ...           10 months ago
  • 2.16.0                                ...           a year ago
  • 2.15.1                                ...           a year ago
  • 2.15.0                                ...           a year ago
  • 2.14.0                                ...           a year ago
  • 2.13.1                                ...           a year ago
  • 2.13.0                                ...           a year ago
  • 2.12.0                                ...           a year ago
Today 0
This Week 0
This Month 42
Last Day 0
Last Week 0
Last Month 0
Dependencies (15)
Dev Dependencies (4)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |