at 16.09-beta 971 B 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 = "Monit system watcher"; 40 after = [ "network-interfaces.target" ]; 41 wantedBy = [ "multi-user.target" ]; 42 script = "${pkgs.monit}/bin/monit -I -c /etc/monit.conf"; 43 serviceConfig.Restart = "always"; 44 }; 45 }; 46}