de-p1st-monitor: add config files

This commit is contained in:
Daniel Langbein 2023-11-20 14:09:10 +01:00
parent 43569d816a
commit cdb6817c0b
Signed by: langfingaz
GPG Key ID: 6C47C753F0823002
5 changed files with 203 additions and 46 deletions

View File

@ -0,0 +1,60 @@
[logging]
dir = /var/log/de-p1st-monitor/
[filesystem.1]
mountpoint = /
warn_if_above = 0.75
[filesystem.2]
mountpoint = /boot
warn_if_above = 0.75
; TODO
[memory]
warn_if_above = 0.85
[swap]
warn_if_above = 0.85
[cpu1]
warn_if_above = 2.0
warn_threshold = 2
warn_data_range = 2
[cpu5]
warn_if_above = 1.5
warn_threshold = 2
warn_data_range = 2
[cpu15]
warn_if_above = 1.0
warn_threshold = 2
warn_data_range = 2
[temp.1]
sensor = coretemp
label = Core 0
warn_if_above = 60
[temp.2]
sensor = coretemp
label = Core 1
warn_if_above = 60
[temp.3]
sensor = coretemp
label = Core 2
warn_if_above = 60
[temp.4]
sensor = coretemp
label = Core 3
warn_if_above = 60
[network.1]
network_interface = enp3s0
[drive_temp.1]
; HDD drives (WDC WD60EFAX-68S and ST6000DM003-2CY1)
; TODO: 39 warn, 45 limit
type = drivetemp
warn_if_above = 40
; Note: The SSD (INTEL SSDSC2CW12) does not report its temperature.
; See
; $ sensors
; $ cat /proc/scsi/scsi
; $ sudo smartctl -A /dev/sda | grep Temperature_Celsius

View File

@ -0,0 +1,70 @@
[logging]
dir = /var/log/de-p1st-monitor/
[filesystem.1]
; 256GB2
mountpoint = /
warn_if_above = 0.75
[filesystem.2]
; 256GB2
mountpoint = /boot
warn_if_above = 0.75
[filesystem.3]
; 12TB1
uuid = c385a436-0288-486f-a2b9-c64c2db667e7
warn_if_above = 0.66
[filesystem.4]
; 3TB1, 3TB2 and 4TB1
uuid = 1f560eeb-a375-457b-84a6-93d771a5ba5f
warn_if_above = 0.85
unmounted_ok = true
[memory]
warn_if_above = 0.85
[swap]
warn_if_above = 0.85
[cpu1]
warn_if_above = 3.0
warn_threshold = 2
warn_data_range = 2
[cpu5]
warn_if_above = 2.0
warn_threshold = 2
warn_data_range = 2
[cpu15]
warn_if_above = 1.0
warn_threshold = 2
warn_data_range = 2
[temp.1]
sensor = coretemp
label = Package id 0
warn_if_above = 60
[temp.2]
sensor = coretemp
label = Core 0
warn_if_above = 60
[temp.3]
sensor = coretemp
label = Core 1
warn_if_above = 60
[network.1]
network_interface = enp0s31f6
[drive_temp.1]
; NVMe drives
; TODO: 49 warn, 55 limit
type = nvme
warn_if_above = 50
[drive_temp.2]
; HDD drives
; TODO: 39 warn, 45 limit
type = drivetemp
warn_if_above = 40
; [sensor_script.1]
; cmd = ["digitemp_DS9097", "-q", "-c", "/home/yoda/.digitemprc", "-t", "0"]
; name = room-temp
; warn_if_above = 32

View File

@ -1,10 +1,3 @@
{ config, pkgs, ... }:
let
backup-source = "rootNas";
# The "stay-awake" file is located at `${backup-source}:${stay-awake-file}`.
stay-awake-file = "${config.networking.hostName}.stay-awake";
in
{
# Suspend:
# sudo systemctl suspend
# Suspend for 60 seconds:
@ -18,6 +11,15 @@ in
# journalctl -u daily-backup-and-suspend
{ config, pkgs, ... }:
let
backup-source = "rootNas";
# The "stay-awake" file is located at `${backup-source}:${stay-awake-file}`.
stay-awake-file = "${config.networking.hostName}.stay-awake";
in
{
yoda.de-p1st-monitor = (builtins.readFile ../../assets/de-p1st-monitor/yodaHedgehog.ini);
assertions = [{
assertion = config.services.openssh.enable;
message = "systemd service daily-backup-and-suspend requires SSH.";

View File

@ -1,5 +1,7 @@
{ config, pkgs, ... }:
{
yoda.de-p1st-monitor = (builtins.readFile ../../assets/de-p1st-monitor/yodaNas.ini);
# Update and start Jinja-Compose project
# during boot and after every 30 minutes.
# To view the log, run

View File

@ -1,5 +1,8 @@
{ config, pkgs, ... }:
{ lib, config, options, pkgs, modulesPath, ... }:
with lib;
let
cfg = config.yoda.de-p1st-monitor;
my-python-packages = ps: with ps; [
# de-p1st-monitor is not (yet) packaged, thus we build it from PyPI
(
@ -24,6 +27,22 @@ let
];
in
{
options = {
yoda.de-p1st-monitor = mkOption {
type = types.str;
example = ''
[logging]
dir = /var/log/de-p1st-monitor/
[network.1]
network_interface = wlan0
'';
description = ''
Content of /etc/de-p1st-monitor/''${hostname}.ini
'';
};
};
config = {
# Install de.p1st.monitor packages.
environment.systemPackages = [
(pkgs.python3.withPackages my-python-packages)
@ -33,6 +52,9 @@ in
# Dependency of de.p1st.monitor
boot.kernelModules = [ "drivetemp" ];
# Create configuration file.
environment.etc."de-p1st-monitor/${config.networking.hostName}.ini".text = cfg;
# Create de.p1st.monitor timer.
systemd.timers."de.p1st.monitor" = {
wantedBy = [ "timers.target" ];
@ -61,4 +83,5 @@ in
smartmontools
];
};
};
}