2020-09-14 09:11:58 +00:00
|
|
|
{ lib,... }:
|
2019-11-25 07:48:14 +00:00
|
|
|
let
|
2020-09-14 09:11:58 +00:00
|
|
|
disk_free_threshold = "10"; # at least this much free disk percentage
|
|
|
|
in {
|
|
|
|
services.prometheus.rules = [(builtins.toJSON
|
|
|
|
{
|
|
|
|
groups = [
|
|
|
|
{ name = "shack-env";
|
|
|
|
rules = [
|
|
|
|
{
|
|
|
|
alert = "RootPartitionFull";
|
|
|
|
for = "30m";
|
2020-09-14 09:42:32 +00:00
|
|
|
expr = ''(node_filesystem_avail_bytes{alias="wolf.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="wolf.shack",mountpoint="/"} < ${disk_free_threshold}'';
|
2020-09-14 09:11:58 +00:00
|
|
|
labels.severity = "warning";
|
|
|
|
annotations.summary = "{{ $labels.alias }} root disk full";
|
2020-09-14 13:45:37 +00:00
|
|
|
annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=wolf";
|
2021-04-20 07:06:52 +00:00
|
|
|
annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%). CI for deploying new configuration will seize working. Log in to the system and try to clean up the obsolete files on the machine. There are a couple of things you can do:
|
|
|
|
1. `nix-collect-garbage -d`
|
|
|
|
2. clean up the shack share folder in `/home/share`
|
|
|
|
3. check `du -hs /var/ | sort -h`.
|
|
|
|
4. run `docker system prune`
|
|
|
|
5. `find /var/lib/containers/news/var/lib/htgen-go/items -mtime +7 -delete;` to clean up the link shortener data
|
|
|
|
5. If you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete
|
|
|
|
6. as a last resort the root disk can be expanded via `lvresize -L +10G /dev/pool/root && btrfs filesystem resize max /` '';
|
2020-09-14 09:11:58 +00:00
|
|
|
}
|
|
|
|
{
|
|
|
|
alert = "RootPartitionFull";
|
|
|
|
for = "30m";
|
2020-09-14 09:42:32 +00:00
|
|
|
expr = ''(node_filesystem_avail_bytes{alias="puyak.shack",mountpoint="/"} * 100) / node_filesystem_size_bytes{alias="puyak.shack",mountpoint="/"} < ${disk_free_threshold}'';
|
2020-09-14 09:11:58 +00:00
|
|
|
labels.severity = "warning";
|
|
|
|
annotations.summary = "{{ $labels.alias }} root disk full";
|
2020-09-14 13:45:37 +00:00
|
|
|
annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=puyak";
|
2020-09-14 09:11:58 +00:00
|
|
|
annotations.description = ''The root disk of {{ $labels.alias }} has {{ $value | printf "%.2f" }}% free disk space (Threshold at ${disk_free_threshold}%).Prometheus will not be able to create new alerts and CI for deploying new configuration will also seize working. Log in to the system and run `nix-collect-garbage -d` and if this does not help you can check `du -hs /var/ | sort -h`, run `docker system prune` or if you are really desperate run `du -hs / | sort -h` and go through the folders recursively until you've found something to delete'';
|
|
|
|
}
|
2020-12-16 15:10:08 +00:00
|
|
|
# wolf.shack is not worth supervising anymore
|
2020-09-14 09:11:58 +00:00
|
|
|
{
|
|
|
|
alert = "HostDown";
|
2020-12-16 15:10:08 +00:00
|
|
|
expr = ''up{alias="infra01.shack"} == 0'';
|
2020-09-14 09:11:58 +00:00
|
|
|
for = "5m";
|
|
|
|
labels.severity = "page";
|
|
|
|
annotations.summary = "Instance {{ $labels.alias }} down for 5 minutes";
|
2020-09-14 13:45:37 +00:00
|
|
|
annotations.url = "http://grafana.shack/d/hb7fSE0Zz/shack-system-dashboard?orgId=1&var-job=node&var-hostname=All&var-node=wolf.shack:9100&var-device=All&var-maxmount=%2F&var-show_hostname=wolf";
|
2020-12-16 15:10:08 +00:00
|
|
|
annotations.description = ''Host {{ $labels.alias }} went down and has not been reconnected after 5 minutes. This is probably bad news, as the machine runs one of the DNS servers and the power broadcast proxy which is used to be able to turn off the light via puyak as well as the shutdown listener.'';
|
2020-09-14 09:11:58 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)];
|
2019-11-25 07:48:14 +00:00
|
|
|
}
|