at 18.03-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 = [ 30 { 31 source = pkgs.writeTextFile { 32 name = "monitrc"; 33 text = config.services.monit.config; 34 }; 35 target = "monitrc"; 36 mode = "0400"; 37 } 38 ]; 39 40 systemd.services.monit = { 41 description = "Pro-active monitoring utility for unix systems"; 42 after = [ "network.target" ]; 43 wantedBy = [ "multi-user.target" ]; 44 serviceConfig = { 45 ExecStart = "${pkgs.monit}/bin/monit -I -c /etc/monitrc"; 46 ExecStop = "${pkgs.monit}/bin/monit -c /etc/monitrc quit"; 47 ExecReload = "${pkgs.monit}/bin/monit -c /etc/monitrc reload"; 48 KillMode = "process"; 49 Restart = "always"; 50 }; 51 }; 52 }; 53}