summary refs log tree commit diff
diff options
context:
space:
mode:
authorRickard Nilsson <rickynils@gmail.com>2014-08-23 17:04:34 +0200
committerRickard Nilsson <rickynils@gmail.com>2014-08-23 17:40:22 +0200
commite9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a (patch)
tree52b9a2e430f39dec445f1f1e34eb788ebc188392
parent3194d5cc321eb09e4b6d936317cf3aba4cca6037 (diff)
downloadnixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar.gz
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar.bz2
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar.lz
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar.xz
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.tar.zst
nixpkgs-e9252cb35e0b0b09d0cb16a9d8b1f62c8233bc0a.zip
Add NixOS module for Riemann monitoring server.
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/monitoring/riemann.nix77
3 files changed, 80 insertions, 0 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 515105d886a..78b3bc2f311 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -144,6 +144,7 @@
       siproxd = 134;
       mlmmj = 135;
       neo4j = 136;
+      riemann = 137;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -261,6 +262,7 @@
       tss = 133;
       siproxd = 134;
       mlmmj = 135;
+      riemann = 137;
 
       # When adding a gid, make sure it doesn't match an existing uid. And don't use gids above 399!
 
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index feb590ad249..532083aa6bd 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -170,6 +170,7 @@
   ./services/monitoring/monit.nix
   ./services/monitoring/munin.nix
   ./services/monitoring/nagios.nix
+  ./services/monitoring/riemann.nix
   ./services/monitoring/smartd.nix
   ./services/monitoring/statsd.nix
   ./services/monitoring/systemhealth.nix
diff --git a/nixos/modules/services/monitoring/riemann.nix b/nixos/modules/services/monitoring/riemann.nix
new file mode 100644
index 00000000000..e8d32af1b83
--- /dev/null
+++ b/nixos/modules/services/monitoring/riemann.nix
@@ -0,0 +1,77 @@
+{ config, pkgs, ... }:
+
+with pkgs;
+with pkgs.lib;
+
+let
+
+  cfg = config.services.riemann;
+
+  classpath = concatStringsSep ":" (
+    cfg.extraClasspathEntries ++ [ "${riemann}/share/java/riemann.jar" ]
+  );
+
+  launcher = writeScriptBin "riemann" ''
+    #!/bin/sh
+    exec ${openjdk}/bin/java ${concatStringsSep "\n" cfg.extraJavaOpts} \
+      -cp ${classpath} \
+      riemann.bin ${writeText "riemann.config" cfg.config}
+  '';
+
+in {
+
+  options = {
+
+    services.riemann = {
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Enable the Riemann network monitoring daemon.
+        '';
+      };
+      config = mkOption {
+        type = types.lines;
+        description = ''
+          Contents of the Riemann configuration file.
+        '';
+      };
+      extraClasspathEntries = mkOption {
+        type = with types; listOf str;
+        default = [];
+        description = ''
+          Extra entries added to the Java classpath when running Riemann.
+        '';
+      };
+      extraJavaOpts = mkOption {
+        type = with types; listOf str;
+        default = [];
+        description = ''
+          Extra Java options used when launching Riemann.
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+
+    users.extraGroups.riemann.gid = config.ids.gids.riemann;
+
+    users.extraUsers.riemann = {
+      description = "riemann daemon user";
+      uid = config.ids.uids.riemann;
+      group = "riemann";
+    };
+
+    systemd.services.riemann = {
+      wantedBy = [ "multi-user.target" ];
+      path = [ inetutils ];
+      serviceConfig = {
+        User = "riemann";
+        ExecStart = "${launcher}/bin/riemann";
+      };
+    };
+
+  };
+
+}