-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos: add module, test, package and patch
- Loading branch information
Showing
8 changed files
with
731 additions
and
1 deletion.
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
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,21 @@ | ||
{ buildGoModule | ||
, lib | ||
}: | ||
|
||
buildGoModule rec { | ||
pname = "prometheus-mgit-exporter"; | ||
# get version from BUILD.bazel | ||
version = with builtins; elemAt (match ".*version = \"([0-9.]*)\".*" (readFile ./BUILD.bazel)) 0; | ||
|
||
src = ./.; | ||
|
||
vendorHash = "sha256-q2e6Q8MbnpOguUNxTumpm3tGbBNes3ada9ma1agcTvs="; | ||
|
||
meta = with lib; { | ||
description = "A collection of useful monitoring for Prometheus by mgIT GmbH."; | ||
homepage = "https://github.com/mgit-at/prometheus-mgit-exporter"; | ||
license = licenses.apsl20; | ||
maintainers = with maintainers; [ mkg20001 ]; | ||
mainProgram = "prometheus-mgit-exporter"; | ||
}; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
description = "A collection of useful monitoring for Prometheus by mgIT GmbH."; | ||
|
||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
inputs.patches4nixpkgs.url = "github:mgit-at/patches4nixpkgs/master"; | ||
|
||
outputs = { self, patches4nixpkgs, ... }@inputs: | ||
let | ||
patchPkgs = patches4nixpkgs.patch inputs.nixpkgs [ self ]; | ||
nixpkgs = patches4nixpkgs.eval patchPkgs; | ||
|
||
supportedSystems = [ "x86_64-linux" "aarch64-linux" ]; | ||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system); | ||
in | ||
{ | ||
overlays.default = final: prev: { | ||
prometheus-mgit-exporter = prev.callPackage ./. {}; | ||
}; | ||
|
||
patches4nixpkgs = nixpkgs: [ | ||
[ | ||
(! builtins.pathExists "${nixpkgs}/nixos/modules/services/monitoring/prometheus/mk-downstream-exporter.nix") | ||
./nixos-prom-downstream.patch | ||
] | ||
]; | ||
|
||
packages = forAllSystems (system: | ||
let | ||
pkgs = (import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlays.default ]; | ||
}); | ||
in | ||
{ | ||
inherit (pkgs) prometheus-mgit-exporter; | ||
default = pkgs.prometheus-mgit-exporter; | ||
} | ||
); | ||
|
||
nixosModules = { | ||
prometheus-mgit-exporter = import ./module.nix; | ||
}; | ||
|
||
checks = forAllSystems (system: | ||
let | ||
pkgs = (import nixpkgs { | ||
inherit system; | ||
overlays = [ self.overlays.default ]; | ||
}); | ||
in | ||
{ | ||
prometheus-mgit-exporter = pkgs.testers.runNixOSTest (import ./test.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,159 @@ | ||
# nixpkgs/nixos/modules/services/prometheus/exporters/mgit.nix | ||
{ config, lib, pkgs, options, utils, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
# for convenience we define cfg here | ||
cfg = config.services.prometheus.exporters.mgit; | ||
json = pkgs.formats.json {}; | ||
configurationFile = json.generate "config.json" cfg; | ||
in | ||
{ | ||
port = 9328; # The mgit exporter listens on this port by default | ||
|
||
# `extraOpts` is an attribute set which contains additional options | ||
# (and optional overrides for default options). | ||
# Note that this attribute is optional. | ||
extraOpts = { | ||
listen = mkOption { | ||
default = ":${toString cfg.port}"; | ||
type = types.str; | ||
description = "Listening address"; | ||
}; | ||
|
||
certFile = { | ||
enable = mkEnableOption "certificate file watching"; | ||
globs = mkOption { | ||
default = []; | ||
type = types.listOf types.str; | ||
description = "List of globs"; | ||
}; | ||
exclude_system = mkOption { | ||
type = types.bool; | ||
description = "Exclude system certificates"; | ||
default = false; | ||
}; | ||
}; | ||
|
||
mceLog = { | ||
enable = mkEnableOption "MCE log"; | ||
path = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Path to MCE log"; | ||
}; | ||
}; | ||
|
||
ptHeartbeat = { | ||
enable = mkEnableOption "PT heartbeat"; | ||
database = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Database for PT heartbeat"; | ||
}; | ||
table = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Table for PT heartbeat"; | ||
}; | ||
defaultsFile = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Defaults file for PT heartbeat"; | ||
}; | ||
masterId = mkOption { | ||
default = 0; | ||
type = types.int; | ||
description = "Master ID for PT heartbeat"; | ||
}; | ||
}; | ||
|
||
fsTab = { | ||
enable = mkEnableOption "fsTab"; | ||
}; | ||
|
||
binLog = { | ||
enable = mkEnableOption "binLog"; | ||
path = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Path to binLog"; | ||
}; | ||
}; | ||
|
||
rasDaemon = { | ||
enable = mkEnableOption "rasDaemon"; | ||
path = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Path to rasDaemon"; | ||
}; | ||
}; | ||
|
||
elk = { | ||
enable = mkEnableOption "elk"; | ||
duration = mkOption { | ||
default = ""; | ||
type = types.str; | ||
description = "Duration for elk"; | ||
}; | ||
node = mkOption { | ||
default = "default_node"; | ||
type = types.str; | ||
description = "Node for elk"; | ||
}; | ||
}; | ||
|
||
exec = { | ||
enable = mkEnableOption "exec"; | ||
scripts = mkOption { | ||
default = {}; | ||
type = types.attrsOf (types.submodule ({ ... }: { | ||
options = { | ||
command = mkOption { | ||
type = types.listOf types.str; | ||
description = "Command"; | ||
}; | ||
|
||
dir = mkOption { | ||
type = types.str; | ||
description = "Working directory"; | ||
default = ""; | ||
}; | ||
|
||
timeout = mkOption { | ||
type = types.str; | ||
description = "Timeout"; | ||
default = ""; | ||
}; | ||
}; | ||
})); | ||
description = "Scripts for exec"; | ||
}; | ||
}; | ||
}; | ||
|
||
# `serviceOpts` is an attribute set which contains configuration | ||
# for the exporter's systemd service. One of | ||
# `serviceOpts.script` and `serviceOpts.serviceConfig.ExecStart` | ||
# has to be specified here. This will be merged with the default | ||
# service configuration. | ||
# Note that by default 'DynamicUser' is 'true'. | ||
serviceOpts = { | ||
unitConfig = { | ||
Description = "mgIT exporter for Prometheus"; | ||
Documentation = "https://prometheus.io/docs/introduction/overview/"; | ||
}; | ||
serviceConfig = { | ||
MemoryMax = "1G"; | ||
Restart = "on-failure"; | ||
RestartSec = 1; | ||
DynamicUser = false; | ||
ExecStart = utils.escapeSystemdExecArgs [ | ||
(getExe pkgs.prometheus-mgit-exporter) | ||
"-config" (toString configurationFile) | ||
]; | ||
}; | ||
}; | ||
} |
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,8 @@ | ||
{ modulesPath, ... }: { | ||
imports = [ | ||
(import "${modulesPath}/services/monitoring/prometheus/mk-downstream-exporter.nix" { | ||
name = "mgit"; | ||
file = ./mgit-exporter.nix; | ||
}) | ||
]; | ||
} |
Oops, something went wrong.