2009-11-18 09:39:10 +01:00
|
|
|
# Monit system watcher
|
|
|
|
# http://mmonit.org/monit/
|
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
{config, pkgs, lib, ...}:
|
2009-11-18 09:39:10 +01:00
|
|
|
|
2014-05-05 20:58:51 +02:00
|
|
|
let inherit (lib) mkOption mkIf;
|
2009-11-18 09:39:10 +01: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 20:20:50 +02:00
|
|
|
|
2009-11-18 10:30:38 +01:00
|
|
|
config = mkIf config.services.monit.enable {
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2009-11-18 09:39:10 +01:00
|
|
|
environment.etc = [
|
|
|
|
{
|
|
|
|
source = pkgs.writeTextFile {
|
|
|
|
name = "monit.conf";
|
|
|
|
text = config.services.monit.config;
|
|
|
|
};
|
|
|
|
target = "monit.conf";
|
|
|
|
mode = "0400";
|
|
|
|
}
|
|
|
|
];
|
2011-09-14 20:20:50 +02:00
|
|
|
|
2016-01-06 07:50:18 +01:00
|
|
|
systemd.services.monit = {
|
2009-11-18 09:39:10 +01:00
|
|
|
description = "Monit system watcher";
|
2016-01-06 07:50:18 +01: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 09:39:10 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|