How to use the os.loadavg function in os

To help you get started, we’ve selected a few os examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Comcast / Speed-testJS / modules / domain.js View on Github external
function getLoadAverages(){
    return os.loadavg();
  }
  /**
github sematext / sematext-agent-docker / lib / linuxAgent.js View on Github external
var timerId = setInterval(function () {
            var time = new Date().getTime()
            var metrics = {}
            metrics['collectd-sys-load'] = os.loadavg()
            metrics['collectd-mem-free'] = os.freemem()
            metrics['collectd-mem-used'] = os.totalmem() - os.freemem()
            if (self.isLinux) {
              linux.df(function dfMetrics (err, data) {
                if (err) {
                  return logger.error('Error in df() for disk-usage metrics:' + err)
                }
                if (data && data.length > 0) {
                  data.forEach(function (disk) {
                    if (/\/dev\/.+/i.test(disk.filesystem)) {
                      var dev = disk.filesystem.split('/')[2]
                      var usedName = 'collectd5-disk-space-used\tdf-' + dev + '/df_complex-used'
                      var usedValue = disk.used * 1024
                      var freeName = 'collectd5-disk-space-free\tdf-' + dev + '/df_complex-free'
                      var freeValue = disk.available * 1024
                      agent.addMetrics({
github Reportr / tracker-machine / bin / tracker.js View on Github external
var update = function() {
    var properties = {
        'loadavg': _.first(os.loadavg()),
        'totalmem': os.totalmem(),
        'freemem': os.freemem()
    };

    client.postEvent(program.event, properties)
    .then(function() {
        console.log("posted");
    }, function(e) {
        console.log("failed:", e.message || e);
    });
};
github nosco / multi-cluster / lib / multi-cluster.js View on Github external
var aggregateStats = function(callback) {
  var masterMem = process.memoryUsage();

  var stats = { all: {}, perApp: {}, aggregated: {} };

  stats.aggregated = {
    loadavg: os.loadavg(),
    totalmem: os.totalmem(),
    freemem: os.freemem(),
    usedmem: (os.totalmem() - os.freemem()),
    cpus: os.cpus().length,
    processes: 1,
    workers: 0,
    rss: masterMem.rss,
    heapTotal: masterMem.heapTotal,
    heapUsed: masterMem.heapUsed
  };

  stats.perApp[ process.argv[1] ] = util._extend({ workers: 1}, process.memoryUsage());

  for(var id in cluster.workers) {
    stats.aggregated.processes++;
github Electron-Microscope / electron-microscope / src / app / main / dashboard / load-average / shared / load-average / load-average.service.ts View on Github external
return Observable.interval(interval * 1000).timestamp().map(x => {
      return {
        load: loadavg(),
        timestamp: new Date(x.timestamp),
        sequenceNumber: x.value
      };
    });
  }
github ninjablocks / client / lib / Metrics.js View on Github external
setInterval(function () {
    var memory = process.memoryUsage();
    this.log.info('sample#node.rss=' + memory.rss, 'sample#node.heapTotal=' + memory.heapTotal, 'sample#node.heapUsed=' + memory.heapUsed);
    var load = os.loadavg();
    this.log.info('sample#os.load1=' + load[0], 'sample#os.load5=' + load[1], 'sample#os.load15=' + load[2]);
    var bench = new Hoek.Bench();
    setImmediate(function () {
      self.log.info('sample#node.threadDelay=' + bench.elapsed());
    });
  }.bind(this), this.opts.statsInterval);
};
github matrix-io / matrix-os / apps / monitor.matrix / app.js View on Github external
setInterval(function(){
		var loadavg = os.loadavg();
		var length = loadavg.length;
		var avg = loadavg.reduce(function(total, num){ return total + num }, 0)/length;
		var memory = 1 - os.freemem()/os.totalmem();
		matrix.type('monitor').send({ 'cpu': avg, 'memory': (memory*100) });
},1000);
github tungtouch / HubTaxi-Server / server.js View on Github external
app.get('/os', function (req, res, next) {
        var ret = {
            hostname: os.hostname(),
            platform: os.platform(),
            type: os.type(),
            loadAvg: os.loadavg(),
            totalMemory: os.totalmem() / 1024 / 1024 / 1024,
            freemem: os.freemem() / 1024 / 1024 / 1024,
            usageMem: ((os.totalmem() - os.freemem()) / 1024 / 1024 / 1024),
            cpus: os.cpus(),
            tmpdir: os.tmpdir(),
            networking: os.networkInterfaces(),
            uptime: os.uptime(),
            arch: os.arch(),
            release: os.release(),
            endianness: os.endianness(),
            status: 'ok'
        };
        res.json(ret);
    });
github rurseekatze / node-tileserver / init-rendering.js View on Github external
eventEmitter.on('tileFinished', function()
{
	if (os.loadavg()[0] <= cpus+1)
	{
		if (y < tilecount-1)
			y++;
		else
		{
			if (x < tilecount-1)
			{
				x++;
				y = 0;
			}
			else if (z < configuration.maxPrerender)
			{
				z++;
				logger.info('Rendering zoom level '+z);
				tilecount = Math.pow(2, z);
				x = 0;