What would be the best way to go about monitoring resource usage of certain running processes? For example if I wanted to generate log files of CPU and memory usage over time.
From what I understand there are various different options, like using top or ps commands, using sysInfo command in code or querying the files in /proc/ directory directly. Although pros and cons of certain approaches is apparent to me (for example ps displaying average CPU usage, while top is more instantaneous. Although this question points that there are some issues with top also), I am still new to Linux so I feel like it is easy to overlook something and cause disaster.
Also, is it better to just directly query /proc/ files instead of using top,ps or calling sysInfo, or is this approach not advised?
atopis good for that.