Procpath can be used to record Procfs metrics of an application (process trees) including CPU usage and Resident Set Size (RSS). Full disclosure: I wrote it.
Let's take Firefox as an example. On my machine its process tree looks like this:
/usr/lib/firefox/firefox
├─ /usr/lib/firefox/firefox -contentproc -childID 4 ...
├─ /usr/lib/firefox/firefox -contentproc -childID 3 ...
├─ /usr/lib/firefox/firefox -contentproc -childID 2 ...
├─ /usr/lib/firefox/firefox -contentproc -childID 1 ...
├─ /usr/lib/firefox/firefox -contentproc -parentBuildID ...
├─ /usr/lib/firefox/firefox -contentproc -parentBuildID ...
└─ /usr/lib/firefox/firefox -contentproc -childID 8 ...
Wit Procpath you can collect process metrics from this tree like the following (and see the documentation if want to ask your allication's process supervisor, say systemd or Docker, for the root PID):
procpath record -d firefox.sqlite '$..children[?(@.stat.comm == "firefox")]'
With this command Procpath will collect and record this tree's Procfs metrics once per 10 seconds. You can leave it running in a terminal multiplexor (like Byobu) to run it in the background on your server.
When your application crashes again, you can use this command to visualise CPU usage and resident set size of the application.
procpath plot -d firefox.sqlite -f firefox.svg -q cpu -q rss --formatter=integer
ps
may differ fromtop
: stackoverflow.com/questions/131303/…