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