vuls: init at 0.27.0
[NixPkgs.git] / nixos / modules / services / monitoring / prometheus / exporters / smokeping.nix
blobc3baed1503764db8f9758ed9c0ca8e6a9d3685a6
1 { config, lib, pkgs, options, ... }:
3 let
4   cfg = config.services.prometheus.exporters.smokeping;
5   inherit (lib) mkOption types concatStringsSep;
6   goDuration = types.mkOptionType {
7     name = "goDuration";
8     description = "Go duration (https://golang.org/pkg/time/#ParseDuration)";
9     check = x: types.str.check x && builtins.match "(-?[0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+" x != null;
10     inherit (types.str) merge;
11   };
14   port = 9374;
15   extraOpts = {
16     telemetryPath = mkOption {
17       type = types.str;
18       default = "/metrics";
19       description = ''
20         Path under which to expose metrics.
21       '';
22     };
23     pingInterval = mkOption {
24       type = goDuration;
25       default = "1s";
26       description = ''
27         Interval between pings.
28       '';
29     };
30     buckets = mkOption {
31       type = types.commas;
32       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";
33       description = ''
34         List of buckets to use for the response duration histogram.
35       '';
36     };
37     hosts = mkOption {
38       type = with types; listOf str;
39       description = ''
40         List of endpoints to probe.
41       '';
42     };
43   };
44   serviceOpts = {
45     serviceConfig = {
46       AmbientCapabilities = [ "CAP_NET_RAW" ];
47       CapabilityBoundingSet = [ "CAP_NET_RAW" ];
48       ExecStart = ''
49         ${pkgs.prometheus-smokeping-prober}/bin/smokeping_prober \
50           --web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
51           --web.telemetry-path ${cfg.telemetryPath} \
52           --buckets ${cfg.buckets} \
53           --ping.interval ${cfg.pingInterval} \
54           --privileged \
55           ${concatStringsSep " \\\n  " cfg.extraFlags} \
56           ${concatStringsSep " " cfg.hosts}
57       '';
58     };
59   };