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.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With