1 { config, pkgs, lib, name, ... }:
3 myplugins = pkgs.runCommand "buildplugins" {
4 buildInputs = [ pkgs.makeWrapper pkgs.perl ];
7 cp ${./plugins}/* $out/
9 wrapProgram $out/check_command --prefix PATH : ${config.security.wrapperDir}
10 wrapProgram $out/send_nrdp.sh --prefix PATH : ${lib.makeBinPath [
13 wrapProgram $out/check_mem.sh --prefix PATH : ${lib.makeBinPath [
14 pkgs.gnugrep pkgs.gawk pkgs.procps-ng
16 wrapProgram $out/check_postgres_replication --prefix PATH : ${lib.makeBinPath [
19 wrapProgram $out/check_redis_replication --prefix PATH : ${lib.makeBinPath [
20 pkgs.gnugrep pkgs.coreutils pkgs.redis
22 wrapProgram $out/check_mysql_replication --prefix PATH : ${lib.makeBinPath [
23 pkgs.gnugrep pkgs.gnused pkgs.coreutils pkgs.mariadb
25 wrapProgram $out/check_openldap_replication --prefix PATH : ${lib.makeBinPath [
26 pkgs.gnugrep pkgs.gnused pkgs.coreutils pkgs.openldap
29 toObjects = pkgs.callPackage ./to_objects.nix {};
32 processWarn = "250"; processAlert = "400";
33 loadWarn = "8.0"; loadAlert = "10.0";
36 processWarn = "50"; processAlert = "60";
37 loadWarn = "1.0"; loadAlert = "2.0";
40 commonObjects = pkgs.callPackage ./objects_common.nix ({
41 hostFQDN = config.hostEnv.FQDN;
42 sudo = "/run/wrappers/bin/sudo";
43 } // builtins.getAttr name commonConfig);
46 specific_file = ./. + "/objects_" + name + ".nix";
48 lib.attrsets.optionalAttrs (builtins.pathExists specific_file) (pkgs.callPackage specific_file { inherit config; });
52 myServices.monitoring = {
53 enable = lib.mkOption {
54 type = lib.types.bool;
57 Whether to enable monitoring.
63 config = lib.mkIf config.myServices.monitoring.enable {
64 services.duplyBackup.profiles.monitoring = {
65 rootDir = config.services.naemon.varDir;
67 security.sudo.extraRules = [
70 { command = "${pkgs.mdadm}/bin/mdadm --monitor --scan -1"; options = [ "NOPASSWD" ]; }
71 { command = "${pkgs.postfix}/bin/mailq"; options = [ "NOPASSWD" ]; }
78 { command = "${myplugins}/check_last_file_date /backup2/*"; options = [ "NOPASSWD" ]; }
85 { command = "${myplugins}/check_postgres_replication *"; options = [ "NOPASSWD" ]; }
92 { command = "${myplugins}/check_mysql_replication *"; options = [ "NOPASSWD" ]; }
99 { command = "${myplugins}/check_openldap_replication *"; options = [ "NOPASSWD" ]; }
101 users = [ "naemon" ];
106 { command = "${myplugins}/check_redis_replication *"; options = [ "NOPASSWD" ]; }
108 users = [ "naemon" ];
112 environment.etc."mdadm.conf" = {
116 text = "MAILADDR ${config.myEnv.monitoring.email}";
119 # needed since extraResource is not in the closure
120 systemd.services.naemon.path = [ myplugins ];
124 broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live
128 admin_email=${config.myEnv.monitoring.email}
130 obsess_over_services=1
131 ocsp_command=notify-master
135 $USER200$=${config.myEnv.monitoring.status_url}
136 $USER201$=${config.myEnv.monitoring.status_token}
138 objectDefs = toObjects commonObjects + toObjects hostObjects;