mirror dashboard a level project built on behalf of c48.uk: backend
  • Python 67.3%
  • JavaScript 32.7%
Find a file
2026-11-19 13:49:38 +00:00
.gitattributes chore: init repository 2026-10-23 14:47:27 +01:00
.gitignore feat(collector): add constants and lastupdates 2026-11-06 12:07:40 +00:00
collection.toml feat(mirror-api): write averages for requests per asn and http bandwidth 2026-11-13 14:44:06 +00:00
collector.py feat(parsers): aggregate user agents based on signals 2026-11-12 09:42:23 +00:00
database.py fix(database): use simpler date format without ms 2026-11-17 10:17:39 +00:00
errors.py chore: improve comments / documentation 2026-11-09 14:52:58 +00:00
mirror-api.js chore(mirror-api): improve comments and update docs 2026-11-19 13:49:38 +00:00
package-lock.json chore: begin component 2 with boilerplate 2026-11-11 10:38:37 +00:00
package.json chore: begin component 2 with boilerplate 2026-11-11 10:38:37 +00:00
parsers.py fix: bruhy mcBruhFace 2026-11-12 09:47:31 +00:00
README.md chore(mirror-api): improve comments and update docs 2026-11-19 13:49:38 +00:00
trigger.py chore: improve comments / documentation 2026-11-09 14:52:58 +00:00
viewdb.py chore: improve comments / documentation 2026-11-09 14:52:58 +00:00

mirror dashboard backend

setup

The default included configuration file looks like this:

collectors = ["web_server", "lastupdate", "health", "bandwidth"]
db_path = "./metrics.db"
port = 3000
testing = false

# collector-specific
log_file_path = "/var/log/nginx/access.log"
mirror_drive_path = "/"
lastupdates = [""]
location = ""
creation_date = ""
  • collectors is simply the list of available collectors. By default, this can contain web_server, lastupdate, health, and bandwidth.
  • db_path is the path to the database file.
  • port is the port on which to run the API server.
  • log_file_path is for the web_server collector and should point to the current web server log file.
  • mirror_drive_path is the mount point for the volume that stores mirror data.
  • lastupdates is a list that should contain the paths to LASTUPDATE files, or individual mirrors' database files if lastupdates are not available.
  • location is the approximate latlong of the mirror, this will be autodetected if not filled.
  • creation_date is the date the mirror was first put online. the current date will be used if not filled.
  • testing can be set to true to see a more verbose output, useful if something is going wrong.

The web server collector depends on the iptoasn database. This can be downloaded from iptoasn.com:

wcurl https://iptoasn.com/data/ip2asn-combined.tsv.gz

Please also note that web server logs have to be in the default Apache/nginx format to be correctly parsed. This is:

2001:db8:: - - [02/Nov/2026:00:07:28 +0000] "GET /chaotic/chaotic-aur/x86_64/chaotic-aur.db HTTP/2.0" 304 0 "-" "pacman/7.1.0 (Linux x86_64) libalpm/16.0.1"

If you are using Caddy, extra configuration may be needed.

The collection system assumes you run collect on 15 minute intervals. This can be done with systemd timers or with cron. You will want to call /usr/bin/env python /path/to/mirror-backend/collect.py to run the collection. You can also run it manually to test.

Once you have sorted collection, you will want to install npm dependencies. Run npm ci and run node mirror-api.js to start the API server. You can then visit http://localhost:3000 (or whatever port you chose) to see the dashboard.

For production use, you will want to run the API server in the background. You can use pm2 process manager for this or any other process manager of your choice. You will also want to run it behind a reverse proxy (nginx etc).

viewdb

The included viewdb.py script will simply dump all output to terminal. If you suspect data isn't being saved, or other issues, then this can be a useful tool.