Package: de.p1st.monitor
de-p1st-monitorResearchSee./research.HDD temp:Modern hard drives will throttle their read and write speeds
when the drive reaches a critical pre-set temperature
(usually around 60°C)20-50°C (short-term)20-40°C (long-term usage)SSD temp:Most SSDs implement thermal throttling as a safety feature
if a drive gets too hot. As the driver approaches the 70ºC limit
that most manufacturers set, the more likely it is that the
drive will start to slow itself down to prevent failure.30-50°CKeep it simple!Lines of code including docstrings and comments:find./src-name'*.py'|xargswc-l#=> 1938 totalConfigurationThe configuration is selected in the following order:Given as CLI argumentLocated at/etc/de-p1st-monitor/${hostname}.iniSeeexample.inifor a configuration file covering all config options.More examples can be found athttps://codeberg.org/privacy1st/nix-git/src/branch/main/assets/de-p1st-monitor.InstallationThe package is available onPyPI.There are two system dependencies which are required for some config options:smartmontoolsanddigitemp.Furthermore, the kernel moduledrivetempis required:sudo modprobe drivetempInstallation with cron entryInstall dependencies on Ubuntu:sudoapt-getinstallpython3-pip# Ubuntu 18.04 and belowsudoapt-getinstallpython3-setuptools
sudoapt-getinstallpython3-wheel

sudoapt-getinstallpython3-psutil# Ubuntu 18.04 and below: psutil < 5.6.2sudoapt-getinstallpython3-dev
sudoapt-getinstallbuild-essential# Ubuntu 20.04 and below: psutil < 5.6.2sudopython3-mpipinstallpsutil--upgradeInstall:Arch Linux:make install-pkgbuildpip:make install-pipUsageCommand line interfaceusage: de-p1st-monitor [-h] [--config CONFIG] [--export]

Iterates over all config sections. For each section the current sensor data is
read and logged to a .csv file.

options:
  -h, --help            show this help message and exit
  --config CONFIG, -c CONFIG
                        Path to .ini configuration file.
  --export, -e          If `True`, export .csv files and print their paths to
                        stdout. No sensor data is logged during this.Periodic loggingAdd a cron entry executing this e.g. every 3 Minutes:de-p1st-monitorExample log filessshmyServer'tail -n 1 /var/log/de-p1st-monitor/*'==> /var/log/de-p1st-monitor/cpu_15min.csv <==
20230712T101202,0.1351318359375

==> /var/log/de-p1st-monitor/cpu_1min.csv <==
20230712T101201,0.2215576171875

==> /var/log/de-p1st-monitor/cpu_5min.csv <==
20230712T101201,0.155517578125

==> /var/log/de-p1st-monitor/drive_20d86155-30d4-404c-95e8-c701cfb16ca5.csv <==
20230712T101202,27

==> /var/log/de-p1st-monitor/drive_4651c3f1-e4b8-45aa-a823-df762530a307.csv <==
20230712T101202,27

==> /var/log/de-p1st-monitor/drive_68c349e8-5118-4773-9fd5-5dbad9acee4e.csv <==
20230712T101202,30

==> /var/log/de-p1st-monitor/drive_b8ef1da9-d76d-44b4-86d4-71c82c888b6f.csv <==
20230712T101202,42

==> /var/log/de-p1st-monitor/filesystem_3CBA-B4EA.csv <==
20230712T101201,0.22699999999999998

==> /var/log/de-p1st-monitor/filesystem_a454430b-dee3-4b6b-8325-f7bdb9435ed1.csv <==
20230712T101201,nan

==> /var/log/de-p1st-monitor/filesystem_b8ef1da9-d76d-44b4-86d4-71c82c888b6f.csv <==
20230712T101201,0.28300000000000003

==> /var/log/de-p1st-monitor/filesystem_c385a436-0288-486f-a2b9-c64c2db667e7.csv <==
20230712T101201,0.397

==> /var/log/de-p1st-monitor/memory.csv <==
20230712T101201,3331,7434,7966

==> /var/log/de-p1st-monitor/net_enp0s31f6.csv <==
20230712T101202,34945986870,32771833466,20230706T100247

==> /var/log/de-p1st-monitor/net_enp0s31f6.csv.exported.csv <==
20230619T203731,68129.75690607735,67623.71270718232

==> /var/log/de-p1st-monitor/sensor_script_room-temp.csv <==
20230712T101202,26.19

==> /var/log/de-p1st-monitor/swap.csv <==
20230712T101201,2375,32767

==> /var/log/de-p1st-monitor/temp_coretemp_Core 0.csv <==
20230712T101202,33.0

==> /var/log/de-p1st-monitor/temp_coretemp_Core 1.csv <==
20230712T101202,39.0

==> /var/log/de-p1st-monitor/temp_coretemp_Package id 0.csv <==
20230712T101202,39.0PlotsCreating plots with graph-cliExport and fetch datassh_target=rootNasdst=~/de-p1st-monitor-"${ssh_target}"files="${dst}".files# Export .csv files on SSH target and save list of exported files to $files.ssh"${ssh_target}"'de-p1st-monitor --export'>"${files}"rm-rf"${dst}"mkdir-p"${dst}"rsync--checksum--archive--progress--human-readable--delete\--files-from="${files}""${ssh_target}":/"${dst}"mv"${dst}"/var/log/de-p1st-monitor/*"${dst}"rm-r"${dst}"/var"${files}"cd"${dst}"Install (Python)graph-cli# With a Python venv:#python -m venv ~/de-p1st-monitor.venv#source ~/de-p1st-monitor.venv/bin/activate#pip install graph-cli# With nix:nix-shell-pgraph-cliCreate plotsCreate one plot for each .csv file with different resampling methods (https://pandas.pydata.org/pandas-docs/stable/reference/resampling.html#computations-descriptive-stats):functionplot(){forfilein"${@}";dograph"${file}"-x1--resample"${sample_duration}"--resample-action"${action}"--figsize1600x1000-o"${file}".resample-"${sample_duration}-${action}".png||{echo"Error while processing${file}"}done}# MEANsample_duration=24Haction=mean
plot{swap,memory}.csv{temp_,cpu_,sensor_script_}*.csv# MAXsample_duration=24Haction=max
plot{swap,memory}.csv{temp_,drive_,drive-temp_,net_,cpu_,filesystem_,sensor_script_}*.csv# SUMsample_duration=24Haction=sum
plotnet_*.csvCreate more plots as you likeSome self-explaining examples:# x and y axis by column namegraphcpu_1min.csv-x'datetime#Date'-y'float#LoadAverage1min'--resample1H-ocpu_1min_resample-1H.png# x and y axis by column numbergraphcpu_1min.csv-x1-y2--resample1H-ocpu_1min_resample-1H.png# specify x axis; use all other axes for ygraphcpu_1min.csv-x1--resample1H-ocpu_1min_resample-1H.png# increased plot sizegraphcpu_1min.csv-x1--resample1H--figsize1600x1000-ocpu_1min_resample-1H.pngExample plots