3p/nixpkgs: add prometheus-smokeping-prober patch
This commit is contained in:
parent
8773350ba6
commit
16424e3c3c
2 changed files with 197 additions and 0 deletions
196
third_party/nixpkgs/patches/pr107891-prometheus-smokeping-prober.patch
vendored
Normal file
196
third_party/nixpkgs/patches/pr107891-prometheus-smokeping-prober.patch
vendored
Normal file
|
@ -0,0 +1,196 @@
|
|||
From 0487aff7d07a3cf3399738baf4beb3edaae7043c Mon Sep 17 00:00:00 2001
|
||||
From: Luke Granger-Brown <git@lukegb.com>
|
||||
Date: Tue, 29 Dec 2020 17:44:07 +0000
|
||||
Subject: [PATCH 1/2] prometheus-smokeping-prober: init at 0.3.1 from git
|
||||
|
||||
---
|
||||
.../prometheus/smokeping-prober.nix | 43 +++++++++++++++++++
|
||||
pkgs/top-level/all-packages.nix | 1 +
|
||||
2 files changed, 44 insertions(+)
|
||||
create mode 100644 pkgs/servers/monitoring/prometheus/smokeping-prober.nix
|
||||
|
||||
diff --git a/pkgs/servers/monitoring/prometheus/smokeping-prober.nix b/pkgs/servers/monitoring/prometheus/smokeping-prober.nix
|
||||
new file mode 100644
|
||||
index 0000000000000..aea7c54deaeed
|
||||
--- /dev/null
|
||||
+++ b/pkgs/servers/monitoring/prometheus/smokeping-prober.nix
|
||||
@@ -0,0 +1,43 @@
|
||||
+{ stdenv, buildGoModule, fetchFromGitHub, nixosTests }:
|
||||
+
|
||||
+let
|
||||
+ inherit (stdenv) lib;
|
||||
+ baseVersion = "0.3.1";
|
||||
+ commit = "9ba85274dcc21bf8132cbe3b3dccfcb4aab57d9f";
|
||||
+in
|
||||
+buildGoModule rec {
|
||||
+ pname = "smokeping_prober";
|
||||
+ version = "${baseVersion}-g${commit}";
|
||||
+
|
||||
+ buildFlagsArray = let
|
||||
+ setVars = {
|
||||
+ Version = baseVersion;
|
||||
+ Revision = commit;
|
||||
+ Branch = commit;
|
||||
+ BuildUser = "nix";
|
||||
+ };
|
||||
+ varFlags = lib.concatStringsSep " " (lib.mapAttrsToList (name: value: "-X github.com/prometheus/common/version.${name}=${value}") setVars);
|
||||
+ in [
|
||||
+ "-ldflags=${varFlags}"
|
||||
+ ];
|
||||
+
|
||||
+ src = fetchFromGitHub {
|
||||
+ rev = commit;
|
||||
+ owner = "SuperQ";
|
||||
+ repo = "smokeping_prober";
|
||||
+ sha256 = "sha256:19596di2gzcvlcwiypsncq4zwbyb6d1r6wxsfi59wax3423i7ndg";
|
||||
+ };
|
||||
+ vendorSha256 = "sha256:1b2v3v3kn0m7dvjxbs8q0gw6zingksdqhm5g1frx0mymqk0lg889";
|
||||
+
|
||||
+ doCheck = true;
|
||||
+
|
||||
+ passthru.tests = { inherit (nixosTests.prometheus-exporters) smokeping; };
|
||||
+
|
||||
+ meta = with stdenv.lib; {
|
||||
+ description = "Prometheus exporter for sending continual ICMP/UDP pings";
|
||||
+ homepage = "https://github.com/SuperQ/smokeping_prober";
|
||||
+ license = licenses.asl20;
|
||||
+ maintainers = with maintainers; [ lukegb ];
|
||||
+ platforms = platforms.unix;
|
||||
+ };
|
||||
+}
|
||||
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
|
||||
index 27c565bce0c71..6619845898cb0 100644
|
||||
--- a/pkgs/top-level/all-packages.nix
|
||||
+++ b/pkgs/top-level/all-packages.nix
|
||||
@@ -17673,6 +17673,7 @@ in
|
||||
prometheus-redis-exporter = callPackage ../servers/monitoring/prometheus/redis-exporter.nix { };
|
||||
prometheus-rabbitmq-exporter = callPackage ../servers/monitoring/prometheus/rabbitmq-exporter.nix { };
|
||||
prometheus-rtl_433-exporter = callPackage ../servers/monitoring/prometheus/rtl_433-exporter.nix { };
|
||||
+ prometheus-smokeping-prober = callPackage ../servers/monitoring/prometheus/smokeping-prober.nix { };
|
||||
prometheus-snmp-exporter = callPackage ../servers/monitoring/prometheus/snmp-exporter.nix { };
|
||||
prometheus-sql-exporter = callPackage ../servers/monitoring/prometheus/sql-exporter.nix { };
|
||||
prometheus-tor-exporter = callPackage ../servers/monitoring/prometheus/tor-exporter.nix { };
|
||||
|
||||
From 6f0916b1d59904ec24660d4394f6eacec23d9a59 Mon Sep 17 00:00:00 2001
|
||||
From: Luke Granger-Brown <git@lukegb.com>
|
||||
Date: Tue, 29 Dec 2020 17:47:58 +0000
|
||||
Subject: [PATCH 2/2] nixos/prometheus: add smokeping and corresponding NixOS
|
||||
test
|
||||
|
||||
---
|
||||
.../monitoring/prometheus/exporters.nix | 1 +
|
||||
.../prometheus/exporters/smokeping.nix | 60 +++++++++++++++++++
|
||||
nixos/tests/prometheus-exporters.nix | 21 +++++++
|
||||
3 files changed, 82 insertions(+)
|
||||
create mode 100644 nixos/modules/services/monitoring/prometheus/exporters/smokeping.nix
|
||||
|
||||
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
|
||||
index 683dc0390c59b..3e7b303620f78 100644
|
||||
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
|
||||
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
|
||||
@@ -47,6 +47,7 @@ let
|
||||
"rspamd"
|
||||
"rtl_433"
|
||||
"snmp"
|
||||
+ "smokeping"
|
||||
"sql"
|
||||
"surfboard"
|
||||
"tor"
|
||||
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/smokeping.nix b/nixos/modules/services/monitoring/prometheus/exporters/smokeping.nix
|
||||
new file mode 100644
|
||||
index 0000000000000..0a7bb9c27be28
|
||||
--- /dev/null
|
||||
+++ b/nixos/modules/services/monitoring/prometheus/exporters/smokeping.nix
|
||||
@@ -0,0 +1,60 @@
|
||||
+{ config, lib, pkgs, options }:
|
||||
+
|
||||
+with lib;
|
||||
+
|
||||
+let
|
||||
+ cfg = config.services.prometheus.exporters.smokeping;
|
||||
+ goDuration = types.mkOptionType {
|
||||
+ name = "goDuration";
|
||||
+ description = "Go duration (https://golang.org/pkg/time/#ParseDuration)";
|
||||
+ check = x: types.str.check x && builtins.match "(-?[0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+" x != null;
|
||||
+ inherit (types.str) merge;
|
||||
+ };
|
||||
+in
|
||||
+{
|
||||
+ port = 9374;
|
||||
+ extraOpts = {
|
||||
+ telemetryPath = mkOption {
|
||||
+ type = types.str;
|
||||
+ default = "/metrics";
|
||||
+ description = ''
|
||||
+ Path under which to expose metrics.
|
||||
+ '';
|
||||
+ };
|
||||
+ pingInterval = mkOption {
|
||||
+ type = goDuration;
|
||||
+ default = "1s";
|
||||
+ description = ''
|
||||
+ Interval between pings.
|
||||
+ '';
|
||||
+ };
|
||||
+ buckets = mkOption {
|
||||
+ type = types.commas;
|
||||
+ default = "5e-05,0.0001,0.0002,0.0004,0.0008,0.0016,0.0032,0.0064,0.0128,0.0256,0.0512,0.1024,0.2048,0.4096,0.8192,1.6384,3.2768,6.5536,13.1072,26.2144";
|
||||
+ description = ''
|
||||
+ List of buckets to use for the response duration histogram.
|
||||
+ '';
|
||||
+ };
|
||||
+ hosts = mkOption {
|
||||
+ type = with types; listOf str;
|
||||
+ description = ''
|
||||
+ List of endpoints to probe.
|
||||
+ '';
|
||||
+ };
|
||||
+ };
|
||||
+ serviceOpts = {
|
||||
+ serviceConfig = {
|
||||
+ AmbientCapabilities = [ "CAP_NET_RAW" ];
|
||||
+ ExecStart = ''
|
||||
+ ${pkgs.prometheus-smokeping-prober}/bin/smokeping_prober \
|
||||
+ --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
|
||||
+ --web.telemetry-path ${cfg.telemetryPath} \
|
||||
+ --buckets ${cfg.buckets} \
|
||||
+ --ping.interval ${cfg.pingInterval} \
|
||||
+ --privileged \
|
||||
+ ${concatStringsSep " \\\n " cfg.extraFlags} \
|
||||
+ ${concatStringsSep " " cfg.hosts}
|
||||
+ '';
|
||||
+ };
|
||||
+ };
|
||||
+}
|
||||
diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix
|
||||
index ffa7f420c093d..4dcea39cef173 100644
|
||||
--- a/nixos/tests/prometheus-exporters.nix
|
||||
+++ b/nixos/tests/prometheus-exporters.nix
|
||||
@@ -670,6 +670,27 @@ let
|
||||
'';
|
||||
};
|
||||
|
||||
+ smokeping = {
|
||||
+ exporterConfig = {
|
||||
+ enable = true;
|
||||
+ hosts = ["127.0.0.1"];
|
||||
+ };
|
||||
+ exporterTest = ''
|
||||
+ wait_for_unit("prometheus-smokeping-exporter.service")
|
||||
+ wait_for_open_port(9374)
|
||||
+ wait_until_succeeds(
|
||||
+ "curl -sSf localhost:9374/metrics | grep '{}' | grep -qv ' 0$'".format(
|
||||
+ 'smokeping_requests_total{host="127.0.0.1",ip="127.0.0.1"} '
|
||||
+ )
|
||||
+ )
|
||||
+ wait_until_succeeds(
|
||||
+ "curl -sSf localhost:9374/metrics | grep -q '{}'".format(
|
||||
+ 'smokeping_response_ttl{host="127.0.0.1",ip="127.0.0.1"}'
|
||||
+ )
|
||||
+ )
|
||||
+ '';
|
||||
+ };
|
||||
+
|
||||
snmp = {
|
||||
exporterConfig = {
|
||||
enable = true;
|
1
third_party/nixpkgs/patches/series
vendored
1
third_party/nixpkgs/patches/series
vendored
|
@ -1 +1,2 @@
|
|||
pr106924-factorio-bump-1.1.6.patch
|
||||
pr107891-prometheus-smokeping-prober.patch
|
||||
|
|
Loading…
Reference in a new issue