- Python 67.3%
- JavaScript 32.7%
| .gitattributes | ||
| .gitignore | ||
| collection.toml | ||
| collector.py | ||
| database.py | ||
| errors.py | ||
| mirror-api.js | ||
| package-lock.json | ||
| package.json | ||
| parsers.py | ||
| README.md | ||
| trigger.py | ||
| viewdb.py | ||
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 = ""
collectorsis simply the list of available collectors. By default, this can containweb_server,lastupdate,health, andbandwidth.db_pathis the path to the database file.portis the port on which to run the API server.log_file_pathis for theweb_servercollector and should point to the current web server log file.mirror_drive_pathis the mount point for the volume that stores mirror data.lastupdatesis a list that should contain the paths to LASTUPDATE files, or individual mirrors' database files if lastupdates are not available.locationis the approximate latlong of the mirror, this will be autodetected if not filled.creation_dateis the date the mirror was first put online. the current date will be used if not filled.testingcan 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.