summaryrefslogtreecommitdiffstats
path: root/lass/2configs/monitoring/monit-alarms.nix
blob: 9333ef9d2511f605c8bac8da0621d965c5ad076b (plain)
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
43
44
45
46
47
48
{pkgs, config, ...}:
with import <stockholm/lib>;
let
  echoToIrc = msg:
    pkgs.writeDash "echo_irc" ''
      set -euf
      export LOGNAME=prism-alarm
      ${pkgs.irc-announce}/bin/irc-announce \
        ni.r 6667 ${config.networking.hostName}-alarm \#noise "${msg}" >/dev/null
    '';

in {
  krebs.monit = {
    enable = true;
    http.enable = true;
    alarms = {
      nirwanabluete = {
        test = "${pkgs.curl}/bin/curl -sf 'https://nirwanabluete.de/'";
        alarm = echoToIrc "test nirwanabluete failed";
      };
      ubik = {
        test = "${pkgs.curl}/bin/curl -sf 'https://ubikmedia.de'";
        alarm = echoToIrc "test ubik failed";
      };
      hfos = {
        test = "${pkgs.curl}/bin/curl -sf --insecure 'https://hfos.hackerfleet.de'";
        alarm = echoToIrc "test hfos failed";
      };
      cac-panel = {
        test = "${pkgs.curl}/bin/curl -sf 'https://panel.cloudatcost.com/login.php'";
        alarm = echoToIrc "test cac-panel failed";
      };
      radio = {
        test = pkgs.writeBash "check_stream" ''
          ${pkgs.curl}/bin/curl -sif http://lassul.us:8000/radio.ogg \
          | ${pkgs.gawk}/bin/awk '/^\r$/{exit}{print $0}' \
          | ${pkgs.gnugrep}/bin/grep -q "200 OK" || exit "''${PIPESTATUS[0]}"
        '';
        alarm = echoToIrc "test radio failed";
      };
    };
  };

  krebs.iptables.tables.filter.INPUT.rules = [
    { predicate = "-p tcp -i retiolum --dport 9093"; target = "ACCEPT"; }
  ];
}