Skip to content

System monitor#

You can monitor the CPU, memory, disk, and network usage during the execution of experiments. The tracking is done transparently in a thread, adding the stats to the run field sysmon.

The monitor operates at the run level and also works in distributed environments.


The statistics are streamed if data streaming is enabled.

Example: Monitoring the system#

Monitoring the system

from mltraq import create_experiment, options
from mltraq.steps.sleep import sleep

# Activate the system monitor, specifying the frequency to sample the stats
with options().ctx({"sysmon.disable": False, "sysmon.interval": 0.1}):

    # Create a new experiment
    experiment = create_experiment()

    # Wait enough time to track a few timestamps, and report the first row
idx                                       0
timestamp        2024-07-03 10:20:58.063755
cpu_pct                                 2.5
disk_free_gb                          13.34
disk_total_gb                        494.38
disk_used_pct                          97.3
mem_free_gb                            6.81
mem_total_gb                          25.77
mem_used_pct                           73.6
net_recv_kbs                            0.0
net_sent_kbs                            0.0
Name: 0, dtype: object