# statware

> Node.js process/system/custom metrics aggregation suite with middle-ware like abilities.

Latest version **1.1.3** (published 2014-10-13) · 0 weekly downloads

## Install

```sh
npm install statware
pnpm add statware
yarn add statware
bun add statware
```

## 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.3 |
| Published | 2014-10-13 |
| First published | 2013-03-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.8.0 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Bryce B. Baril |
| Maintainers | bryce |
| Keywords | monitoring, health, status, stats, performance, ravenwall |

## Links

- npm: https://www.npmjs.com/package/statware
- Repository: http://github.com/Ravenwall/node-statware
- Homepage: https://github.com/Ravenwall/node-statware
- Issues: https://github.com/Ravenwall/node-statware/issues
- npm.io page: https://npm.io/package/statware

## Dependencies (2)

- [fixed-array](https://npm.io/package/fixed-array.md) ~1.0.0
- [stats-incremental](https://npm.io/package/stats-incremental.md) ~1.1.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2014-10-13
- 1.1.2 — 2014-09-03
- 1.1.1 — 2014-09-03
- 1.1.0 — 2014-06-09
- 1.0.1 — 2014-06-09
- 1.0.0 — 2014-06-09
- 0.4.1 — 2013-09-25
- 0.4.0 — 2013-09-25
- 0.3.0 — 2013-06-23
- 0.2.11 — 2013-06-23
- 0.2.10 — 2013-06-23
- 0.2.9 — 2013-06-21
- 0.2.8 — 2013-06-21
- 0.2.7 — 2013-05-11
- 0.2.6 — 2013-05-11
- … 7 more at https://npm.io/package/statware/versions

## README

statware
=============

[![NPM](https://nodei.co/npm/statware.svg)](https://nodei.co/npm/statware/)

Node.js status monitoring wares.

```javascript
var statware = require("statware")

var stats = statware()

// Optionally install pre-defined metric collections
stats.installProcessInfo()
stats.installSystemInfo()

// Register an asynchronous middleware helper
stats.registerHelper(function (status, next) {
  status.foo = (new Date()).toString()
  next()
})

// Set values manually
stats.set("cat", "meow")

// Incrementers
stats.increment("lines")
stats.increment("lines")
stats.increment("lines")

// windowed stats -- keeps the last `windowSize` records and reports on them
var windowed = stats.windowedStat("games", 10)
windowed.push(50)
windowed.push(100)
windowed.push(75)

// rolling stats for the lifetime of the process
var s = stats.addStat("ht")
s.update(40)
s.update(1000)
s.update(352)
s.update(550)

// namespaces

var ns = stats.namespace("ns")
ns.increment("foo")

// now read the stats by providing a callback function
stats.getStats(function (metrics) {
  console.log(metrics)
})

/*
  { cat: 'meow',
  lines: 3,
  ns: { foo: 1 },
  process_info:
   { uptime: 0,
     memory: { rss: 13094912, heapTotal: 6163968, heapUsed: 1938952 },
     active_requests: 0,
     active_handles: 0,
     versions:
      { http_parser: '1.0',
        node: '0.10.28',
        v8: '3.14.5.9',
        ares: '1.9.0-DEV',
        uv: '0.10.27',
        zlib: '1.2.3',
        modules: '11',
        openssl: '1.0.1g' },
     node_env: '',
     pid: 61429,
     title: 'node',
     user: 'bryce' },
  system_info:
   { freemem: 2590896128,
     totalmem: 17179869184,
     arch: 'x64',
     platform: 'darwin',
     uptime: 4015625,
     loadavg: { '1m': 4.21923828125, '5m': 4.244140625, '15m': 4.0029296875 },
     cores: 8,
     cpu_model: 'Intel(R) Core(TM) i7-4960HQ CPU @ 2.60GHz',
     cpu_speed: 2600 },
  foo: 'Sun Jun 08 2014 20:23:48 GMT-0700 (PDT)',
  games: { n: 3, min: 50, max: 100, mean: 75 },
  ht:
   { n: 4,
     min: 40,
     max: 1000,
     sum: 1942,
     mean: 485.5,
     variance: 121290.75,
     standard_deviation: 348.2682156040083 },
  statware: { checktime: 1402284228839, stats_runtime: 0.001205082 } }
*/

```

API
===

`Statware([initial])`
---

Create a statware stats instance, with optional initial value object of `initial`.

`statwareInstance.getStats(callback)`
---

Fetch the stats object. The `callback` should be of form `callback(statsObject)` where `statsObject` is a pure Js object with the statware internal stats.

`statwareInstance.registerHelper(helper)`
---

Register an asynchronous helper function to be called whenever `stats.getStats(cb)` is called. The helper must be in the form of `helper(statsObject, next)` and *must* call `next()` one time. The `statsObject` is the internal stats object from `statware` and can be mutated to add, remove, or modify values. Returns itself for chaining.

`statwareInstance.set(key, value)`
---

Set a key to a value explicitly

`statwareInstance.increment(key)`
---

Update an incrementing key

`var fixedArray = statwareInstance.windowedStat(key, windowSize)`
---

Create a [FixedArray](http://npm.im/fixed-array) at `key` that will have n, min, max, mean reported for it at each `getStats()` call.

`var statsIncremental = statwareInstance.addStat(key)`
---

Create a [stats-incremental](http://npm.im/stats-incremental) instance that will report `getAll()` every time `getStats()` is run.

`var namespace = statwareInstance.namespace(name)`
---

Create a top-level namespace inside the `statInstance` that behaves almost identically to `statwareInstance` except it cannot define deeper namespaces.

`stawareInstance.installProcessInfo()`
---

Register a pre-defined helper that collects a set of process-related information.

`statwareInstance.installSystemInfo()`
---

Register a pre-defined helper that collects a set of system-related information.

LICENSE
=======

MIT

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