# cmon-client

> CMON client module

Latest version **1.1.2** (published 2017-08-28) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install cmon-client
pnpm add cmon-client
yarn add cmon-client
bun add cmon-client
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.2 |
| Published | 2017-08-28 |
| First published | 2017-05-09 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wyatt |
| Maintainers | wyatt |

## Links

- npm: https://www.npmjs.com/package/cmon-client
- Repository: https://github.com/geek/cmon-client
- Homepage: https://github.com/geek/cmon-client#readme
- Issues: https://github.com/geek/cmon-client/issues
- npm.io page: https://npm.io/package/cmon-client

## Dependencies (3)

- [hoek](https://npm.io/package/hoek.md) 4.1.x
- [wreck](https://npm.io/package/wreck.md) 12.2.x
- [exposition](https://npm.io/package/exposition.md) 1.1.x

## Recent versions

- 1.1.2 (latest) — 2017-08-28
- 1.1.1 — 2017-05-15
- 1.1.0 — 2017-05-11
- 1.0.0 — 2017-05-09
- 0.0.0 — 2017-05-09

## README

# cmon-client
CMON client module

[![Build Status](https://travis-ci.org/geek/cmon-client.svg?branch=master)](https://travis-ci.org/geek/cmon-client)

## Usage

```javascript
const CMonClient = require('cmon-client');

const cmonClient = new CMonClient({
  key: '' // string or buffer version of tls key
  cert: '' // string or buffer version of tls cert
  datacenter: 'cmon.us-sw-1.zone:9163' // datacenter to use for client instance
});

cmonClient.discover((err, containers) => {
  // handler error

  containers.forEach((container) => {
    cmonClient.metrics(container.vm_uuid, (err, metrics) => {
      // handle error

      console.log(metrics); // metrics are in the text exposition format that prometheus uses https://prometheus.io/docs/instrumenting/exposition_formats/
    });
  });
});
```


## API

### new CMonClient(options)

Create a new instance of a CMON client with the provided options.

- `key` - string or buffer used to construct an HTTPS Node.js Agent
- `cert` - string or buffer used to construct an HTTPS Node.js Agent
- `datacenter` - string in the format of hostname:port. Default is 'cmon.us-sw-1.zone:9163'. See `triton datacenters` for the available datacenters to use.

### discover(cb)

Retrieve all available containers running on the configured datacenter. `cb` has the signature `(err, containers)` where each `container` is in the following format:

```json
{
  "server_uuid": "91b757b5-bd29-2126-5ff9-ae9235011ff5",
  "source": "Changefeed",
  "vm_alias": "docker_container_name",
  "vm_image_uuid": "91b757b5-bd29-2126-5ff9-ae9235011ff5",
  "vm_owner_uuid": "91b757b5-bd29-2126-5ff9-ae9235011ff5",
  "vm_uuid": "81205d4a-92f4-c4d9-da8a-aafd689eeabb",
  "cached_date": 1494359171671
}
```

### metrics(vm_uuid, cb)

Retrieve the current available metrics for a running container specified by `vm_uuid`. `cb` has the signature `(err, metrics)` where metrics is an object representation of [exposition text-formatted](https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details) prometheus metrics using the [exposition module](https://www.npmjs.com/package/exposition).

---
_Source: https://npm.io/package/cmon-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
