A very simple python script which monitors and records the CPU and RAM consumption of submitted cluster jobs.


To start recording use the script. This script requires 3 arguments:

  • -u which corresponds to your username.
  • -o which specifies the output file (in tsv format)
  • --interval which specifies the time (in seconds) over which the CPU and RAM usage gets averaged


python -u nickhir -o cpu_ram.log --interval 5

The script can simply be included in your cluster job submittion like this:

#SBATCH --job-name=Example_run

sambamba sort -t 20 some_bam.bam &
python -u nickhir -o cpu_ram.log --interval 5 &
wait $MainScript
pkill -P $$

Afterwards the resulting log file can be plotted (for that matplotlib is needed).
For that use the script which needs 2 arguments:

  • -i which specifies the path to the log file which was created with
  • -o which specifies the path to the resulting PDF which contains a plot for the CPU and RAM usage.


python -i cpu_ram.log -o cpu_ram_visualization.pdf

The resulting plots will look somewhat like this: