enable ups monitoring
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
hosts/nas/*.conf
|
||||||
|
hosts/nas/*.users
|
||||||
@@ -8,7 +8,7 @@ let
|
|||||||
password =
|
password =
|
||||||
"$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06";
|
"$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06";
|
||||||
hostname = "jallen-nas";
|
hostname = "jallen-nas";
|
||||||
allowedPorts = [ 2342 61208 ];
|
allowedPorts = [ 2342 3493 61208 ];
|
||||||
enableDisplayManager = false;
|
enableDisplayManager = false;
|
||||||
in {
|
in {
|
||||||
imports = [ # Include the results of the hardware scan.
|
imports = [ # Include the results of the hardware scan.
|
||||||
@@ -72,58 +72,6 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.grafana = {
|
|
||||||
enable = true;
|
|
||||||
settings.server = {
|
|
||||||
http_port = 2342;
|
|
||||||
domain = hostname;
|
|
||||||
serve_from_sub_path = true;
|
|
||||||
http_addr = "";
|
|
||||||
};
|
|
||||||
dataDir = "/mnt/ssd/nix-app-data/grafana";
|
|
||||||
};
|
|
||||||
|
|
||||||
services.prometheus = {
|
|
||||||
enable = true;
|
|
||||||
port = 9001;
|
|
||||||
exporters = {
|
|
||||||
node = {
|
|
||||||
enable = true;
|
|
||||||
enabledCollectors = [ "diskstats" "systemd" ];
|
|
||||||
port = 9002;
|
|
||||||
};
|
|
||||||
smartctl = {
|
|
||||||
enable = true;
|
|
||||||
group = "disk";
|
|
||||||
devices = [
|
|
||||||
"/dev/sda"
|
|
||||||
"/dev/sdb"
|
|
||||||
"/dev/sdc"
|
|
||||||
"/dev/sdd"
|
|
||||||
"/dev/sde"
|
|
||||||
"/dev/sdf"
|
|
||||||
"/dev/sdg"
|
|
||||||
"/dev/sdh"
|
|
||||||
"/dev/sdi"
|
|
||||||
"/dev/nvme0n1"
|
|
||||||
"/dev/nvme1n1"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
scrapeConfigs = [{
|
|
||||||
job_name = hostname;
|
|
||||||
static_configs = [{
|
|
||||||
targets = [
|
|
||||||
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
|
|
||||||
"127.0.0.1:${
|
|
||||||
toString config.services.prometheus.exporters.smartctl.port
|
|
||||||
}"
|
|
||||||
];
|
|
||||||
}];
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
|
|
||||||
share.hardware.nvidia = {
|
share.hardware.nvidia = {
|
||||||
enable = true;
|
enable = true;
|
||||||
enableBeta = true;
|
enableBeta = true;
|
||||||
@@ -163,14 +111,14 @@ in {
|
|||||||
services = {
|
services = {
|
||||||
# Enable the X11 windowing system.
|
# Enable the X11 windowing system.
|
||||||
xserver = {
|
xserver = {
|
||||||
enable = true;
|
enable = enableDisplayManager;
|
||||||
|
|
||||||
# Enable the Plasma 6 Desktop Environment.
|
# Enable the Plasma 6 Desktop Environment.
|
||||||
displayManager = {
|
displayManager = {
|
||||||
sddm.enable = enableDisplayManager;
|
sddm.enable = enableDisplayManager;
|
||||||
defaultSession = "plasmawayland";
|
#defaultSession = "plasma";
|
||||||
};
|
};
|
||||||
desktopManager.plasma6.enable = true;
|
desktopManager.plasma5.enable = enableDisplayManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Set to enable Flatpak
|
# Set to enable Flatpak
|
||||||
@@ -178,9 +126,9 @@ in {
|
|||||||
|
|
||||||
# Enable RDP
|
# Enable RDP
|
||||||
xrdp = {
|
xrdp = {
|
||||||
enable = true;
|
enable = enableDisplayManager;
|
||||||
defaultWindowManager = "startplasma-x11";
|
defaultWindowManager = "startplasma-x11";
|
||||||
openFirewall = true;
|
openFirewall = enableDisplayManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
avahi = {
|
avahi = {
|
||||||
@@ -208,6 +156,62 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
apcupsd = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
grafana = {
|
||||||
|
enable = true;
|
||||||
|
settings.server = {
|
||||||
|
http_port = 2342;
|
||||||
|
domain = hostname;
|
||||||
|
serve_from_sub_path = true;
|
||||||
|
http_addr = "";
|
||||||
|
};
|
||||||
|
dataDir = "/mnt/ssd/nix-app-data/grafana";
|
||||||
|
};
|
||||||
|
|
||||||
|
prometheus = {
|
||||||
|
enable = true;
|
||||||
|
port = 9001;
|
||||||
|
exporters = {
|
||||||
|
node = {
|
||||||
|
enable = true;
|
||||||
|
enabledCollectors = [ "diskstats" "systemd" ];
|
||||||
|
port = 9002;
|
||||||
|
};
|
||||||
|
smartctl = {
|
||||||
|
enable = true;
|
||||||
|
group = "disk";
|
||||||
|
devices = [
|
||||||
|
"/dev/sda"
|
||||||
|
"/dev/sdb"
|
||||||
|
"/dev/sdc"
|
||||||
|
"/dev/sdd"
|
||||||
|
"/dev/sde"
|
||||||
|
"/dev/sdf"
|
||||||
|
"/dev/sdg"
|
||||||
|
"/dev/sdh"
|
||||||
|
"/dev/sdi"
|
||||||
|
"/dev/nvme0n1"
|
||||||
|
"/dev/nvme1n1"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
scrapeConfigs = [{
|
||||||
|
job_name = hostname;
|
||||||
|
static_configs = [{
|
||||||
|
targets = [
|
||||||
|
"127.0.0.1:${toString config.services.prometheus.exporters.node.port}"
|
||||||
|
"127.0.0.1:${
|
||||||
|
toString config.services.prometheus.exporters.smartctl.port
|
||||||
|
}"
|
||||||
|
];
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
@@ -252,13 +256,16 @@ in {
|
|||||||
allowPing = true;
|
allowPing = true;
|
||||||
extraCommands =
|
extraCommands =
|
||||||
"iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns"; # TODO is this needed?
|
"iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns"; # TODO is this needed?
|
||||||
allowedTCPPorts = [ allowedPorts ];
|
allowedTCPPorts = allowedPorts;
|
||||||
allowedUDPPorts = [ allowedPorts ];
|
allowedUDPPorts = allowedPorts;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Configure environment
|
# Configure environment
|
||||||
environment = {
|
environment = {
|
||||||
|
etc."nut/upsd.conf".source = ./upsd.conf;
|
||||||
|
etc."nut/upsd.users".source = ./upsd.users;
|
||||||
|
etc."nut/upsmon.conf".source = ./upsmon.conf;
|
||||||
# List packages installed in system profile. To search, run:
|
# List packages installed in system profile. To search, run:
|
||||||
# $ nix search wget
|
# $ nix search wget
|
||||||
systemPackages = with pkgs; [
|
systemPackages = with pkgs; [
|
||||||
@@ -276,6 +283,7 @@ in {
|
|||||||
binutils
|
binutils
|
||||||
gcc
|
gcc
|
||||||
nodejs-18_x
|
nodejs-18_x
|
||||||
|
nut
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -285,6 +293,16 @@ in {
|
|||||||
virt-manager.enable = true;
|
virt-manager.enable = true;
|
||||||
nix-ld.enable = true;
|
nix-ld.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
power.ups = {
|
||||||
|
enable = true;
|
||||||
|
mode = "netserver";
|
||||||
|
ups."nasups" = {
|
||||||
|
driver = "usbhid-ups";
|
||||||
|
port = "auto";
|
||||||
|
description = "NAS UPS";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Configure nixpkgs
|
# Configure nixpkgs
|
||||||
nixpkgs = {
|
nixpkgs = {
|
||||||
@@ -348,13 +366,22 @@ in {
|
|||||||
extraGroups = [ "jallen-nas" ]; # Enable ‘sudo’ for the user.
|
extraGroups = [ "jallen-nas" ]; # Enable ‘sudo’ for the user.
|
||||||
hashedPassword = password;
|
hashedPassword = password;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
groups.nut.name = "nut";
|
||||||
|
users.upsuser = {
|
||||||
|
group = "nut";
|
||||||
|
isNormalUser = false;
|
||||||
|
isSystemUser = true;
|
||||||
|
createHome = true;
|
||||||
|
home = "/var/lib/nut";
|
||||||
|
hashedPassword = password;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Virtualisation
|
# Virtualisation
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
docker = {
|
docker = {
|
||||||
enable = true;
|
enable = true;
|
||||||
# enableNvidia = true;
|
|
||||||
enableOnBoot = true;
|
enableOnBoot = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user