Ejemplo n.º 1
1
 async.parallel(tasks, function (err, results) {
   if (err) return console.log(err);
   if (results.battery) clauses.push('battery: ' + results.battery.trim() + '%');
   if (results.temperature) clauses.push('CPU temperature: ' +
     (results.temperature.trim() / 1000) + '° C');
   var cpuLoad = os.loadavg()[1].toFixed(2);
   var memUse = (process.memoryUsage().rss / Math.pow(1000, 2)).toFixed(1) + ' MB';
   var memFree = (os.freemem() * 100 / os.totalmem()).toFixed(1) + '%';
   var nodeUptimeMs = Date.now() - self.bootTime;
   var nodeUptime = (nodeUptimeMs / 3600000).toFixed(2) + 'h';
   var osUptime = (os.uptime() / 3600).toFixed(2) + 'h';
   var format = clauses.join(', ');
   console.log(format, cpuLoad, memUse, memFree, nodeUptime, osUptime);
 });
Ejemplo n.º 2
0
	app.get('/api/info/os', auth.dev, function (req, res) {
		res.json({

			type: os.type(),
			platform: os.platform(),
			arch: os.arch(),
			release: os.release(),
			uptime: os.uptime(),
			loadavg: os.loadavg(),
			totalmem: os.totalmem(),
			freemem: os.freemem(),
			cpus: os.cpus()
		});
	});
Ejemplo n.º 3
0
module.exports.getSystemInfo = function (callback) {
  var sysInfo = {
    arch: os.arch(),
    cpus: os.cpus(),
    freemem: os.freemem(),
    loadavg: os.loadavg(),
    platform: os.platform(),
    release: os.release(),
    totalmem: os.totalmem(),
    type: os.type(),
    uptime: os.uptime()
  }
  callback(sysInfo)
}
Ejemplo n.º 4
0
client.on('message', function(user, userID, channelID, message, rawEvent) {
	if (message === '!info.y') {
		var start = process.hrtime();
    var load = os.loadavg()
    var mem = os.freemem()
    var plat = os.platform()
    var totmem = os.totalmem()
    var sysup = os.uptime()
    var memfix = bytes(mem);

    var totmemfix = bytes(totmem);
    var child = require('child_process');
    child.exec('expr ' + '"' + "scale=0; " + sysup + "*1000" + '"' + ' | bc -l', function(error, stdout, stderr) {
    setTimeout(function() {
    var calcul = stdout.replace(/\\/g, '');
    var sysupfix = prettyMs(parseInt(calcul));
    var currentTime = Date.now();
	  var uptime = currentTime - startTime;
	  var upfinal = prettyMs(parseInt(uptime));
		var end = process.hrtime(start);
		var timee = prettyHrtime(end);
    client.sendMessage({
       to: channelID,
       message: '------------------' +
                '\n' + '## Uptime ## :' +
                '\n' + '------------------' +
                '\n' + '`> ' + upfinal + '`' +
                '\n' + '-------------------------' +
                '\n' + '## Load average ## :' +
                '\n' + '-------------------------' +
                '\n' + '`> ' + load + '`' +
                '\n' + '------------------------------' +
                '\n' + '## Total memory use ## :' +
                '\n' + '------------------------------' +
                '\n' + '`> ' + memfix + " / " + totmemfix + '`' +
                '\n' + "------------------" +
                '\n' + '## Platform ## :' +
                '\n' + '-------------------' +
                '\n' + '`> ' + plat + '`' +
                '\n' + '--------------------------' +
                '\n' + '## Uptime server ## :' +
                '\n' + '--------------------------' +
                '\n' + '`> ' + sysupfix + '`' +
								'\n' + '---------------------' +
								'\n' + '`>  Elapsed time : ' + timee + '`'
    });
    }, 200);
    });
  };
});
Ejemplo n.º 5
0
      fs.readFile('/proc/uptime', 'utf8', function (err, uptime) {
        if (err) {
          return done(err, null)
        }

        if (uptime === undefined) {
          console.error("[pidusage] We couldn't find uptime from /proc/uptime")
          self.cpu.uptime = os.uptime()
        } else {
          self.cpu.uptime = uptime.split(' ')[0]
        }

        return self.proc_calc(pid, options, done)
      })
