diff --git a/modules/module-list.nix b/modules/module-list.nix index a25857f2a9a..c9b414ca420 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -56,6 +56,7 @@ ./services/misc/nixos-manual.nix ./services/misc/rogue.nix ./services/misc/synergy.nix + ./services/monitoring/monit.nix ./services/monitoring/nagios/default.nix ./services/monitoring/zabbix-agent.nix ./services/monitoring/zabbix-server.nix diff --git a/modules/services/monitoring/monit.nix b/modules/services/monitoring/monit.nix new file mode 100644 index 00000000000..216c57411af --- /dev/null +++ b/modules/services/monitoring/monit.nix @@ -0,0 +1,51 @@ +# Monit system watcher +# http://mmonit.org/monit/ + +{config, pkgs, ...}: + +let inherit (pkgs.lib) mkOption; +in + +{ + options = { + services.monit = { + enable = mkOption { + default = false; + description = '' + Whether to run Monit system watcher. + ''; + }; + config = mkOption { + default = ""; + description = "monit.conf content"; + }; + startOn = mkOption { + default = "networking/started"; + description = "What Monit supposes to be already present"; + }; + }; + }; + + config = { + environment.etc = [ + { + source = pkgs.writeTextFile { + name = "monit.conf"; + text = config.services.monit.config; + }; + target = "monit.conf"; + mode = "0400"; + } + ]; + jobs.monit = { + description = "Monit system watcher"; + + startOn = config.services.monit.startOn; + stopOn = "shutdown"; + + exec = "${pkgs.monit}/bin/monit -I -c /etc/monit.conf"; + + respawn = true; + }; + }; +}