Learn how to measure system responsiveness and temperature using Python, set alert thresholds for notifications, and install monitoring software as a daemon on various devices.

The system sometimes feels lagging, less responsive. The only way to fix is to reboot.

Although monitor task completion time is helpful, but not general enough.

Simple hack:

1
2
3
4
5
6
7
8
9
10
11
import subprocess
def measure_system_responsiveness():
start_time = time.time()
subprocess.run(
["echo", "hello"], capture_output=True, encoding='utf-8', check=True
)
end_time = time.time()
exec_time = end_time - start_time
exec_per_second = 1 / exec_time
return exec_per_second

Lagging related package:

1
2
apt install nohang oomd psi-notify


Temperature monitoring packages:

1
2
3
4
pip3 install gpustat
pip3 install pyspectator
apt install lm-sensor # sensors -j

Create temperature statistics (high, low, mean) for all crucial components.

Set alert threshold, only trigger alert if temperature reoccurs for several times.

Send ntfy.sh notification as well as making audible alerts.

Notification shall specify device name, component name, current temperature, threshold, statistics.

Every device shall be equipped with this software as daemon, be it smartphone, MacBook, Linux PC, Windows PC.

Comments