diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3d5479c31f0..2fbde1c451c 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -431,6 +431,7 @@ ./services/monitoring/dd-agent/dd-agent.nix ./services/monitoring/fusion-inventory.nix ./services/monitoring/grafana.nix + ./services/monitoring/grafana-reporter.nix ./services/monitoring/graphite.nix ./services/monitoring/hdaps.nix ./services/monitoring/heapster.nix diff --git a/nixos/modules/services/monitoring/grafana-reporter.nix b/nixos/modules/services/monitoring/grafana-reporter.nix new file mode 100644 index 00000000000..149026d2018 --- /dev/null +++ b/nixos/modules/services/monitoring/grafana-reporter.nix @@ -0,0 +1,66 @@ +{ options, config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.grafana_reporter; + +in { + options.services.grafana_reporter = { + enable = mkEnableOption "grafana_reporter"; + + grafana = { + protocol = mkOption { + description = "Grafana protocol."; + default = "http"; + type = types.enum ["http" "https"]; + }; + addr = mkOption { + description = "Grafana address."; + default = "127.0.0.1"; + type = types.str; + }; + port = mkOption { + description = "Grafana port."; + default = 3000; + type = types.int; + }; + + }; + addr = mkOption { + description = "Listening address."; + default = "127.0.0.1"; + type = types.str; + }; + + port = mkOption { + description = "Listening port."; + default = 8686; + type = types.int; + }; + + templateDir = mkOption { + description = "Optional template directory to use custom tex templates"; + default = "${pkgs.grafana_reporter}"; + type = types.str; + }; + }; + + config = mkIf cfg.enable { + systemd.services.grafana_reporter = { + description = "Grafana Reporter Service Daemon"; + wantedBy = ["multi-user.target"]; + after = ["network.target"]; + serviceConfig = let + args = lib.concatSepString " " [ + "-proto ${cfg.grafana.protocol}://" + "-ip ${cfg.grafana.addr}:${toString cfg.grafana.port}" + "-port :${toString cfg.port}" + "-templates ${cfg.templateDir}" + ]; + in { + ExecStart = "${pkgs.grafana_reporter.bin}/bin/grafana-reporter ${args}"; + }; + }; + }; +} diff --git a/pkgs/servers/monitoring/grafana-reporter/default.nix b/pkgs/servers/monitoring/grafana-reporter/default.nix new file mode 100644 index 00000000000..03ed37b8b3f --- /dev/null +++ b/pkgs/servers/monitoring/grafana-reporter/default.nix @@ -0,0 +1,32 @@ +{ stdenv, buildGoPackage, fetchFromGitHub, tetex, makeWrapper }: + +with stdenv.lib; + +buildGoPackage rec { + name = "reporter-${version}"; + version = "2.0.1"; + rev = "v${version}"; + + goPackagePath = "github.com/IzakMarais/reporter"; + + nativeBuildInputs = [ makeWrapper ]; + + src = fetchFromGitHub { + inherit rev; + owner = "IzakMarais"; + repo = "reporter"; + sha256 = "0yi7nx8ig5xgkwizddl0gdicnmcdp4qgg1fdxyq04l2y3qs176sg"; + }; + + postInstall = '' + wrapProgram $bin/bin/grafana-reporter \ + --prefix PATH : ${makeBinPath [ tetex ]} + ''; + + meta = { + description = "PDF report generator from a Grafana dashboard"; + homepage = https://github.com/IzakMarais/reporter; + license = licenses.mit; + maintainers = with maintainers; [ disassembler ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a24b16d232d..5c7e3fae7c5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13354,6 +13354,8 @@ with pkgs; grafana = callPackage ../servers/monitoring/grafana { }; + grafana_reporter = callPackage ../servers/monitoring/grafana-reporter { }; + h2o = callPackage ../servers/http/h2o { }; haka = callPackage ../tools/security/haka { };