at 18.09-beta 1.2 kB view raw
1# Monit system watcher 2# http://mmonit.org/monit/ 3 4{config, pkgs, lib, ...}: 5 6let inherit (lib) mkOption mkIf; 7in 8 9{ 10 options = { 11 services.monit = { 12 enable = mkOption { 13 default = false; 14 description = '' 15 Whether to run Monit system watcher. 16 ''; 17 }; 18 config = mkOption { 19 default = ""; 20 description = "monitrc content"; 21 }; 22 }; 23 }; 24 25 config = mkIf config.services.monit.enable { 26 27 environment.systemPackages = [ pkgs.monit ]; 28 29 environment.etc."monitrc" = { 30 text = config.services.monit.config; 31 mode = "0400"; 32 }; 33 34 systemd.services.monit = { 35 description = "Pro-active monitoring utility for unix systems"; 36 after = [ "network.target" ]; 37 wantedBy = [ "multi-user.target" ]; 38 serviceConfig = { 39 ExecStart = "${pkgs.monit}/bin/monit -I -c /etc/monitrc"; 40 ExecStop = "${pkgs.monit}/bin/monit -c /etc/monitrc quit"; 41 ExecReload = "${pkgs.monit}/bin/monit -c /etc/monitrc reload"; 42 KillMode = "process"; 43 Restart = "always"; 44 }; 45 restartTriggers = [ config.environment.etc."monitrc".source ]; 46 }; 47 48 }; 49}