How to use the pidusage.unmonitor function in pidusage

To help you get started, we’ve selected a few pidusage 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 lgapontes / hey-joe / infrastructure / cpu.js View on Github external
pusage.stat(process.pid, function(err, stat) {
            if (err) {
                callback(err);
            } else {
                if (stat.cpu === undefined) {
                    callback('CPU status not found!');
                } else {
                    let cpuUsage = parseInt(stat.cpu)
                    let cpuFree = 100 - cpuUsage;

                    /* Unmonitor process */
                    pusage.unmonitor(process.pid);

                    callback(undefined,[
                        cpuUsage,
                        cpuFree
                    ]);
                }
            }
        });
    };
github lgapontes / hey-joe / infrastructure / memory.js View on Github external
pusage.stat(process.pid, function(err, stat) {
            if (err) {
                callback(err);
            } else {
                if (stat.memory === undefined) {
                    callback('Memory status not found!');
                } else {
                    let memoryUsed = round( (stat.memory / 1024) / 1024 );
                    let memoryTotal = round( (os.totalmem() / 1024) / 1024 );

                    /* Unmonitor process */
                    pusage.unmonitor(process.pid);

                    callback(undefined,[
                        [memoryUsed],
                        [memoryTotal]
                    ]);
                }
            }
        });
    };
github AidosKuneen / aidos-wallet / app / js / main.js View on Github external
if (settings.lightWallet == 1) {
      pid = rendererPid;
    } else if (server && server.pid) {
      pid = server.pid;
    }

    if (pid) {
      pusage.stat(pid, function (err, stat) {
        if (err) {
          App.updateStatusBar({ "cpu": "" });
        } else {
          App.updateStatusBar({ "cpu": Math.round(stat.cpu).toFixed(2) });
        }
      });

      pusage.unmonitor(pid);
    } else {
      console.log("Track CPU: No server PID");
      if (cpuTrackInterval) {
        console.log("Clear the interval");
        clearInterval(cpuTrackInterval);
      }
    }
  }
github hyperledger / caliper / packages / caliper-core / lib / master / monitor / monitor-process.js View on Github external
async stop() {
        clearInterval(this.intervalObj);
        this.containers = [];
        this.stats      = {'time': []};

        for(let key in this.pids) {
            usage.unmonitor(key);
        }
        this.pids = [];

        await Util.sleep(100);
    }
github hyperledger / caliper / src / comm / monitor / monitor-process.js View on Github external
restart() {
        clearInterval(this.intervalObj);
        for(let key in this.stats) {
            if(key === 'time') {
                this.stats[key] = [];
            }
            else {
                for(let v in this.stats[key]) {
                    this.stats[key][v] = [];
                }
            }
        }

        for(let key in this.pids) {
            usage.unmonitor(key);
        }
        this.pids = [];

        return this.start();
    }
github hyperledger / caliper / src / comm / monitor / monitor-process.js View on Github external
stop() {
        clearInterval(this.intervalObj);
        this.containers = [];
        this.stats      = {'time': []};

        for(let key in this.pids) {
            usage.unmonitor(key);
        }
        this.pids = [];

        return Util.sleep(100);
    }
github hyperledger / caliper / packages / caliper-core / lib / master / monitor / monitor-process.js View on Github external
async restart() {
        clearInterval(this.intervalObj);
        for (let key in this.stats) {
            if (key === 'time') {
                this.stats[key] = [];
            } else {
                for (let v in this.stats[key]) {
                    this.stats[key][v] = [];
                }
            }
        }

        for (let key in this.pids) {
            usage.unmonitor(key);
        }
        this.pids = [];

        await this.start();
    }
github hardog / tinymonit / lib / proc.js View on Github external
exports.clear = function(pids){
	pids = Array.prototype.slice.call(pids);
	let len = pids.length;

	for(let i = 0; i < len; i++){
		pusage.unmonitor(pids[i]);
	}
};

pidusage

Cross-platform process cpu % and memory usage of a PID

MIT
Latest version published 2 years ago

Package Health Score

80 / 100
Full package analysis