0.9.8 • Published 8 years ago

node-stats-collector v0.9.8

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

stat example:

'use strict'
var Stat = require('node-stats-collector').Stat
var stat = new Stat('example')
var interval = 100

function createCalculateLoopDelay (interval) {
  var previous = process.hrtime()
  return function () {
    var now = process.hrtime()
    var delay = (now[0] - previous[0]) * 1e3 + (now[1] - previous[1]) / 1e6 - interval
    previous = now
    return delay
  }
}

// add custom stat
stat.addStat('loopDelay-'+interval, 'avg', interval, createCalculateLoopDelay(interval))

// add standard load average stat
stat.initLoadAvg(1000)

// add standard freemem average stat (in Kb)
stat.initFreeMem(1000, 1e3)

// add standard totalMem average stat (in Mb)
// stat.initTotalMem(1000, 1e6)

/* stat.reportStats(reportInterval, precision, reportFunction)
 * or
 * stat.reportStats(reportInterval, reportFunction)
 * same but use default precision = 2
 */

stat.reportStats(interval * 50, function (value) {
  console.log('stat value: %s', JSON.stringify(value))
})
0.9.8

8 years ago

0.9.7

8 years ago

0.9.6

8 years ago

0.9.5

8 years ago

0.9.4

8 years ago

0.9.3

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

8 years ago