network monitoring

This commit is contained in:
Alex Tau 2025-06-07 15:59:05 +03:00
parent 8af7b683b6
commit 8b18d407d7
21 changed files with 434 additions and 53 deletions

View file

@ -6,6 +6,7 @@
let
tempSensorOptions = (import ./suboptions/tempSensorOptions.nix) { inherit lib; };
vulnixWhitelistRule = (import ./suboptions/vulnixWhitelistRule.nix) { inherit lib; };
netInterfaceOptions = (import ./suboptions/netInterfaceOptions.nix) { inherit lib; };
in
{
options.services.lego-monitoring = {
@ -32,6 +33,7 @@ in
"cpu"
"ram"
"temp"
"net"
"vulnix"
]);
@ -96,12 +98,12 @@ in
cpu = {
warningPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.float;
type = lib.types.nullOr lib.types.numbers.positive;
default = 80.0;
description = "CPU load percentage for a warning alert to be sent. Null means never generate a CPU warning alert.";
};
criticalPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.float;
type = lib.types.nullOr lib.types.numbers.positive;
default = 90.0;
description = "CPU load percentage for a critical alert to be sent. Null means never generate a CPU critical alert.";
};
@ -109,16 +111,31 @@ in
ram = {
warningPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.float;
type = lib.types.nullOr lib.types.numbers.positive;
default = 80.0;
description = "RAM usage percentage for a warning alert to be sent. Null means never generate a RAM warning alert.";
};
criticalPercentage = lib.mkOption {
type = lib.types.nullOr lib.types.float;
type = lib.types.nullOr lib.types.numbers.positive;
default = 90.0;
description = "RAM usage percentage for a critical alert to be sent. Null means never generate a RAM critical alert.";
};
};
net = {
interfaces = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule netInterfaceOptions);
default = { };
description = "Per-interface configuration of IO byte thresholds.";
example = lib.literalExpression ''
{
br0 = {
warningThresholdCombBytes = 700 * 1024 * 128; # 700 Megabits
criticalThresholdCombBytes = 1 * 1024 * 1024 * 128; # 1 Gigabit
};
}'';
};
};
};
};
}