-
-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
209 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ let | |
"openvpn" | ||
"postfix" | ||
"postgres" | ||
"py-air-control" | ||
"redis" | ||
"rspamd" | ||
"rtl_433" | ||
|
62 changes: 62 additions & 0 deletions
62
nixos/modules/services/monitoring/prometheus/exporters/py-air-control.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ config, lib, pkgs, options }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.prometheus.exporters.py-air-control; | ||
|
||
py-air-control-exporter-env = pkgs.python3.withPackages (pyPkgs: [ | ||
pyPkgs.py-air-control-exporter | ||
]); | ||
|
||
workingDir = "/var/lib/${cfg.stateDir}"; | ||
|
||
in | ||
{ | ||
port = 9896; | ||
extraOpts = { | ||
deviceHostname = mkOption { | ||
type = types.str; | ||
example = "192.168.1.123"; | ||
description = '' | ||
The hostname of the air purification device from which to scrape the metrics. | ||
''; | ||
}; | ||
protocol = mkOption { | ||
type = types.str; | ||
default = "http"; | ||
description = '' | ||
The protocol to use when communicating with the air purification device. | ||
Available: [http, coap, plain_coap] | ||
''; | ||
}; | ||
stateDir = mkOption { | ||
type = types.str; | ||
default = "prometheus-py-air-control-exporter"; | ||
description = '' | ||
Directory below <literal>/var/lib</literal> to store runtime data. | ||
This directory will be created automatically using systemd's StateDirectory mechanism. | ||
''; | ||
}; | ||
}; | ||
serviceOpts = { | ||
serviceConfig = { | ||
DynamicUser = false; | ||
StateDirectory = cfg.stateDir; | ||
WorkingDirectory = workingDir; | ||
ExecStart = '' | ||
${py-air-control-exporter-env}/bin/python -c \ | ||
"from py_air_control_exporter import app; app.create_app().run( \ | ||
debug=False, \ | ||
port=${toString cfg.port}, \ | ||
host='${cfg.listenAddress}', \ | ||
)" | ||
''; | ||
Environment = [ | ||
"PY_AIR_CONTROL_HOST=${cfg.deviceHostname}" | ||
"PY_AIR_CONTROL_PROTOCOL=${cfg.protocol}" | ||
"HOME=${workingDir}" | ||
]; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.