NodeJS Sensu metric check providing both status & metric checks for MongoDB
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Sensu mongo check is a nodejs written check providing both status & metrics checks for MongoDB


  • As this check is written in NodeJS, Node has to be installed on the system running it.

  • The metrics check is designed to store data in InfluxDB. Therefore it outputs metrics on stdin and needs an appropriate handler. I have written one in Node that is available as a Gist.


In your Sensu plugins directory run:

npm install sensu-mongo-metrics

Note that it's important to have node_modules in the plugins directory. Otherwise it won't be able to locate client.json.

Then add your mongoDB connection details to your client.json for each of your server. (Different servers might (must) have different credentials so this can't be set up centrally). client.json must be either in Sensu root directory or in conf.d and has to be called client.json. Here's an exemple:

  "client": {
    "name": "Web_server",
    "address": "",
    "subscriptions": [
    "dbPath": "mongodb://localhost:27017/myDatabase",
    "dbOptions": {
      "user": "",
      "pass": "",
      "server": {
          "ssl": false,
          "sslValidate": false

Finally add the check to your checks file specifying the type of check in parameter (either metrics, flushAvgTime, lastFlushTime or usedConnections):

  "checks": {
    "mongo_metrics": {
      "type": "metric",
      "command": "/etc/sensu/plugins/node_modules/sensu-mongo-check/mongoMetrics.js metrics",
      "interval": 30,
      "handlers": ["influxdb"],
      "subscribers": ["default"]
    "mongo_usedCon": {
      "command": "/etc/sensu/plugins/node_modules/sensu-mongo-check/mongoMetrics.js usedConnections 50 70",
      "interval": 60,
      "handlers": ["mail"],
      "subscribers": ["dbServer"]

Health checks

There are 3 different health (or status or standard, name is as you whish) checks. Thresholds are customizable by passing parameters after the check name like mongo.js checkName [warning critical]

  • flushAvgTime default warning 100ms, critical 200ms
  • lastFlushTime default warning 200ms, critical 400ms
  • usedConnections default warning 70%, critical 80%

Note that flushAvgTime and lastFlushTime are only available for instances that use the MMAPv1 storage engine.

Metric check

The metric check gathers the following metrics:

  • used connections (in %)
  • RAM usage (in MB)
  • Virtual memory usage (in MB)
  • Flush average time (in ms)