diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index df482fbfcaf..db8c5219925 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -308,9 +308,11 @@ ./services/monitoring/munin.nix ./services/monitoring/nagios.nix ./services/monitoring/prometheus/default.nix + ./services/monitoring/prometheus/alertmanager.nix ./services/monitoring/prometheus/nginx-exporter.nix ./services/monitoring/prometheus/node-exporter.nix - ./services/monitoring/prometheus/alertmanager.nix + ./services/monitoring/prometheus/snmp-exporter.nix + ./services/monitoring/prometheus/varnish-exporter.nix ./services/monitoring/riemann.nix ./services/monitoring/riemann-dash.nix ./services/monitoring/riemann-tools.nix diff --git a/nixos/modules/services/monitoring/prometheus/varnish-exporter.nix b/nixos/modules/services/monitoring/prometheus/varnish-exporter.nix new file mode 100644 index 00000000000..0f608760e91 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/varnish-exporter.nix @@ -0,0 +1,51 @@ +{ config, pkgs, lib, ... }: + +# Shamelessly cribbed from nginx-exporter.nix. ~ C. +with lib; + +let + cfg = config.services.prometheus.varnishExporter; +in { + options = { + services.prometheus.varnishExporter = { + enable = mkEnableOption "prometheus Varnish exporter"; + + port = mkOption { + type = types.int; + default = 9131; + description = '' + Port to listen on. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the Varnish exporter. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.prometheus-varnish-exporter = { + description = "Prometheus exporter for Varnish metrics"; + unitConfig.Documentation = "https://github.com/jonnenauha/prometheus_varnish_exporter"; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.varnish ]; + script = '' + exec ${pkgs.prometheus-varnish-exporter}/bin/prometheus_varnish_exporter \ + -web.listen-address :${toString cfg.port} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + }; + }; +}