Very simple bash and gnuplot (>=5.0) script to monitor cpu and memory usage of given process in graph
Clone repo, mark monitor.sh as an executable running chmod +x monitor.sh
and run it by
./monitor.sh [OPTIONS]... -p PID | [OPTIONS]... -c COMMAND
-p PID
PID which will be monitored[-g]
The graph will be created[-l FILE]
Log file path[-d FILE]
Graph file path[-s NUMBER]
Time after the values will be added to log in seconds
-c COMMAND
Command name will be tracked in system instead of PID[-F NUMBER]
How long it will be waited for first occurrence of command in ps output.[-N NUMBER]
How long it will be waited for next instance to appear in ps output.
./monitor.sh -c firefox
will track different instances of Firefox browser in system one at a time (always the newest instance if previously watched was killed).
Logged raw values will be placed in usage.log files and graph will be placed in usage.png by default. Graph will not be created by default.