node-usage

a process usage monitor with nodejs

Usage no npm install needed!

<script type="module">
  import nodeUsage from 'https://cdn.skypack.dev/node-usage';
</script>

README

node-usage

a process usage monitor with nodejs

  • support MEM, RSS, VSZ, %MEM, %CPU
  • support process group usage monitor

usage

$ npm install node-usage

then just use it in your codes like this

  import UsageMonitor from 'node-usage';

  const memMonitor = new UsageMonitor({ interval: 500 });
  memMonitor.run(p.pid, (err, data) => {
    console.log(data);
  });

the default monitor will count child process memory, virtual memory size, and physical resident memory into result. you can disable it like this:

  memMonitor.run(p.pid, { countChild: false },  (err, data) => {
    console.log(data);
  });

LICENSE

MIT