This repository has been archived on 2024-07-08. You can view files and clone it, but cannot push or open issues or pull requests.
nix-config-tn/nixos/modules/nixos/services/glances/default.nix
Joe Hanson 6a278729f8
reduce, reuse, refine (#3)
* reduce, reuse, refine

* more refining and replacing

* More refining

* Removing unused code such as homepage and traefik

* Remove homepage references.
2024-05-19 06:39:08 -05:00

83 lines
1.7 KiB
Nix

{ pkgs
, config
, lib
, ...
}:
let
cfg = config.mySystem.services.glances;
app = "Glances";
in
with lib;
{
options.mySystem.services.glances =
{
enable = mkEnableOption "Glances system monitor";
monitor = mkOption
{
type = lib.types.bool;
description = "Enable gatus monitoring";
default = true;
};
addToHomepage = mkOption
{
type = lib.types.bool;
description = "Add to homepage";
default = true;
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs;
[ glances python310Packages.psutil hddtemp ];
# port 61208
systemd.services.glances = {
script = ''
${pkgs.glances}/bin/glances --enable-plugin smart --webserver --bind 0.0.0.0
'';
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
};
networking = {
firewall.allowedTCPPorts = [ 61208 ];
};
environment.etc."glances/glances.conf" = {
text = ''
[global]
check_update=False
[network]
hide=lo,docker.*
[diskio]
hide=loop.*
[containers]
disable=False
podman_sock=unix:///var/run/podman/podman.sock
[connections]
disable=True
[irq]
disable=True
'';
};
mySystem.services.gatus.monitors = mkIf cfg.monitor [{
name = "${app} ${config.networking.hostName}";
group = "${app}";
url = "http://${config.networking.hostName}.${config.mySystem.internalDomain}:61208:/api/3/status";
interval = "1m";
conditions = [ "[CONNECTED] == true" "[STATUS] == 200" "[RESPONSE_TIME] < 50" ];
}];
};
}