summary refs log tree commit diff stats
path: root/modules/monit.nix
blob: b4155eea47ccadd3a9292cb79cd2b0f9476a0b95 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ pkgs, libs, config, ... }:
{

  services.monit = {
    enable = true;
    config = ''
      set mailserver localhost port 25 username admin
      set alert mail@krinitsin.com

      set daemon 120 with start delay 60
      set mailserver
          localhost

      set httpd port 2812 and use address localhost
          allow localhost

      check filesystem root with path /
          if space usage > 80% then alert
          if inode usage > 80% then alert

      check system $HOST
          if cpu usage > 95% for 10 cycles then alert
          if memory usage > 75% for 5 cycles then alert
          if swap usage > 20% for 10 cycles then alert
          if loadavg (1min) > 90 for 15 cycles then alert
          if loadavg (5min) > 80 for 10 cycles then alert
          if loadavg (15min) > 70 for 8 cycles then alert

      check network network interface ens3
    '';
  };
  
  services.nginx.virtualHosts."status.krinitsin.com" = {
    forceSSL = true;
    useACMEHost = "krinitsin.com";
    basicAuthFile = "/secret/monit";
    locations."/".proxyPass = "http://localhost:2812";
  };

  security.acme.certs."krinitsin.com".extraDomainNames = [ "status.krinitsin.com" ];

}