iac/nixos/hosts/asxpio-ops/crawler.nix
Sergei Poljanski 35bc42b01b
All checks were successful
nixos / nixos (push) Successful in 21s
crawler: use the tool's own flake instead of a copy of the script
crawler-alert.py was a byte-identical copy of the one in
asxpi/traefik-crawlers-statistics. That repository now has a package and
a NixOS module with the same three units and timers; iac takes it as a
flake input and keeps only the settings. The package also puts dig on
the script's path, which the Meta ASN check needs and lacked here.

Assisted-by: Claude:opus-5-5
2026-11-17 12:00:16 +04:00

30 lines
1.2 KiB
Nix

# Crawler watch for Forgejo: separates real AI crawlers from traffic that
# only claims to be one, from Traefik's access log. A daily mail when
# yesterday crossed the threshold, a weekly summary, and metrics every
# five minutes for the Crawlers dashboard. The tool and its units are
# asxpi/traefik-crawlers-statistics (flake input crawler-alert).
{ config, ... }:
{
services.crawler-alert = {
enable = true;
environment = {
CRAWLER_SITE = "git.asxp.io";
CRAWLER_THRESHOLD = "100000";
CRAWLER_ROBOTS = "https://git.czsk.it/robots.txt";
CRAWLER_LOG = "/var/log/traefik/access.log*";
CRAWLER_LIVE_LOG = "/var/log/traefik/access.log";
CRAWLER_ROUTER = "forgejo@file";
CRAWLER_TEXTFILE = "/var/lib/node_exporter/textfile/crawler.prom";
CRAWLER_SMTP_ADDR = "smtp.fastmail.com";
CRAWLER_SMTP_PORT = "587";
CRAWLER_SMTP_FROM = "Czechoslovakia Git <noreply@asxp.io>";
};
environmentFile = config.sops.templates."crawler.env".path;
};
sops.templates."crawler.env".content = ''
CRAWLER_RECIPIENT=${config.sops.placeholder."alert/recipient"}
CRAWLER_SMTP_USER=${config.sops.placeholder."alert/smtp_user"}
CRAWLER_SMTP_PASSWORD=${config.sops.placeholder."alert/smtp_password"}
'';
}