2009-11-18 08:39:10 +00:00
|
|
|
# Monit system watcher
|
|
|
|
# http://mmonit.org/monit/
|
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
{config, pkgs, lib, ...}:
|
2009-11-18 08:39:10 +00:00
|
|
|
|
2014-05-05 19:58:51 +01:00
|
|
|
let inherit (lib) mkOption mkIf;
|
2009-11-18 08:39:10 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.monit = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to run Monit system watcher.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
config = mkOption {
|
|
|
|
default = "";
|
2017-09-27 23:20:14 +01:00
|
|
|
description = "monitrc content";
|
2009-11-18 08:39:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2009-11-18 09:30:38 +00:00
|
|
|
config = mkIf config.services.monit.enable {
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2017-09-27 23:20:14 +01:00
|
|
|
environment.systemPackages = [ pkgs.monit ];
|
|
|
|
|
2009-11-18 08:39:10 +00:00
|
|
|
environment.etc = [
|
|
|
|
{
|
|
|
|
source = pkgs.writeTextFile {
|
2017-09-27 23:20:14 +01:00
|
|
|
name = "monitrc";
|
2009-11-18 08:39:10 +00:00
|
|
|
text = config.services.monit.config;
|
|
|
|
};
|
2017-09-27 23:20:14 +01:00
|
|
|
target = "monitrc";
|
2009-11-18 08:39:10 +00:00
|
|
|
mode = "0400";
|
|
|
|
}
|
|
|
|
];
|
2011-09-14 19:20:50 +01:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services.monit = {
|
2016-09-12 15:31:18 +01:00
|
|
|
description = "Pro-active monitoring utility for unix systems";
|
|
|
|
after = [ "network.target" ];
|
2016-01-06 06:50:18 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2016-09-12 15:31:18 +01:00
|
|
|
serviceConfig = {
|
2017-09-27 23:20:14 +01: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 15:31:18 +01:00
|
|
|
KillMode = "process";
|
|
|
|
Restart = "always";
|
|
|
|
};
|
2009-11-18 08:39:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|