2014-05-05 11:58:51 -07:00
|
|
|
{config, pkgs, lib, ...}:
|
2009-11-18 00:39:10 -08:00
|
|
|
|
2018-11-09 16:07:42 -08:00
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.monit;
|
2009-11-18 00:39:10 -08:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2018-11-09 16:07:42 -08:00
|
|
|
options.services.monit = {
|
|
|
|
|
|
|
|
enable = mkEnableOption "Monit";
|
|
|
|
|
|
|
|
config = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = "monitrc content";
|
2009-11-18 00:39:10 -08:00
|
|
|
};
|
2018-11-09 16:07:42 -08:00
|
|
|
|
2009-11-18 00:39:10 -08:00
|
|
|
};
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2018-11-09 16:07:42 -08:00
|
|
|
config = mkIf cfg.enable {
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2017-09-27 15:20:14 -07:00
|
|
|
environment.systemPackages = [ pkgs.monit ];
|
|
|
|
|
2019-08-13 14:52:01 -07:00
|
|
|
environment.etc.monitrc = {
|
2018-11-09 16:07:42 -08:00
|
|
|
text = cfg.config;
|
2018-03-28 14:45:57 -07:00
|
|
|
mode = "0400";
|
|
|
|
};
|
2011-09-14 11:20:50 -07:00
|
|
|
|
2016-01-05 22:50:18 -08:00
|
|
|
systemd.services.monit = {
|
2016-09-12 07:31:18 -07:00
|
|
|
description = "Pro-active monitoring utility for unix systems";
|
|
|
|
after = [ "network.target" ];
|
2016-01-05 22:50:18 -08:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-09-12 07:31:18 -07:00
|
|
|
serviceConfig = {
|
2017-09-27 15:20:14 -07:00
|
|
|
ExecStart = "${pkgs.monit}/bin/monit -I -c /etc/monitrc";
|
|
|
|
ExecStop = "${pkgs.monit}/bin/monit -c /etc/monitrc quit";
|
|
|
|
ExecReload = "${pkgs.monit}/bin/monit -c /etc/monitrc reload";
|
2016-09-12 07:31:18 -07:00
|
|
|
KillMode = "process";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
2019-08-13 14:52:01 -07:00
|
|
|
restartTriggers = [ config.environment.etc.monitrc.source ];
|
2009-11-18 00:39:10 -08:00
|
|
|
};
|
2018-03-28 14:45:57 -07:00
|
|
|
|
2009-11-18 00:39:10 -08:00
|
|
|
};
|
|
|
|
}
|