mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 05:36:59 +01:00
Configure Monit on all hosts
This commit is contained in:
parent
8d31683aa0
commit
5f36ab8644
6 changed files with 110 additions and 20 deletions
|
|
@ -9,6 +9,7 @@
|
|||
../modules/synapse.nix
|
||||
../modules/nextcloud.nix
|
||||
../modules/custom-backup-job.nix
|
||||
../modules/custom-monit.nix
|
||||
../modules/dokuwiki.nix
|
||||
../modules/website-marie.nix
|
||||
];
|
||||
|
|
@ -22,12 +23,35 @@
|
|||
|
||||
services.custom-backup-job = {
|
||||
additionalPaths = [ "/var/lib/nextcloud/config" ];
|
||||
readWritePaths = [ "/nix/var/data/murmur" ];
|
||||
preHook = "cp /var/lib/murmur/murmur.sqlite /nix/var/data/murmur/murmur.sqlite";
|
||||
readWritePaths = [ "/nix/var/data/murmur" "/nix/var/data/backup/" ];
|
||||
preHook = ''
|
||||
cp /var/lib/murmur/murmur.sqlite /nix/var/data/murmur/murmur.sqlite
|
||||
'';
|
||||
postHook = ''
|
||||
touch /nix/var/data/backup/backup-ok
|
||||
'';
|
||||
startAt = "03:30";
|
||||
sshKey = config.sops.secrets.borgSshKey.path;
|
||||
};
|
||||
|
||||
services.custom-monit.additionalConfig = ''
|
||||
check file nextcloud-data-mounted with path /var/lib/nextcloud/data/index.html
|
||||
start = "${pkgs.systemd}/bin/systemctl start nextcloud-data-sshfs.service"
|
||||
|
||||
check host jellyfin with address jellyfin.banditlair.com
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
check host stb with address www.societe-de-tir-bertrix.com
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
|
||||
check host transmission with address transmission.banditlair.com
|
||||
if failed
|
||||
port 443
|
||||
protocol https
|
||||
status = 401
|
||||
with timeout 20 seconds
|
||||
then alert
|
||||
'';
|
||||
|
||||
networking.interfaces.enp1s0 = {
|
||||
useDHCP = true;
|
||||
ipv4 = {
|
||||
|
|
@ -43,19 +67,4 @@
|
|||
networking.firewall.allowedTCPPorts = [ 80 443 64738 ];
|
||||
networking.firewall.allowedUDPPorts = [ 64738 ];
|
||||
|
||||
services.monit = {
|
||||
enable = true;
|
||||
config = ''
|
||||
set daemon 30
|
||||
with start delay 90
|
||||
|
||||
set httpd
|
||||
port 2812
|
||||
use address 127.0.0.1
|
||||
allow localhost
|
||||
|
||||
check file nextcloud-data-mounted with path /var/lib/nextcloud/data/index.html
|
||||
start = "${pkgs.systemd}/bin/systemctl start nextcloud-data-sshfs.service"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
../modules/openssh.nix
|
||||
../modules/postgresql.nix
|
||||
../modules/custom-backup-job.nix
|
||||
../modules/custom-monit.nix
|
||||
];
|
||||
|
||||
networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ 5432 ];
|
||||
|
|
@ -18,11 +19,12 @@
|
|||
};
|
||||
|
||||
services.custom-backup-job = {
|
||||
readWritePaths = [ "/nix/var/data/postgresql" ];
|
||||
readWritePaths = [ "/nix/var/data/postgresql" "/nix/var/data/backup/" ];
|
||||
preHook = ''
|
||||
${pkgs.postgresql_12}/bin/pg_dump -U synapse synapse > /nix/var/data/postgresql/synapse.dmp
|
||||
${pkgs.postgresql_12}/bin/pg_dump -U nextcloud nextcloud > /nix/var/data/postgresql/nextcloud.dmp
|
||||
'';
|
||||
postHook = "touch /nix/var/data/backup/backup-ok";
|
||||
startAt = "03:00";
|
||||
sshKey = config.sops.secrets.borgSshKey.path;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
../modules/monero.nix
|
||||
../modules/torrents.nix
|
||||
../modules/custom-backup-job.nix
|
||||
../modules/custom-monit.nix
|
||||
];
|
||||
|
||||
sops.secrets = {
|
||||
|
|
@ -45,7 +46,19 @@
|
|||
services.custom-backup-job = {
|
||||
readWritePaths = [ "/nix/var/data/backup" ];
|
||||
preHook = "${pkgs.docker}/bin/docker exec stb-mariadb sh -c 'mysqldump -u stb -pstb stb' > /nix/var/data/backup/stb_mariadb.sql";
|
||||
postHook = "touch /nix/var/data/backup/backup-ok";
|
||||
startAt = "04:00";
|
||||
sshKey = config.sops.secrets.borgSshKey.path;
|
||||
};
|
||||
|
||||
services.custom-monit.additionalConfig = ''
|
||||
check host nextcloud with address cloud.banditlair.com
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
check host anderia-wiki with address anderia.banditlair.com
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
check host arkadia-wiki with address arkadia.banditlair.com
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
check host website-marie with address osteopathie.froidmont.org
|
||||
if failed port 443 protocol https with timeout 20 seconds then alert
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue