How to use the os.totalmem 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 Financial-Times / origami-build-service / lib / monitoring / healthmonitor.js View on Github external
addMemoryChecks: function(info) {
		const availableMemory = os.totalmem(); // In bytes
		const maxMemUsage = availableMemory * 0.75; // Start alerting when memory usage > 75% (In bytes)

		const checks = [
			[Object.assign({name:'Memory RSS'}, info), 'rss'],
			[Object.assign({name:'Memory heap total'}, info), 'heapTotal'],
			[Object.assign({name:'Memory heap used'}, info), 'heapUsed'],
		];
		return Q.all(checks.map(function(check){
			const info = check[0];
			const propName = check[1];

			const aggregate = new Average('bytes');
			return this.addCheck(info, function(){
				let value = process.memoryUsage()[propName];
				if (value > maxMemUsage) {
					// If the memory threshold has been reached for the used heap, force global gc before reporting (only available if exposed through --expose_gc)
github racker / node-rproxy / node_modules / cluster2 / lib / process.js View on Github external
Process.prototype.listen = function() {
    var self = this, apps, monApp, cb;

    if(arguments.length === 3) {
        apps = arguments[0];
        monApp = arguments[1];
        cb = arguments[2];
    }
    else if (arguments.length === 2) {
        apps = arguments[0];
        cb = arguments[1];
    }
    if(cluster.isMaster) {
        this.stats.pid = process.pid;
        this.stats.start = new Date();
        this.stats.totalmem = os.totalmem();
        this.stats.freemem = os.freemem();
        this.workers = [];

        // Monitor to serve log files and other stats - typically on an internal port
        var monitor = new Monitor({
            monitor: monApp,
            stats: self.stats,
            port: self.options.monPort,
            path: self.options.monPath
        });

        monitor.on('listening', function() {
            misc.ensureDir(process.cwd() + '/pids', true); // Ensure pids dir
            misc.ensureDir(process.cwd() + '/logs'); // Ensure logs dir

            fs.writeFileSync(self.options.pids + '/master.' + self.stats.pid + '.pid', self.stats.pid);
github microsoft / vscode / src / vs / platform / diagnostics / node / diagnosticsService.ts View on Github external
private formatEnvironment(info: IMainProcessInfo): string {
		const MB = 1024 * 1024;
		const GB = 1024 * MB;

		const output: string[] = [];
		output.push(`Version:          ${product.nameShort} ${product.version} (${product.commit || 'Commit unknown'}, ${product.date || 'Date unknown'})`);
		output.push(`OS Version:       ${osLib.type()} ${osLib.arch()} ${osLib.release()}`);
		const cpus = osLib.cpus();
		if (cpus && cpus.length > 0) {
			output.push(`CPUs:             ${cpus[0].model} (${cpus.length} x ${cpus[0].speed})`);
		}
		output.push(`Memory (System):  ${(osLib.totalmem() / GB).toFixed(2)}GB (${(osLib.freemem() / GB).toFixed(2)}GB free)`);
		if (!isWindows) {
			output.push(`Load (avg):       ${osLib.loadavg().map(l => Math.round(l)).join(', ')}`); // only provided on Linux/macOS
		}
		output.push(`VM:               ${Math.round((virtualMachineHint.value() * 100))}%`);
		output.push(`Screen Reader:    ${info.screenReader ? 'yes' : 'no'}`);
		output.push(`Process Argv:     ${info.mainArguments.join(' ')}`);
		output.push(`GPU Status:       ${this.expandGPUFeatures(info.gpuFeatureStatus)}`);

		return output.join('\n');
	}
github RocketChat / Rocket.Chat / packages / rocketchat-version / plugin / compile-version.js View on Github external
const processFile = function(file, cb) {
			if (!file.getDisplayPath().match(/rocketchat\.info$/)) {
				return cb();
			}

			let output = JSON.parse(file.getContentsAsString());
			output.build = {
				date: new Date().toISOString(),
				nodeVersion: process.version,
				arch: process.arch,
				platform: process.platform,
				osRelease: os.release(),
				totalMemory: os.totalmem(),
				freeMemory: os.freemem(),
				cpus: os.cpus().length,
			};

			if (process.env.TRAVIS_BUILD_NUMBER) {
				output.travis = {
					buildNumber: process.env.TRAVIS_BUILD_NUMBER,
					branch: process.env.TRAVIS_BRANCH,
					tag: process.env.TRAVIS_TAG,
				};
			}

			exec('git log --pretty=format:\'%H%n%ad%n%an%n%s\' -n 1', function(err, result) {
				if (err == null) {
					result = result.split('\n');
					output.commit = {
github pipedrive / kardia / lib / status.js View on Github external
throughput: this.throughputs,
			stacks: this.stacks,
			workers: workersData,
			remoteAddress: (req && req.socket && req.socket.remoteAddress ? req.socket.remoteAddress : false),
			network: os.networkInterfaces(),
			hostname: os.hostname(),
			memory: formatMemory(process.memoryUsage(), this.startMemory),
			fallBehind: this.fallBehind,
			os: {
				type: os.type(),
				platform: os.platform(),
				arch: os.arch(),
				release: os.release(),
				uptime: os.uptime(),
				loadavg: os.loadavg(),
				totalmem: os.totalmem(),
				freemem: os.freemem()
			},
			config: this.config
		};

		return resp;
	};
github nilppm / npm / src / controller / index.ts View on Github external
CPM_CACHE = await Total(ctx);
        CPM_TIME = Date.now();
      }
      CPM_CACHE.version = project.version;
      CPM_CACHE.description = project.description;
      CPM_CACHE.machine = {
        cpu: {
          arch: os.arch(),
          info: os.cpus()
        },
        freemem: os.freemem(),
        hostname: os.hostname(),
        networkInterfaces: os.networkInterfaces(),
        platform: os.platform(),
        release: os.release(),
        totalmem: os.totalmem(),
        type: os.type(),
        uptime: os.uptime(),
        loadavg: os.loadavg()
      }
      ctx.body = CPM_CACHE;
    }
github nodyn / nodyn / src / main / javascript / process.js View on Github external
Process.prototype.memoryUsage = function() {
  os = require('os');
  var obj = {};
  obj.heapTotal = os.totalmem();
  obj.heapUsed  = os.totalmem() - os.freemem();
  return obj;
};
github ioBroker / ioBroker.js-controller / main.js View on Github external
function _startMultihost(_config, secret) {
    const MHService = require('./lib/multihostServer.js');
    const cpus    = os.cpus();
    mhService = new MHService(hostname, logger, _config, {
        node:   process.version,
        arch:   os.arch(),
        model:  cpus && cpus[0] && cpus[0].model ? cpus[0].model : 'unknown',
        cpus:   cpus ? cpus.length : 1,
        mem:    os.totalmem(),
        ostype: os.type()
    }, getIPs(), secret);
}
github SAP / com.sap.openSAP.hana5.example / core_node / router / routes / os.js View on Github external
app.get("/osInfo", (req, res) => {
		var os = require("os");
		var output = {};

		output.tmpdir = os.tmpdir();
		output.endianness = os.endianness();
		output.hostname = os.hostname();
		output.type = os.type();
		output.platform = os.platform();
		output.arch = os.arch();
		output.release = os.release();
		output.uptime = os.uptime();
		output.loadavg = os.loadavg();
		output.totalmem = os.totalmem();
		output.freemem = os.freemem();
		output.cpus = os.cpus();
		output.networkInfraces = os.networkInterfaces();

		var result = JSON.stringify(output);
		res.type("application/json").status(200).send(result);
	});