2024-12-10 20:26:33 +01:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2014-08-23 17:04:34 +02:00
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.riemann;
|
|
|
|
|
2024-08-30 00:47:03 +02:00
|
|
|
classpath = lib.concatStringsSep ":" (
|
|
|
|
cfg.extraClasspathEntries ++ [ "${pkgs.riemann}/share/java/riemann.jar" ]
|
2014-08-23 17:04:34 +02:00
|
|
|
);
|
|
|
|
|
2024-08-30 00:47:03 +02:00
|
|
|
riemannConfig = lib.concatStringsSep "\n" (
|
2024-12-10 20:26:33 +01:00
|
|
|
[ cfg.config ] ++ (map (f: ''(load-file "${f}")'') cfg.configFiles)
|
2014-11-19 12:55:42 +01:00
|
|
|
);
|
|
|
|
|
2024-08-30 00:47:03 +02:00
|
|
|
launcher = pkgs.writeScriptBin "riemann" ''
|
2014-08-23 17:04:34 +02:00
|
|
|
#!/bin/sh
|
2024-08-30 00:47:03 +02:00
|
|
|
exec ${pkgs.jdk}/bin/java ${lib.concatStringsSep " " cfg.extraJavaOpts} \
|
2014-08-23 17:04:34 +02:00
|
|
|
-cp ${classpath} \
|
2018-08-01 13:36:16 +01:00
|
|
|
riemann.bin ${cfg.configFile}
|
2014-08-23 17:04:34 +02:00
|
|
|
'';
|
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
in
|
|
|
|
{
|
2014-08-23 17:04:34 +02:00
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.riemann = {
|
2024-08-30 00:47:03 +02:00
|
|
|
enable = lib.mkEnableOption "Riemann network monitoring daemon";
|
2022-11-09 22:45:00 +01:00
|
|
|
|
2024-08-30 00:47:03 +02:00
|
|
|
config = lib.mkOption {
|
|
|
|
type = lib.types.lines;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2018-08-01 13:36:16 +01:00
|
|
|
Contents of the Riemann configuration file. For more complicated
|
|
|
|
config you should use configFile.
|
2014-08-23 17:04:34 +02:00
|
|
|
'';
|
|
|
|
};
|
2024-08-30 00:47:03 +02:00
|
|
|
configFiles = lib.mkOption {
|
|
|
|
type = with lib.types; listOf path;
|
2024-12-10 20:26:33 +01:00
|
|
|
default = [ ];
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2014-11-19 12:55:42 +01:00
|
|
|
Extra files containing Riemann configuration. These files will be
|
|
|
|
loaded at runtime by Riemann (with Clojure's
|
2022-07-28 23:19:15 +02:00
|
|
|
`load-file` function) at the end of the
|
2018-08-01 13:36:16 +01:00
|
|
|
configuration if you use the config option, this is ignored if you
|
|
|
|
use configFile.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-30 00:47:03 +02:00
|
|
|
configFile = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2018-08-01 13:36:16 +01:00
|
|
|
A Riemann config file. Any files in the same directory as this file
|
|
|
|
will be added to the classpath by Riemann.
|
2014-11-19 12:55:42 +01:00
|
|
|
'';
|
|
|
|
};
|
2024-08-30 00:47:03 +02:00
|
|
|
extraClasspathEntries = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
2024-12-10 20:26:33 +01:00
|
|
|
default = [ ];
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2014-08-23 17:04:34 +02:00
|
|
|
Extra entries added to the Java classpath when running Riemann.
|
|
|
|
'';
|
|
|
|
};
|
2024-08-30 00:47:03 +02:00
|
|
|
extraJavaOpts = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
2024-12-10 20:26:33 +01:00
|
|
|
default = [ ];
|
2024-04-13 14:54:15 +02:00
|
|
|
description = ''
|
2014-08-23 17:04:34 +02:00
|
|
|
Extra Java options used when launching Riemann.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-08-30 00:47:03 +02:00
|
|
|
config = lib.mkIf cfg.enable {
|
2014-08-23 17:04:34 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.groups.riemann.gid = config.ids.gids.riemann;
|
2014-08-23 17:04:34 +02:00
|
|
|
|
2018-06-30 01:58:35 +02:00
|
|
|
users.users.riemann = {
|
2014-08-23 17:04:34 +02:00
|
|
|
description = "riemann daemon user";
|
|
|
|
uid = config.ids.uids.riemann;
|
|
|
|
group = "riemann";
|
|
|
|
};
|
|
|
|
|
2024-12-10 20:26:33 +01:00
|
|
|
services.riemann.configFile = lib.mkDefault (pkgs.writeText "riemann-config.clj" riemannConfig);
|
2018-08-01 13:36:16 +01:00
|
|
|
|
2014-08-23 17:04:34 +02:00
|
|
|
systemd.services.riemann = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2024-08-30 00:47:03 +02:00
|
|
|
path = [ pkgs.inetutils ];
|
2014-08-23 17:04:34 +02:00
|
|
|
serviceConfig = {
|
|
|
|
User = "riemann";
|
|
|
|
ExecStart = "${launcher}/bin/riemann";
|
|
|
|
};
|
2018-08-01 13:36:16 +01:00
|
|
|
serviceConfig.LimitNOFILE = 65536;
|
2014-08-23 17:04:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|