mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(octoprint): metrics
This commit is contained in:
parent
1ead7f237e
commit
2c9219ba87
8 changed files with 91 additions and 18 deletions
|
|
@ -37,6 +37,9 @@ in {
|
||||||
packages.x86_64-linux.openwebrxplus
|
packages.x86_64-linux.openwebrxplus
|
||||||
# TODO: packages.aarch64-linux.openwebrxplus
|
# TODO: packages.aarch64-linux.openwebrxplus
|
||||||
];
|
];
|
||||||
|
print.inputs = [
|
||||||
|
legacyPackages.x86_64-linux.pkgs.cura-octoprint
|
||||||
|
];
|
||||||
systemd2mqtt.inputs = [
|
systemd2mqtt.inputs = [
|
||||||
packages.x86_64-linux.systemd2mqtt
|
packages.x86_64-linux.systemd2mqtt
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@
|
||||||
portName,
|
portName,
|
||||||
}: let
|
}: let
|
||||||
port = service.ports.${portName};
|
port = service.ports.${portName};
|
||||||
in "${mkAddress6 (access.getAddressFor system.name "lan")}:${toString port.port}";
|
# TODO: this properly
|
||||||
|
getAddressFor = if port.status.gatus.client.network or "ip" == "ip4" then "getAddress4For" else "getAddressFor";
|
||||||
|
in "${mkAddress6 (access.${getAddressFor} system.name "lan")}:${toString port.port}";
|
||||||
mkServiceConfig = system: serviceName: let
|
mkServiceConfig = system: serviceName: let
|
||||||
inherit (service.prometheus) exporter;
|
inherit (service.prometheus) exporter;
|
||||||
service = system.exports.services.${serviceName};
|
service = system.exports.services.${serviceName};
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ in {
|
||||||
config.exports.services.octoprint = {config, ...}: {
|
config.exports.services.octoprint = {config, ...}: {
|
||||||
displayName = mkAlmostOptionDefault "OctoPrint";
|
displayName = mkAlmostOptionDefault "OctoPrint";
|
||||||
id = mkAlmostOptionDefault "print";
|
id = mkAlmostOptionDefault "print";
|
||||||
|
prometheus.exporter.metricsPath = "/plugin/prometheus_exporter/metrics";
|
||||||
nixos = {
|
nixos = {
|
||||||
serviceAttr = "octoprint";
|
serviceAttr = "octoprint";
|
||||||
assertions = let
|
assertions = let
|
||||||
|
|
@ -33,6 +34,7 @@ in {
|
||||||
enable = mkAlmostOptionDefault true;
|
enable = mkAlmostOptionDefault true;
|
||||||
gatus.client.network = mkAlmostOptionDefault "ip4";
|
gatus.client.network = mkAlmostOptionDefault "ip4";
|
||||||
};
|
};
|
||||||
|
prometheus.exporter.enable = mkAlmostOptionDefault true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
pkgs,
|
||||||
config,
|
config,
|
||||||
access,
|
access,
|
||||||
lib,
|
lib,
|
||||||
|
|
@ -12,6 +13,18 @@ in {
|
||||||
services.octoprint = {
|
services.octoprint = {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
# host = mkIf config.networking.enableIPv6 "::";
|
# host = mkIf config.networking.enableIPv6 "::";
|
||||||
|
plugins = python3Packages: with python3Packages; [
|
||||||
|
prometheus-exporter
|
||||||
|
abl-expert
|
||||||
|
bedlevelvisualizer
|
||||||
|
#displayprogress / displaylayerprogress?
|
||||||
|
marlingcodedocumentation
|
||||||
|
printtimegenius
|
||||||
|
stlviewer
|
||||||
|
#octoklipper?
|
||||||
|
#octolapse?
|
||||||
|
#dashboard?
|
||||||
|
];
|
||||||
extraConfig = mkMerge [
|
extraConfig = mkMerge [
|
||||||
# https://docs.octoprint.org/en/master/configuration/config_yaml.html
|
# https://docs.octoprint.org/en/master/configuration/config_yaml.html
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
final: prev: {
|
|
||||||
cura-octoprint = final.cura.override {
|
|
||||||
plugins = [ final.curaPlugins.octoprint ];
|
|
||||||
};
|
|
||||||
|
|
||||||
curaengine = prev.curaengine.override {
|
|
||||||
inherit (final.python311Packages) libarcus;
|
|
||||||
};
|
|
||||||
cura = prev.cura.override {
|
|
||||||
python3 = final.python311;
|
|
||||||
};
|
|
||||||
curaPlugins = prev.curaPlugins.override {
|
|
||||||
python3Packages = final.python311Packages;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -4,22 +4,22 @@ in rec {
|
||||||
default = nixlib.composeManyExtensions [
|
default = nixlib.composeManyExtensions [
|
||||||
barcodebuddy
|
barcodebuddy
|
||||||
builders
|
builders
|
||||||
cura
|
|
||||||
krb5
|
krb5
|
||||||
minecraft
|
minecraft
|
||||||
nfs
|
nfs
|
||||||
nginx
|
nginx
|
||||||
openwebrx
|
openwebrx
|
||||||
|
print
|
||||||
samba
|
samba
|
||||||
];
|
];
|
||||||
barcodebuddy = import ./barcodebuddy.nix;
|
barcodebuddy = import ./barcodebuddy.nix;
|
||||||
cura = import ./cura.nix;
|
|
||||||
krb5 = import ./krb5.nix;
|
krb5 = import ./krb5.nix;
|
||||||
minecraft = import ./minecraft.nix;
|
minecraft = import ./minecraft.nix;
|
||||||
nfs = import ./nfs.nix;
|
nfs = import ./nfs.nix;
|
||||||
nginx = import ./nginx.nix;
|
nginx = import ./nginx.nix;
|
||||||
samba = import ./samba.nix;
|
samba = import ./samba.nix;
|
||||||
openwebrx = import ./openwebrxplus.nix;
|
openwebrx = import ./openwebrxplus.nix;
|
||||||
|
print = import ./print.nix;
|
||||||
builders = import ./builders.nix;
|
builders = import ./builders.nix;
|
||||||
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
deploy-rs = inputs.deploy-rs.overlays.default or inputs.deploy-rs.overlay;
|
||||||
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
|
systemd2mqtt = inputs.systemd2mqtt.overlays.default;
|
||||||
|
|
|
||||||
44
overlays/print.nix
Normal file
44
overlays/print.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
final: prev: let
|
||||||
|
inherit (final) lib;
|
||||||
|
in {
|
||||||
|
cura-octoprint = final.cura.override {
|
||||||
|
plugins = [ final.curaPlugins.octoprint ];
|
||||||
|
};
|
||||||
|
|
||||||
|
octoprint = let
|
||||||
|
mapPlugin = python3Packages: _: plugin: plugin.override {
|
||||||
|
inherit python3Packages;
|
||||||
|
inherit (python3Packages) buildPlugin;
|
||||||
|
};
|
||||||
|
packageOverrides = python3Packages: python3Packages'prev: lib.mapAttrs (mapPlugin python3Packages) {
|
||||||
|
inherit (final.octoprintPlugins) prometheus-exporter;
|
||||||
|
};
|
||||||
|
octoprint = prev.octoprint.override (old: {
|
||||||
|
packageOverrides = lib.composeExtensions old.packageOverrides or (_: _: {}) packageOverrides;
|
||||||
|
});
|
||||||
|
in octoprint;
|
||||||
|
|
||||||
|
octoprintPlugins = let
|
||||||
|
pythonPackages = final.octoprint.python.pkgs;
|
||||||
|
octoprintPlugins'overlay = final.callPackage (final.path + "/pkgs/applications/misc/octoprint/plugins.nix") { };
|
||||||
|
octoprintPlugins'nixpkgs = octoprintPlugins'overlay pythonPackages pythonPackages;
|
||||||
|
octoprintPlugins = prev.octoprintPlugins or octoprintPlugins'nixpkgs;
|
||||||
|
callPackage = final.newScope {
|
||||||
|
inherit (final.octoprintPlugins) buildPlugin;
|
||||||
|
};
|
||||||
|
in octoprintPlugins // {
|
||||||
|
callPackage = prev.octoprintPlugins.callPackage or callPackage;
|
||||||
|
|
||||||
|
prometheus-exporter = callPackage ../packages/octoprint/prometheus-exporter.nix { };
|
||||||
|
};
|
||||||
|
|
||||||
|
curaengine = prev.curaengine.override {
|
||||||
|
inherit (final.python311Packages) libarcus;
|
||||||
|
};
|
||||||
|
cura = prev.cura.override {
|
||||||
|
python3 = final.python311;
|
||||||
|
};
|
||||||
|
curaPlugins = prev.curaPlugins.override {
|
||||||
|
python3Packages = final.python311Packages;
|
||||||
|
};
|
||||||
|
}
|
||||||
24
packages/octoprint/prometheus-exporter.nix
Normal file
24
packages/octoprint/prometheus-exporter.nix
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
{ buildPlugin
|
||||||
|
, python3Packages
|
||||||
|
, fetchFromGitHub
|
||||||
|
}: let
|
||||||
|
version = "0.2.3";
|
||||||
|
in buildPlugin {
|
||||||
|
pname = "OctoPrint-Prometheus-Exporter";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "tg44";
|
||||||
|
repo = "OctoPrint-Prometheus-Exporter";
|
||||||
|
rev = version;
|
||||||
|
sha256 = "sha256-pw5JKMWQNAkFkUADR2ue6R4FOmFIeapw2k5FLqJ6NQg=";
|
||||||
|
};
|
||||||
|
|
||||||
|
propagatedBuildInputs = with python3Packages; [
|
||||||
|
prometheus-client
|
||||||
|
];
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
homepage = "https://github.com/tg44/OctoPrint-Prometheus-Exporter";
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue