David Brown
David Brown

Reputation: 938

NodeJS: get information on a process from the process ID

I am writing a small NodeJS service that I want to be able to monitor a process given the PID of that process. I want to be able to gather the following info about the process:

All processes that I will be monitoring will have been started using the child_process exec (or spawn) function, so I can get the PID from there. Technically, I could record the start time when the process is spawned, but I think this wouldn't be all that accurate?

What would be the best way to get all the above information? It would be good to get and end time when the process exited as well.

Upvotes: 4

Views: 3596

Answers (1)

David R
David R

Reputation: 15639

pidusage is one great module which can get you all details (like process cpu % and memory usage of a PID) that you need pertaining to a pid upon supplying the same as an argument.

Another good thing is, this library can run on any platform.

Hope this helps!

Upvotes: 3

Related Questions