2009-11-18 08:39:10 +00:00
|
|
|
# Monit system watcher
|
|
|
|
# http://mmonit.org/monit/
|
|
|
|
|
2014-05-05 18:58:51 +00:00
|
|
|
{config, pkgs, lib, ...}:
|
2009-11-18 08:39:10 +00:00
|
|
|
|
2014-05-05 18:58:51 +00: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 = "";
|
|
|
|
description = "monit.conf content";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-11-18 09:30:38 +00:00
|
|
|
config = mkIf config.services.monit.enable {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-11-18 08:39:10 +00:00
|
|
|
environment.etc = [
|
|
|
|
{
|
|
|
|
source = pkgs.writeTextFile {
|
|
|
|
name = "monit.conf";
|
|
|
|
text = config.services.monit.config;
|
|
|
|
};
|
|
|
|
target = "monit.conf";
|
|
|
|
mode = "0400";
|
|
|
|
}
|
|
|
|
];
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services.monit = {
|
2009-11-18 08:39:10 +00:00
|
|
|
description = "Monit system watcher";
|
2016-01-06 06:50:18 +00:00
|
|
|
after = [ "network-interfaces.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
script = "${pkgs.monit}/bin/monit -I -c /etc/monit.conf";
|
|
|
|
serviceConfig.Restart = "always";
|
2009-11-18 08:39:10 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|