Add prometheus co2 exporter
This commit is contained in:
parent
c906e208e2
commit
fd3bb4284b
|
@ -8,6 +8,7 @@
|
||||||
./services/media-backup.nix
|
./services/media-backup.nix
|
||||||
./services/media.nix
|
./services/media.nix
|
||||||
./services/torrent.nix
|
./services/torrent.nix
|
||||||
|
./services/co2_exporter.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
sbruder = {
|
sbruder = {
|
||||||
|
|
8
machines/fuuko/services/co2_exporter.nix
Normal file
8
machines/fuuko/services/co2_exporter.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
services.co2_exporter = {
|
||||||
|
enable = true;
|
||||||
|
listenAddress = "${config.sbruder.wireguard.home.address}:9672"; # uses port numer of unrelated co2 exporter to avoid 8080
|
||||||
|
};
|
||||||
|
}
|
|
@ -98,6 +98,10 @@ in
|
||||||
job_name = "hcloud";
|
job_name = "hcloud";
|
||||||
static_configs = mkStaticTarget config.services.hcloud_exporter.listenAddress;
|
static_configs = mkStaticTarget config.services.hcloud_exporter.listenAddress;
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
job_name = "co2";
|
||||||
|
static_configs = mkStaticTarget "fuuko.vpn.sbruder.de:9672";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
rules =
|
rules =
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
|
|
||||||
# TI-84+ SE
|
# TI-84+ SE
|
||||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="e008", MODE="0660", GROUP="users"
|
SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="e008", MODE="0660", GROUP="users"
|
||||||
|
|
||||||
|
# TFA AIRCO2NTROL COACH (Holtek Semiconductor, Inc. USB-zyTemp)
|
||||||
|
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="a052", MODE="0644"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boot.kernelModules = [ "uinput" ];
|
boot.kernelModules = [ "uinput" ];
|
||||||
|
|
24
pkgs/co2_exporter/default.nix
Normal file
24
pkgs/co2_exporter/default.nix
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{ lib, buildGoModule, fetchFromGitHub }:
|
||||||
|
|
||||||
|
buildGoModule rec {
|
||||||
|
pname = "co2_exporter";
|
||||||
|
version = "unstable-2022-11-03";
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "sbruder"; # fork of am3o’s original version
|
||||||
|
repo = pname;
|
||||||
|
rev = "49ee376d257c0d92dcb819de6d67bb16d64b0339";
|
||||||
|
sha256 = "sha256-GJyIS6G0egSfk6LI38VqXg+E+WWQqJRmcvUU9Nk5MSo=";
|
||||||
|
};
|
||||||
|
|
||||||
|
subPackages = [ "." ];
|
||||||
|
|
||||||
|
vendorSha256 = "sha256-CMo6FBzw0/OMKEX12oNqhbF/0dRRFR6W3VRp+EU6Q68=";
|
||||||
|
|
||||||
|
oCheck = false; # no tests
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
license = licenses.mit;
|
||||||
|
maintainer = with mainatiners; [ sbruder ];
|
||||||
|
};
|
||||||
|
}
|
45
pkgs/co2_exporter/module.nix
Normal file
45
pkgs/co2_exporter/module.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
let
|
||||||
|
cfg = config.services.co2_exporter;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.co2_exporter = {
|
||||||
|
enable = lib.mkEnableOption "co2 exporter";
|
||||||
|
package = lib.mkOption {
|
||||||
|
type = lib.types.package;
|
||||||
|
default = pkgs.co2_exporter;
|
||||||
|
description = "The package to use for the exporter.";
|
||||||
|
};
|
||||||
|
device = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.path;
|
||||||
|
default = null;
|
||||||
|
description = "The path to the co2 monitor device.";
|
||||||
|
};
|
||||||
|
listenAddress = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = ":8080";
|
||||||
|
description = "The address to listen on";
|
||||||
|
example = "127.0.0.1:8080";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.co2_exporter = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
environment = {
|
||||||
|
CO2MONITOR_ADDRESS = cfg.listenAddress;
|
||||||
|
} // (lib.optionalAttrs (!isNull cfg.device) {
|
||||||
|
CO2MONITOR_DEVICE = cfg.device;
|
||||||
|
});
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${cfg.package}/bin/co2_exporter";
|
||||||
|
Restart = "always";
|
||||||
|
|
||||||
|
# systemd-analyze --no-pager security co2_exporter.service
|
||||||
|
DynamicUser = true;
|
||||||
|
# FIXME
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ in
|
||||||
{
|
{
|
||||||
bwrap-helper = callPackage ./bwrap-helper { };
|
bwrap-helper = callPackage ./bwrap-helper { };
|
||||||
|
|
||||||
|
co2_exporter = callPackage ./co2_exporter { };
|
||||||
|
|
||||||
osu-lazer = callPackage ./osu-lazer { inherit (prev) osu-lazer; };
|
osu-lazer = callPackage ./osu-lazer { inherit (prev) osu-lazer; };
|
||||||
osu-lazer-sandbox = callPackage ./osu-lazer-sandbox { };
|
osu-lazer-sandbox = callPackage ./osu-lazer-sandbox { };
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./wordclock-dimmer/module.nix
|
./wordclock-dimmer/module.nix
|
||||||
|
./co2_exporter/module.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue