简体   繁体   中英

How to Get Memory & CPU usage of Tomcat local server via NodeJS

I'm building a Nodejs App that will monitor the performance of a local tomcat server.The two server are running on the same machine. I want to know several info about my Java ee App and tomcat server like CPU & Memory usage(Generaly important resource) I have tried os-utils module but it return the ressource used by my node server.

const os = require('os-utils');   
os.cpuUsage(c => console.log( 'CPU Usage (%): ' + c ));

It is a method to use the os module for nodejs to return the resource of another server running on same machine ?

const os = require('os');
os.cpus()

There is no such functionality in Node.js, and os-utils refers to Node.js process itself.

There are third-party packages that can do that. pidusage is a wrapper around ps and wmic commands depending on the platform, it parses their output and is capable of providing stats on CPU and RAM process use based on its PID.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM