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.
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
print(
experiment.execute(sleep(0.3))
.runs.first()
.fields.sysmon.df()
.iloc[0]
)
|
Outputidx 0
timestamp 2024-10-11 12:10:08.902507
cpu_cnt 8.0
cpu_pct 8.3
disk_free_gb 178.11
disk_total_gb 494.38
disk_used_pct 63.97
mem_free_gb 5.28
mem_total_gb 25.77
mem_used_pct 79.5
net_recv_kbs 10.24
net_sent_kbs 10.24
Name: 0, dtype: object