Ejemplo n.º 6
0
 })(function () {
     var os = require("os");
     var details = {
         workerId: _workerId,
         environment: __appEnv,
         processName: process.title,
         versions: process.versions,
         architecture: process.arch,
         platform: process.platform,
         environmentVariables: process.env,
         pid: process.pid,
         features: process.features,
         debugPort: process.debugPort,
         listeningPort: _app.get('port'),
         nodeFilePath: process.execPath,
         processConfig: process.config,
         hostname: os.hostname(),
         uptime: os.uptime(),
         ram: {
             free: os.freemem(),
             total: os.totalmem()
         },
         cpus: os.cpus(),
         osType: {
             name: os.type(),
             release: os.release(),
             arch: os.arch()
         },
         networkInterfaces: os.networkInterfaces(),
         tempDir: os.tmpDir(),
         updated: new Date().getTime()
     };
     details = JSON.parse(JSON.stringify(details)); //sanitize
     ClusterWorker.update({workerId: _workerId}, {$set: details}, {upsert: true}, function (err) {
         if (err) log.error(err);
     });
     try {
         ClusterWorker.find({updated: {$lt: (new Date().getTime() - (1000 * 40))}}, function (err, objList) {
             objList.forEach(function (obj) {
                 ClusterWorker.remove({_id: obj._id}, function (err) {
                     if (err) log.error(err);
                     else globalEvent.emit("OnClusterWorkerFoundInactive", obj);
                 });
             });
         });
     } catch (c) {
         log.error(c);
     }
 }), 1000 * 30);
Ejemplo n.º 7
0
xmpp.on('chat', function(from, message) {
    if (message.indexOf('reload') !== -1) {
        xmpp.send(from, pretext + 'Exiting on ' + os.hostname());
        process.exit();
    }

    if (message.indexOf('hello') !== -1) {
        xmpp.send(from, pretext + 'Hello from ' + os.hostname());
    }
    if (message.indexOf('version') !== -1) {
        xmpp.send(from, pretext  + 'WatcherBot ' + version);
    }

    if (message.indexOf('uptime') !== -1) {
        var loadavg = os.loadavg(),
         uptime = os.uptime(),
         upstring = '';
        var years = moment.duration(uptime,'seconds').years(),
         months = moment.duration(uptime,'seconds').months(),
         days = moment.duration(uptime,'seconds').days(),
         hours = moment.duration(uptime,'seconds').hours(),
         minutes = moment.duration(uptime,'seconds').minutes();
        if (years !== 0) upstring += years + ' years ';
        if (months !== 0) upstring += months + ' months ';
        if (days !== 0) upstring += days + ' days ';
        if (hours !== 0) upstring += hours + ' hours ';
        if (minutes !== 0) upstring += minutes + ' minutes ';
        xmpp.send(from, pretext + hostname + " " + upstring +
            '\n' + pretext + "loadavg: " + loadavg[0].toFixed(2) + " " + loadavg[1].toFixed(2) + " " + loadavg[2].toFixed(2) +
            '\n' + pretext + "mem: " + humanize.filesize(os.totalmem()) + "/" + humanize.filesize(os.freemem())
        );
    }

    if (message.indexOf('status') !== -1) {
        exec(config.statscmd + ' | grep -e "Services Ok" -e "Hosts Up" | sed "s/       / /g"', function(error, stdout, stderr) {
            var array1 = stdout.split("\n");
            for ( i = 0; i < array1.length; i++) {
                array1[i] = pretext + array1[i];
            }
            stdout = array1.join("\n");
            xmpp.send(from, stdout + config.baseurl + "/icinga/");
        });
    }

    if (message.indexOf('url') !== -1) {
        xmpp.send(from, pretext + config.baseurl);
    }

});
Ejemplo n.º 8
0
(function() {
	const os = require('os');

	console.log('arch: ' + os.arch());
	console.log('free: ' + os.freemem());
	console.log('total: ' + os.totalmem());
	console.log( 'platform: ' + os.platform() );
	console.log( 'release: ' + os.release() );
	console.log( 'os type: ' + os.type() );
	console.log( 'uptime: ' + os.uptime() );

	console.log('os.cpus()');
	//dump(os.cpus());
	console.log(os.cpus());
})();
Ejemplo n.º 9
0
 God.getMonitorData(env, function(err, processes) {
   cb(err, {
     system: {
       hostname: os.hostname(),
       uptime: os.uptime(),
       cpus: os.cpus(),
       load: os.loadavg(),
       memory: {
         free: os.freemem(),
         total: os.totalmem()
       }
     },
     processes: processes
   });
 });
Ejemplo n.º 10
0
SystemInfo.prototype.getGeneral = function() {
  return {
    "hostname": os.hostname(),
    "type": os.type(),
    "platform": os.platform(),
    "arch": os.arch(),
    "release": os.release(),
    "uptime": os.uptime(),
    //"loadavg": os.loadavg(),
    //"totalmem": os.totalmem(),
    //"freemem": os.freemem(),
    //"cpus": os.cpus(),
    //"netwok": os.networkInterfaces(),
  };
};
Ejemplo n.º 11
0
exports.status = function () {
  return {
    sourceVersion: SOURCE_VERSION,
    configVersion: CONFIG_VERSION,
    apiKeysVersion: API_KEYS_VERSION,
    host: os.hostname(),
    uptime: Math.floor((Date.now() - TIME_STARTED) / 1000),
    os: {
      uptime: os.uptime(),
      loadavg: os.loadavg(),
      totalmem: os.totalmem(),
      freemem: os.freemem()
    }
  };
};
Ejemplo n.º 12
0
function sendStartInfo(from)
{
	if(wxmpp.checkConnected())
	{
		var t = wxmpp.getConnection();
		var tag = new xmpp.Element('info', {board:boardType, uptime:os.uptime(), loadavg1:os.loadavg()[0],
			loadavg5:os.loadavg()[1], loadavg15:os.loadavg()[2], totalmem:os.totalmem(), freemem:os.freemem()});
		var cpus = os.cpus();	
		for(var i=0; i<cpus.length; i++)
		{
			tag.c('cpu', {model:cpus[i].model, speed:cpus[i].speed});
		}
		t.sendWyliodrin(from, tag);
	}
}
Ejemplo n.º 13
0
  norris.get(function(facts) {
    var info = {
      'agent_version': version.toString(),
      'node_version': process.version,
      'api_version': http.CURRENT_API_VERSION,
      'hostname': facts.hostname,
      'architecture': facts.arch,
      'os': os.release(),
      'memory': os.totalmem(),
      'os_uptime': os.uptime(),
      'agent_uptime': uptime
    };

    httputil.returnJson(res, 200, info);
  });
Ejemplo n.º 14
0
stream.get('/state', function(req, res) {
  var ret = {
    version: version,
    total: total,
    uptime: parseInt((Date.now() - tstarted) / 1000),
    host: require("os").hostname(),
    os: {
      uptime: os.uptime(),
      loadavg: os.loadavg(),
      totalmem: os.totalmem(),
      freemem: os.freemem()
    }
  };

  res.json(ret);
});
Ejemplo n.º 15
0
function UptimeExtras(opts) {
  if (!(this instanceof UptimeExtras)) return new UptimeExtras(opts);

  opts = opts || {};

  if (!opts.date || !opts.uptime) {
    this.uptime = os.uptime();
    this._upDate = toSeconds(Date.now()) - this.uptime;
  } else {
    this.uptime = opts.uptime;
    this._upDate = toSeconds(opts.date) - this.uptime;
  }

  this.upDate = new Date(toMilliseconds(this._upDate));
  return this;
}
Ejemplo n.º 16
0
    fs.readFile("/etc/hostname", "utf8", (err, data) => {
        let val  = "";
        val += "Hostname: " + data +"\n";
        val += "Platform: " + os.platform()+"\n";
        val += "Arch: " + os.arch() + "\n";
        val += "CPU count: " + os.cpus().length+ "\n";

        val += "Uptime: " + os.uptime()+ "\n";

        if (content && content.length && content.indexOf("verbose") > -1) {
            val += util.inspect(os.cpus()) + "\n";
            val += util.inspect(os.networkInterfaces())+ "\n";
        }

        callback(null, val);
    });
Ejemplo n.º 17
0
worker.addFunction("statOS", function(job) {
  var retval = {
    name: os.type(),
    platform: os.platform(),
    arch: os.arch(),
    release: os.release(),
    uptime: os.uptime(),
    load: os.loadavg(),
    totalMemory: os.totalmem(),
    freeMemory: os.freemem(),
    cpus: os.cpus(),
    networkInterfaces: os.networkInterfaces(),

  }
  job.workComplete(JSON.stringify({result: retval}));
});
Ejemplo n.º 18
0
 server.get('/healthcheck', function(req, res, next) {
     res.send({
         alive:true,
         hostname:os.hostname(),
         type:os.type(),
         platform:os.platform(),
         arch:os.arch(),
         release:os.release(),
         uptime:os.uptime(),
         load:os.loadavg(),
         totalMemory:os.totalmem(),
         freeMemory:os.freemem(),
         cpus:os.cpus()
     });
     return next();
 });
Ejemplo n.º 19
0
getMashineInfo = function () {
    return {
        hostname:os.hostname(),
        osType:os.type(),
        osPlatform:os.platform(),
        osArch:os.arch(),
        osVer:os.release(),
        uptime:os.uptime(),
        load:os.loadavg(),
        totalmem:os.totalmem(),
        freemem:os.freemem(),
        cpus:os.cpus(),
        nics:os.networkInterfaces(),
        lastTimeStamp: new Date().getTime()
    };
};
Ejemplo n.º 20
0
Agent.prototype.getSystemInfo = function (callback) {
    var system = {};
    system.platform = os.platform();
    system.hostname = os.hostname();
    // cpu architecture
    system.arch = os.arch();
    system.release = os.release();
    // uptime in seconds
    system.uptime = os.uptime();
    
    system.totalmem = os.totalmem() / 1048576; // convert to MB
    system.freemem = os.freemem() / 1048576; // convert to MB
    // os.cpus() // probably overkill to no the specifics of the cpus
	system.device = config.device || system.hostname;
    callback(null, system);
}
    return new Promise((resolve, reject) => {
      let c1 = 15 + (new Date()).getSeconds() / 60 * 15;
      let c2 = 15 + (new Date()).getSeconds() / 60 * 15;
      let fakeData = {
        simulated : true,
        DHT22 : {
          temperature_C : c1,
          temperature_F : c1 * 9 / 5 + 32,
          humidity : 39.7666
        },
        BME280 : {
          temperature_C : c2,
          temperature_F : c2 * 9 / 5 + 32,
          humidity : 39.7666,
          pressure_hPa : 1014.3578,
          pressure_inHg : 29.9539,
          altitude_m :  9.2139,
          altitude_ft : 30.2295
        },
        TSL2561 : {
          lux : 3000 + 250 * Math.random(),
          timestamp : '2016-10-09T23:41:15.107Z'
        },
        GPS : {
          lat : 37.444795 + Math.random() * 0.000001,
          lon : -122.165146 + Math.random() * 0.000001,
          altitude : 9.144 + Math.random() * 0.03,
          altitudeUnits : 'M',
          satelliteCount : 8,
          PDOP : 1.94,
          HDOP : 0.98,
          VDOP : 1.68,
          fix : '3D Fix',
          timestamp : new Date(),
          speedKnots : 0.01,
          heading : 227.16
        },
        app : {
          platformUptime : os.uptime(),
          processUptime  : process.uptime(),
          engine         : `Node.js ${process.version}`

        }
      };

      resolve(fakeData);
    });
Ejemplo n.º 22
0
		get: function (key, exclude) {
			var memory = process.memoryUsage(),
				addresses = getAddresses(),
				ipAddress = addresses[0] || undefined,
				obj,
				result;
				obj = {
					process: {
						node: process.version,
						memory: memory.rss,
						'heap total': memory.heapTotal,
						'heap used': memory.heapUsed,
						pid: process.pid,
						uptime: process.uptime().toFixed(2)
					},
					os: {
						hostname: os.hostname(),
						arch: os.arch(),
						platform: os.platform(),
						type: os.type(),
						cpus: os.cpus(),
						'total memory': os.totalmem(),
						'free memory': os.freemem(),
						uptime: os.uptime().toFixed(2),
                        'used memory' : os.totalmem() - os.freemem(),
						network: os.networkInterfaces()
					},
					server: {
						ip: ipAddress,
						addresses: addresses,
						host: self.options.host,
						port: self.options.port,
						'stukko path': self.rootdir,
						'app path': self.cwd,
						packets: []
					}
				};

			if(!key){
				result = _.clone(obj);
				if(exclude)
					result = excludeKeys(result, exclude);
				return result;
			} else {
				return obj[key];
			}
		},
Ejemplo n.º 23
0
 app.get('/api/stats', function(req, res) {
   res.send({
     "stats": {
       type: os.type(),
       arch: os.arch(),
       platform: os.platform(),
       release: os.release(),
       uptime: moment.duration(os.uptime(), 'seconds').humanize(),
       loadavg: os.loadavg().map(function(load){return load.toFixed(2)}),
       loadpercent: (os.loadavg()[0]*100/os.cpus().length).toFixed(2),
       totalmem: os.totalmem(),
       freemem: os.freemem(),
       mempercent: (((os.totalmem()-os.freemem())/os.totalmem())*100).toFixed(2),
       cpus: os.cpus()
     }
   })
 })
Ejemplo n.º 24
0
stream.get('/state', function(req, res) {
  var ret = {
    version: version,
    total: total,
    uptime: parseInt((Date.now() - tstarted) / 1000, 10),
    host: require("os").hostname(),
    os: {
      uptime: os.uptime(),
      loadavg: os.loadavg(),
      totalmem: os.totalmem(),
      freemem: os.freemem()
    },
    subscriptions: subscriptions // TODO: should not be public
  };

  res.json(ret);
});
Ejemplo n.º 25
0
 function(err, results) {
     var stats = {
         kernel: os.release(),
         uptime: os.uptime(),
         loadavg: os.loadavg(),
         memory: {
             free: os.freemem(),
             total: os.totalmem(),
             used: os.totalmem() - os.freemem()
         },
         disk: results[0],
         net: results[1],
     };
     if (err) return fn(err);
     
     return fn(null, stats);
 });
Ejemplo n.º 26
0
Archivo: hal.js Proyecto: nobbyknox/hal
app.get('/sysInfo', function(request, response) {

    var os = require('os');

    var info = {
        hostName: os.hostname(),
        osType: os.type(),
        release: os.release(),
        cpu: os.cpus()[0].model,
        upTime: moment().subtract('seconds', os.uptime()).fromNow(),
        totMem: (os.totalmem() / 1024 / 1024) + ' MB',
        freeMem: (os.freemem() / 1024 / 1024) + ' MB'
    };

    response.send(info);
    response.end();
});
Ejemplo n.º 27
0
  async captureEvent(hapiEvent) {
    const heapStats = v8.getHeapStatistics();
    const port = this.config.get('server.port');
    const avgInMillis = get(hapiEvent, ['responseTimes', port, 'avg']); // sadly, it's possible for this to be NaN
    const maxInMillis = get(hapiEvent, ['responseTimes', port, 'max']);

    return {
      process: {
        memory: {
          heap: {
            // https://nodejs.org/docs/latest-v8.x/api/process.html#process_process_memoryusage
            total_in_bytes: get(hapiEvent, 'psmem.heapTotal'),
            used_in_bytes: get(hapiEvent, 'psmem.heapUsed'),
            size_limit: heapStats.heap_size_limit
          },
          resident_set_size_in_bytes: get(hapiEvent, 'psmem.rss'),
        },
        event_loop_delay: get(hapiEvent, 'psdelay'),
        pid: process.pid,
        uptime_in_millis: process.uptime() * 1000
      },
      os: {
        load: {
          '1m': get(hapiEvent, 'osload.0'),
          '5m': get(hapiEvent, 'osload.1'),
          '15m': get(hapiEvent, 'osload.2')
        },
        memory: {
          total_in_bytes: os.totalmem(),
          free_in_bytes: os.freemem(),
          used_in_bytes: get(hapiEvent, 'osmem.total') - get(hapiEvent, 'osmem.free')
        },
        uptime_in_millis: os.uptime() * 1000,
        ...(await getOSInfo())
      },
      response_times: {
        avg_in_millis: isNaN(avgInMillis) ? undefined : avgInMillis, // convert NaN to undefined
        max_in_millis: maxInMillis
      },
      requests: {
        ...requestDefaults,
        ...keysToSnakeCaseShallow(get(hapiEvent, ['requests', port]))
      },
      concurrent_connections: hapiEvent.concurrent_connections
    };
  }
Ejemplo n.º 28
0
setInterval(function() {
   	
   data = "vscout real-time system information from KACANTOUTSB\n";
   data += "systemtime: " + getDateTime() + "\n" ;
   data += "hostname: " + os.hostname() + "\n" ;
   data += "uptime: " + os.uptime() + "\n";
   data += "loadavg: " + os.loadavg() + "\n";
   data += "totalmem: " + os.totalmem() + "\n";
   data += "freemem: " + os.freemem() + "\n";
   data += "networkInterfaces: " + JSON.stringify(os.networkInterfaces()) + "\n";
   data += "\n";
   message = new Buffer(data);

   send(); 

   console.log('Sent ', sent, 'at ', getDateTime());
}, REPEAT);
Ejemplo n.º 29
0
Node.prototype.stats = function() {
    this.pid = process.getuid();
    this.version = process.version;
    this.memoryUsage = process.memoryUsage();
    this.uptime = process.uptime();
    this.os = {
        type: os.type(),
        platform: os.platform(),
        architecture: os.arch(),
        uptime: os.uptime(),
        loadAverage: os.loadavg(),
        totalMemory: os.totalmem(),
        freeMemory: os.freemem(),
        memUsage: os.freemem()/os.totalmem(),
        cpus: os.cpus(),
    }
};
Ejemplo n.º 30
0
	exports.os = function (req, res, next) {

		var obj = {};
		obj.tempDir = os.tmpdir();
		obj.hostname = os.hostname();
		obj.osname = os.type();
		obj.platform = os.platform();
		obj.osarch = os.arch();
		obj.osrelease = os.release();
		obj.uptime = os.uptime();
		obj.totalmem = os.totalmem();
		obj.freemem = os.freemem();
		obj.cpus = os.cpus();
		obj.networkInterfaces = os.networkInterfaces();

		res.status(200).json(obj);
	}