In this repo, we have an example of following:
- How to use monitor.py (see shell_code.py)
psutil
This piece of code does the following:
- it takes as a command line argument the PID of a process that it needs to monitor
- as long as the process with the given pid (lets say this is Process P) is alive, this process will keep monitoring
- in addition to monitoring P, our monitor will also track the processes that are owned by a user, and those spawned after P
- when P finishes, our monitor exits by reporting CPU time and peak memory usage
- the interval used by our monitor is 0.1 seconds
If we need to change the interval or the username, we need to do so in hard code.