Skip to content

About

AIS-catcher Statistics lite in PHP/MariaDB

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

AISSeaStats

Long-term statistics for your AIS-catcher station — the SkyStats idea, for ships.

AIS-catcher already shows a live map. AISSeaStats keeps the history and turns it into one simple page:

  • Vessels seen per hour, day and month, split by distance (under 20 NM, 20–50 NM, beyond); click a bar to list them, each with its distance band
  • Propagation days flagged when the station hears much further than usual (tropospheric ducting), and the furthest vessels
  • Top routes, inferred from where each vessel enters and leaves your coverage, drawn on a map along their most typical real track (rivers and fairways included)
  • Traffic density: a heatmap of where vessels sail (shipping lanes, fairways, ports), over any period, with the station's range by direction drawn on top
  • Top vessels by passages, days seen, length, speed and distance, 10 to 100 per page
  • Interesting vessels: military, authorities and rescue, superyachts, dangerous goods, very large ships, rare flags, your own watch list; click a tag to list only those
  • Fleet by type and flag, and range by direction, with the vessel and time of each record
  • Regulars: vessels that come back most regularly, and the time between passages on each vessel card
  • Busiest hours: average traffic by weekday and hour
  • Station reception: hour-by-hour strip, share of hours with messages and interruptions
  • A vessel card on click: photo (your own, or Wikimedia Commons), identity, size, first and last seen, recent passages, track, links to aiscatcher.org, VesselFinder and ShipSpotting
  • Constellation: where the vessels say they are going (destinations and vessel types as glossy bubbles), and the network of ports they link
  • Records: furthest reception, largest, fastest, rarest flag, busiest day, longest stay, first vessel
  • Signal and distance: mean signal level by distance and direction, to tune the antenna
  • Alerts when your station stops receiving, vessel alerts (watch list, military, distress, range record…) and daily or weekly summaries: ntfy, Telegram, webhook, e-mail or MQTT
  • Home Assistant sensors through MQTT, discovered automatically

French and English, light and dark themes, works on a phone. Runs next to AIS-catcher on a Raspberry Pi.

Français : voir docs/README.fr.md.

Statistics page: key figures, vessels seen per hour, top routes and declared destinations

Vessel card with identity, track on the map and recent passages Top vessels, fleet by type and flag, range by direction

Constellation: destinations declared by the vessels around the station, with their vessel types Constellation, ports view: ports linked by the vessels' destination changes, arrows in the direction of travel

Regulars, busiest hours by weekday and hour, and station reception hour by hour (dark theme)

Vessels seen per day, split by distance band, on a phone (French interface) Range by direction and furthest vessels with day and direction, on a phone (French interface)

How it works

flowchart LR
    A["AIS-catcher"] -- "HTTP POST JSON, every 15 s" --> B["ingest.php"]
    B --> C[("MariaDB")]
    W["worker"] --> C
    C --> E["api.php"] --> F["Browser"]
Loading

AIS-catcher's built-in HTTP output (-H) posts decoded messages. AISSeaStats does not store every message: it updates counters, one sampled position per vessel per minute (kept 30 days by default), passages and range records. A year of statistics stays well under 1 GB.

Requirements

Minimum Recommended
Host 64-bit Linux: Raspberry Pi 4 or 5 with Raspberry Pi OS 64-bit, or any amd64 machine Pi 4 (2 GB+) or Pi 5
Memory available 512 MB 1 GB
Free disk space 1 GB 2 GB, ideally on an SSD rather than the SD card
Docker Docker Engine with the Compose plugin (docker compose) latest stable
AIS-catcher 0.29 or newer, reachable over the network latest

32-bit systems (armv7l, armv6l) are not supported: the official MariaDB image is 64-bit only.

Check before installing:

uname -m                  # must print aarch64 or x86_64
docker compose version    # must print a version
free -h                   # "available" column
df -h .                   # "Avail" column

No Docker yet? curl -fsSL https://get.docker.com | sh, then sudo usermod -aG docker $USER and log in again.

install.sh runs these checks itself and stops with a clear message if something is missing.

Install (Docker)

git clone https://github.com/Crchlnn/AISSeaStats.git
cd AISSeaStats
./install.sh

install.sh downloads the ready-made image (64-bit Raspberry Pi and PC, about a minute), creates .env with random database passwords and starts three containers: db (MariaDB 11), app (lighttpd + PHP-FPM) and worker (background jobs). If the image cannot be downloaded, it builds it on your machine instead.

Prefer to build the image yourself? ./install.sh --build. Allow 5 to 10 minutes on a Raspberry Pi (about 6.5 minutes measured on a Pi 4), 1 to 2 minutes on a PC: PHP extensions are compiled once. Both ways give the same result and can be switched at any time (see Upgrade).

Then open http://<pi-address>:8095 and the setup wizard asks for:

  1. the setup code shown at the end of install.sh (also in docker compose logs app, or with docker compose exec app php bin/setup-code.php): only the person running the server can become admin,
  2. the station name and antenna position (used for distances and range, never sent anywhere),
  3. the time zone and language,
  4. an admin password.

If AIS-catcher runs in managed mode, the wizard can pre-fill the name and position from its config.json (read in your browser, never uploaded). It then shows your ingestion token and how to fill AIS-catcher's HTTP output.

Without Git, with the ready-made image only:

mkdir aisseastats && cd aisseastats
curl -fsSLO https://raw.githubusercontent.com/Crchlnn/AISSeaStats/main/docker-compose.yml
curl -fsSL https://raw.githubusercontent.com/Crchlnn/AISSeaStats/main/.env.example -o .env
nano .env                  # set DB_PASSWORD and DB_ROOT_PASSWORD to long random values
docker compose up -d
docker compose exec app php bin/setup-code.php   # the code asked by the setup wizard

Manual alternative from the cloned folder: cp .env.example .env, edit the passwords, then docker compose up -d (ready-made image) or docker compose up -d --build (built here).

Ready-made image

ghcr.io/crchlnn/aisseastats, for linux/arm64 (Raspberry Pi 4/5 with a 64-bit OS) and linux/amd64, published automatically by GitHub Actions for each release:

Tag Follows
latest the latest release (default)
1 every 1.x release, new features included (1.2.0, 1.3.0…), never a 2.0
1.1 bug fixes of 1.1 only (1.1.2, 1.1.3…)
1.1.2 exactly this version
1.2.0-beta.1 a test version: only this exact tag, never latest, 1 or 1.2

To pin a tag, set AISSEASTATS_VERSION=1.1 (for example) in .env. Database changes are applied when the container starts, so an automatic updater (Watchtower or similar) that pulls a new image and restarts the app and worker containers keeps working with your data. Updates then install without you looking: keep a backup (see Everyday commands), or pin a tag to choose when to move on.

Connect AIS-catcher

Managed mode (web interface)

In AIS-catcher: Output → HTTP → add an output, then:

AIS-catcher field Value
Description anything, e.g. AISSeaStats
Link empty
URL http://<pi-address>:8095/ingest.php
Interval 15
ID optional: station name, shown in the ingestion log
Credentials aisseastats:<token>
Protocol AISCATCHER (the default)
Gzip on
Response either way (on shows AISSeaStats' reply in the AIS-catcher log)
Unique / Downsample Position off

Keep Active on and save with the floppy-disk icon at the top right: while "You have unsaved changes" shows, nothing is applied.

Command line or service

Add these options to your existing AIS-catcher command (do not run the line on its own):

-M DTM -H http://<pi-address>:8095/ingest.php interval 15 gzip on userpwd aisseastats:<token> id MyStation

-M DTM adds signal level, reception time and flag country to each message. Field reference: AIS-catcher JSON decoding. Without it, the flag is derived from the MMSI and signal levels are not recorded.

Which address?

AIS-catcher usually runs in its own Docker container, so localhost and 127.0.0.1 point to that container, not to AISSeaStats. Use:

  • the Pi's IP address, e.g. http://192.168.1.20:8095/ingest.php, or
  • its name from your local DNS (Pi-hole, router), without .local, e.g. http://mypi:8095/ingest.php.

Names ending in .local (mDNS/Bonjour) usually work in a browser but not inside Docker containers.

The first figures appear within a minute. Routes appear once vessels have left your coverage for 2 hours.

Try it with demo data

docker compose exec app php bin/simulate.php --hours 72      # 72 h of fake traffic around your station
docker compose exec app php bin/reset-data.php --yes          # remove it before real use

Upgrade

Your statistics are kept: they live in the Docker volume aisseastats_db-data, and your settings in the database and in .env, none of which Git or the upgrade touch. Database changes are applied automatically when the app starts.

cd AISSeaStats                                    # the folder you installed from
git pull                                          # get the new version (docs, docker-compose.yml)
docker compose pull && docker compose up -d       # ready-made image: download and restart

or, to build the image on your machine as before:

cd AISSeaStats
git pull
docker compose up -d --build                      # rebuild and restart

Both ways can be used on the same station, one update with one, the next with the other: they give the image the same name and use the same data. An installation made before 1.1.2 built an image named aisseastats:local; it is no longer used and can be removed with docker image rm aisseastats:local.

Then reload the page (Ctrl+F5 / Cmd+Shift+R if the look did not change). Check the version at the bottom of the page and what changed in Version history.

  • Backup first, if you want to be safe (see the table below): an upgrade does not delete data, but a backup costs nothing.
  • git pull refuses to run ("your local changes would be overwritten"): you edited a tracked file. git stash, then git pull, then git stash pop if you want your change back; your data is not affected.
  • Going back to a previous version: set AISSEASTATS_VERSION=1.1.1 (for example) in .env and run docker compose pull && docker compose up -d, or git checkout v1.1.1 then docker compose up -d --build. Database changes are not rolled back, so prefer restoring a backup taken before the upgrade.
  • Only docker compose down -v deletes the data (the -v removes the volume).

Testing a beta. Test versions are published under their exact tag only, so latest users never get them. To try one: git fetch --tags && git checkout v1.2.0-beta.1, set AISSEASTATS_VERSION=1.2.0-beta.1 in .env, then docker compose pull && docker compose up -d (or docker compose up -d --build). Back to the releases: git checkout main && git pull, empty AISSEASTATS_VERSION, docker compose pull && docker compose up -d. A beta's database changes stay (they only add tables), so a backup first is a good idea.

Version history

Newest first. Details, fixes and database changes for each version: CHANGELOG.md (English) · docs/CHANGELOG.fr.md (français).

Version Date What's new
1.2.1 2026-11-13 Towboats and pushers no longer tagged "very large" (they declare the length of their convoy); known vessels in the admin match the page, with every transmitter by kind (base stations, aids to navigation by type…); Home Assistant: worker says "offline" when stopped, "unavailable" delay set in the admin (3 min by default), long-term statistics for the range record; dashboard example by @Phil353556
1.2.0 2026-10-27 Release of the 1.2.0 features, with testers' feedback: clickable tags to filter interesting vessels (issue #4), zoom in the constellation, UN/LOCODE port names on demand (NLRTM → Rotterdam), "FOR ORDERS" no longer a destination, plausible speeds only in the records, dark theme buttons readable, bin/reset-admin.php and Mosquitto set-up documented (issue #5)
1.2.0-beta.1 2026-10-23 Test version. Home Assistant sensors through MQTT; vessel alerts (watch list, military, distress, range record…) and daily or weekly summaries on ntfy, Telegram, webhook, e-mail or MQTT, with quiet hours and channels per kind; constellation of destinations and ports network; records; signal and distance; public address for links in alerts; hardening (database time limit on the public API, image checks, end-to-end test of the Docker stack, Exposing to the Internet)
1.1.6 2026-10-21 Security review fixes: login attempts limited, one-time setup code, photo look-ups only for received vessels, refused ingest posts no longer logged, strict INGEST_ALLOW, worker without root, option to round the published position, admin session timeout
1.1.5 2026-10-15 Top routes drawn along their most typical real track instead of a straight line (rivers, fairways), with arrows of the same size at every zoom; no minimum length for the admin password
1.1.4 2026-10-13 Traffic density map: range of the period and all-time range record drawn by direction, each one can be hidden; history after an update computed about 5 times faster, with its progress shown
1.1.3 2026-10-13 Fix: an AIS-catcher batch could be lost with MariaDB 11.8 ("Record has changed since last read", issue #2), now retried; traffic density heatmap under the routes map (issue #3)
1.1.2 2026-10-10 Ready-made image documented and used by default (docker compose pull), building it yourself still possible; Top vessels and Regulars: 10, 20, 50 or 100 per page with pages; vessel list of a chart bar: sort by distance and filter by distance band
1.1.1 2026-10-10 Vessel list of a chart bar: a coloured square for each vessel's distance band, its distance and the totals per band; range chart tooltip: vessel, date and time of each record; time of the record in the furthest vessels list
1.1.0 2026-10-10 Vessel chart split by distance band; exceptional propagation days and furthest vessels; Regulars and time between passages; busiest hours (weekday × hour); station reception strip
1.0.0-beta.8 2026-10-06 Debug capture also written to a dated JSON Lines file (contributed by @Phil353556); aiscatcher.org link on the vessel card instead of MarineTraffic, whose links no longer work
1.0.0-beta.7 2026-09-30 Debug capture of raw messages in the admin; explanation when a vessel's name has not been received; 30/90-day charts always show the whole period
1.0.0-beta.6 2026-09-30 Alerts when reception stops, and when it comes back: ntfy, Telegram, webhook (Discord, Slack, Gotify, Home Assistant…) and e-mail, with a test button; optional heartbeat URL to detect a station that is off; type of inland vessels from Inland AIS data; clearer database size in the admin
1.0.0-beta.5 2026-09-30 Destination dictionary in the admin (e.g. SAINT-MALO, ST-MALO, FR SML → FRSML); meaningless destinations (0, Q…) shown as Unknown; click a bar of the vessel chart to list its vessels; maximum range raised to 1,500 NM by default (tropospheric ducting), with far positions confirmed before they set a record
1.0.0-beta.4 2026-09-30 One period selector for the whole page, remembered; automatic refresh; click a type, flag, route or destination to list its vessels; readable fleet bars on phones; your own vessel photos, then Wikimedia Commons / Wikidata; setup pre-filled from AIS-catcher's config.json; fixes for map tiles "Access blocked" and empty charts
1.0.0-beta.3 2026-09-29 Flag derived from the MMSI; "rare flag" only once 100 vessels are known; clearer AIS-catcher instructions
1.0.0-beta.2 2026-09-29 Fix for "Invalid form token" in Docker; install time documented; memory and disk checks in install.sh
1.0.0-beta.1 2026-09-29 First test version

Everyday commands

Run the docker compose commands from the folder you installed from (the one with docker-compose.yml); elsewhere they answer "no configuration file provided". From any folder, use the container name instead: docker exec -it aisseastats-app-1 php bin/reset-admin.php (the name starts with the install folder's name, see docker ps).

Task Command
Upgrade (ready-made image) git pull && docker compose pull && docker compose up -d
Upgrade (build here) git pull && docker compose up -d --build
Logs docker compose logs -f app worker
Status docker compose ps
Lost admin password docker compose exec app php bin/reset-admin.php
Backup docker compose exec db sh -c 'mariadb-dump -u root -p"$MARIADB_ROOT_PASSWORD" aisseastats' | gzip > aisseastats.sql.gz
Restore a backup gunzip -c aisseastats.sql.gz | docker compose exec -T db sh -c 'mariadb -u root -p"$MARIADB_ROOT_PASSWORD" aisseastats'
Uninstall (keeps data) docker compose down
Uninstall and delete data docker compose down -v

Reading the statistics

  • Distance bands. Each vessel is counted once per hour, day or month, in the band of its furthest position: under 20 NM, 20–50 NM, 50 NM and beyond, or distance unknown (no position received, or hours recorded before 1.1.0).
  • Vessel list of a bar. Clicking a bar lists its vessels with a coloured square for their band (same colours as the chart) and their furthest distance; the totals per band at the top count the whole bar, even when the list stops at 300 vessels. Sort by messages (by name for an hour) or by distance; click a band to list only its vessels, click it again to see them all.
  • Range records. Hovering the range chart shows, for each 10° sector, the vessel that set the record and when. Records set before 1.1.1 get their time from the sampled positions when these are still kept (30 days); older ones show their day only.
  • Top routes. A route is the pair "zone where the vessel was first heard → zone where it was last heard" (compass sectors around the station, or your named zones). On the map, each route follows its most typical real track: among its 12 latest passages that still have positions (kept 30 days by default), the one closest on average to all the others. On a river it follows the bends; a detour or a bad position is not chosen. Without positions left for the period, the route is a straight line from the average entry point to the average exit point.
  • Traffic density. Each hour, every vessel seen in an area of about 1 km counts once in that area (vessel-hours): a lane used by many vessels stands out, a vessel moored all day counts once an hour. Base stations and aids to navigation are left out. The worker adds each hour about 5 minutes after it ends and keeps 400 days, so the map covers long periods too; after installing 1.1.3 it starts from the positions still kept (30 days by default), in about 3 minutes. The range of the period (solid line) and the all-time range record (dashed) are drawn by 10° sector over the heatmap, like the range chart; the box at the top right of the map hides either one.
  • Exceptional propagation. A day is flagged (orange triangle above the bar) when its range is at least twice the usual range (median of the 30 previous days), at least 20 NM more, and at least 3 vessels were heard beyond 1.5 × the usual range. Beyond the horizon, VHF reception depends on tropospheric ducting, which follows the weather: see the forecast on dxinfocentre.com.
  • Regulars. Time between passages is measured from the end of one passage to the start of the next (a passage ends after 2 hours without hearing the vessel). Vessels with at least 4 passages in the period are ranked by how steady that time is. A vessel moored at the edge of coverage, heard on and off, can count several short passages.
  • Busiest hours. Average number of vessels per hour, by weekday and hour in the station's time zone, over the period (at least 7 days). Hours without any message are left out, so an outage does not look like calm.
  • Constellation. Destinations: the station in the centre, the destinations declared by the vessels seen in the period around it (bubble size = number of vessels, spellings grouped with the destination dictionary; unknown and meaningless destinations left out), and their vessel types as small bubbles. Ports: when a vessel changes its declared destination, its old port is linked to the new one; arrows follow the direction of travel and their width is the number of vessels. This history is recorded since 1.2.0, so the view fills over a few weeks. Click a bubble or an arrow to list its vessels; hovering a destination also shows how crews wrote it ("written: NL RTM, ROTTERDAM"), and the dictionary of destinations gives it a name. Zoom with the + and − buttons, a double click, Ctrl + wheel or a pinch, then drag to move; names are then shown in full. "Show as a list" gives the same information as text.
  • Records. All-time records of the station, with the vessel and the date: furthest reception (same rule as the range chart), largest vessel, fastest (class A and B, up to 50 kn for high-speed craft and 40 kn for other vessels, so that corrupted speeds and aircraft are left out), rarest flag, busiest day (vessels), longest continuous presence (one passage), first vessel received.
  • Signal and distance. Mean signal level of the positions received, by 2 NM distance bins, over the period; pick a direction to compare it with the whole station. A healthy station shows a steady decrease with distance; a direction that drops early points to an obstacle or the antenna's pattern. The level comes from the signalpower field of the messages AIS-catcher sends; recorded since 1.2.0.
  • Station reception. One cell per hour: green when messages were received, red when none were. At a station that always hears a shore base station, red means an outage; in a quiet area it can also mean no traffic. To be warned of outages, see Alerts.

Admin page

http://<pi-address>:8095/admin.php: ingestion health, station settings (including the optional public address of the page), alerts, MQTT and Home Assistant, vessel alerts and summaries, rules for interesting vessels, named zones for routes, destination dictionary, vessel photos, token rotation, password, deletion of one vessel's data or of everything.

Very large vessels and tows. A towboat or pusher often declares the length of its whole convoy (a 15 m boat pushing barges sends 250 m). Since 1.2.1 it is not tagged very large, nor taken for the largest vessel in the records: AIS types 31, 32 and 52, inland push-tow and pusher codes, and any vessel seen with the navigational status "towing" or "pushing ahead". The rule has an option to count them anyway.

Known vessels in the admin is the same figure as all time on the page. Click it to see every transmitter the station heard, by kind: class A and B vessels, search and rescue aircraft, distress beacons, and the base stations and aids to navigation (lighthouses, buoys…) that the page leaves out, with the aids by type (lights, cardinal and lateral marks…; recorded since 1.2.1).

Military vessels. No MMSI block is reserved for warships: each country assigns their numbers (usually in its normal range), and many do not transmit, or transmit with AIS type 35. The rule tags type 35 and the MMSI prefixes you list in the admin (known prefixes of your area).

Named zones make routes readable. By default a route goes from one compass sector around the station to another (South-West → North-East; West → West for vessels that came and left on the same side, often moored or at anchor). Add zones such as a lock, a port or a town and routes become Harbour → North lock. Existing passages are recomputed when zones change.

Destination dictionary. Crews type the destination freely: FRSML, FR SML, SAINT-MALO, ST-MALO… Group the spellings of a port under one name (for example SAINT-MALO, ST-MALO, FR SML → FRSML). The admin lists the destinations received in the last 90 days to help. Meaningless values such as 0, Q or FOR ORDERS (waiting for orders, since 1.2.0) are shown as Unknown.

Destination dictionary in the admin page

Port names (UN/LOCODE, 1.2.0). Many crews type the port's UN/LOCODE code (NLRTM, FRSML, IEORK). In the dictionary card, "Fill in the names of UN/LOCODE ports" downloads UNECE's list from your station (about 7 MB, the datasets/un-locode extract; about 17,500 ports kept) and shows NLRTM as Rotterdam everywhere: routes card, constellation, vessel lists and cards. The list is not shipped with AISSeaStats because its licence does not clearly allow redistribution; it is only downloaded when you ask. Names typed in the dictionary keep priority; "Update the list" and "Remove the list" do what they say.

Maximum plausible range (1,500 NM by default): tropospheric ducting can bring messages from over 1,000 NM. Beyond 50 NM, a position only counts for range records when the same vessel was received shortly before at a consistent position, so a single corrupted message cannot set a record.

Alerts

AIS-catcher does not tell you when reception stops. AISSeaStats can: in the admin, Alerts sends one message when nothing has been received for N minutes (30 by default), and another when reception comes back. Channels, any combination:

  • ntfy: the ntfy app on your phone, with the public ntfy.sh server or your own. Pick a topic name that is hard to guess.
  • Telegram: a bot created with @BotFather, its token and your chat ID.
  • Webhook: a JSON POST readable by Discord, Slack, Mattermost, Gotify, Home Assistant or n8n.
  • E-mail: through your provider's SMTP server (STARTTLS or SSL/TLS).

“Send a test” checks each channel and shows the error if one fails. These alerts are sent by the Pi itself, so they cannot warn you if the Pi is off or offline: for that, give a heartbeat URL (healthchecks.io, Uptime Kuma in Push mode…), called every 5 minutes while reception works.

Alert settings in the admin page

Vessel alerts and summaries

Since 1.2.0, the same channels (and MQTT) can also carry, from the admin card Vessel alerts and summaries:

  • Vessel alerts, each reason can be turned on: watch list, distress, military, authorities and rescue, dangerous goods, very large, rare flag, superyacht, first visit, new range record, exceptional propagation. On by default once enabled: watch list, distress, military, range record. Reasons come from the interesting-vessel rules. A vessel alerts once per passage and reason; several reasons make one message, with its type, flag, distance, direction, destination and, if you gave the page's public address, a link that opens its card. A first visit waits for one week of history; a range record alerts at most every 30 minutes, with the best value reached meanwhile.
  • Quiet hours (distress beacons still go through) and a maximum per hour: held alerts are logged, not sent later.
  • Summaries, daily (20:00 by default) and/or weekly (Sunday 20:00): vessels, new vessels, messages, best range, interesting vessels, busiest hour. "Save and send today's summary" tries it at once.
  • Channels per kind of message: for example reception alerts by e-mail, vessel alerts on ntfy and MQTT, summaries on Telegram.
  • The last 100 messages are listed with their result (sent, quiet hours, maximum reached, channel error).

The webhook and MQTT messages are JSON with event, kind (reception, vessel, summary), title, message, priority, and for a vessel mmsi, name, triggers, distance_nm, url; a summary also has data with its figures.

Home Assistant (MQTT)

In the admin, MQTT / Home Assistant: server (the Mosquitto add-on of Home Assistant, for example), port, user and password, optional TLS (with or without checking the certificate, for a self-signed one on your home network). "Send a test" connects and publishes a test message.

With discovery on (default), an AISSeaStats device appears in Home Assistant with its sensors: vessels today, active vessels, new vessels today, messages today, messages in the last hour, today's range, range record, age of the last message, and a Reception connectivity sensor. The worker keeps one connection open and publishes every minute:

Topic Content
aisseastats/<station>/state JSON of all values, retained
aisseastats/<station>/availability online / offline; the worker publishes offline when it is stopped (docker compose stop, restart, update), and the server publishes it for the worker if it dies or the Pi goes offline (last will)
aisseastats/<station>/event alerts and summaries routed to MQTT (QoS 1, not retained)
homeassistant/…/aisseastats_<id>/…/config discovery, retained, refreshed hourly

Without a new value for 3 minutes (setting "Unavailable after", 60 to 3,600 s), Home Assistant shows the sensors as unavailable. The range record has long-term statistics, so its curve can be kept for months. Only the worker container talks to MQTT: stopping the app container (web page and ingestion) changes nothing in Home Assistant at first, then Reception turns off and Last message grows, since no AIS data arrives any more.

Home Assistant dashboard built from the AISSeaStats sensors: reception, last message, active vessels, today's range, today's figures, 24 h history

Home Assistant dashboard by @Phil353556.

No message is published per vessel. <station> is the station name in lower case (letters, digits and dashes); the prefixes can be changed. Example automation: trigger on mqtt topic aisseastats/+/event, condition {{ trigger.payload_json.kind == 'vessel' }}, then a notification with {{ trigger.payload_json.title }}.

Check what is published. With the Mosquitto tools (mosquitto-clients package, or inside a Mosquitto container), with the user and password of your broker:

mosquitto_sub -h <broker> -u <user> -P '<password>' -t 'aisseastats/#' -v
docker exec mosquitto mosquitto_sub -h localhost -u <user> -P '<password>' -t 'aisseastats/#' -v   # Mosquitto in Docker

The state arrives at once (retained), then every minute; "Send a test" in the admin shows up on …/event. The topic uses the station name in lower case (SM35 → aisseastats/sm35/…).

No MQTT server yet? Home Assistant users: install the Mosquitto broker add-on and create a Home Assistant user for AISSeaStats. Otherwise, Mosquitto in Docker, with a user and password (Mosquitto 2 refuses anonymous clients from other machines):

mkdir -p ~/mosquitto/config
printf 'listener 1883\nallow_anonymous false\npassword_file /mosquitto/config/passwd\n' > ~/mosquitto/config/mosquitto.conf
docker run --rm -it -v ~/mosquitto/config:/mosquitto/config eclipse-mosquitto:2 \
  sh -c 'mosquitto_passwd -c /mosquitto/config/passwd aisseastats && chown mosquitto:mosquitto /mosquitto/config/passwd && chmod 0700 /mosquitto/config/passwd'
docker run -d --name mosquitto --restart unless-stopped -p 1883:1883 -v ~/mosquitto/config:/mosquitto/config eclipse-mosquitto:2

The second command asks for the password of the aisseastats user: choose a real one, not the station name. Then enter the Pi's address, port 1883, aisseastats and that password in the admin.

Photos

The vessel card shows, in this order:

  1. your own photo, added in the admin page (Vessel photos) or from the card's "Add a photo" link when signed in as admin; it is stored in the database;
  2. a free photo from Wikimedia Commons, found by IMO number (files categorised IMO nnnnnnn);
  3. the image of the matching Wikidata item, found by IMO number (P458) or MMSI (P587).

Free photos are shown with author and licence and cached 30 days. Many fishing boats and pleasure craft have no free photo anywhere: they get a silhouette, and you can add yours. VesselFinder, ShipSpotting and aiscatcher.org are linked, never fetched: their terms do not allow automated reuse of their photos. The Wikimedia/Wikidata look-up is the only outbound call and can be turned off in the admin.

Troubleshooting

Symptom Fix
"Waiting for the first data from AIS-catcher" Check the HTTP output is saved and Active in AIS-catcher, and that its URL uses the Pi's IP or DNS name (not localhost, not .local). The admin page shows the last batch received and the last error.
Admin shows "token rejected" The credentials in AIS-catcher do not match: generate a new token in the admin and paste aisseastats:<token> again.
Map tiles show "Access blocked" Upgrade to 1.0.0-beta.4 or later (the page now sends the Referer that OpenStreetMap requires), or set another tile server in the admin.
A chart stays empty after switching period Upgrade to 1.0.0-beta.4 or later, then reload the page.
A vessel has an MMSI but no name The name only comes in the vessel's identity message (AIS type 5, or 24 for class B), sent every 6 minutes and longer than a position report, so it is the first lost at the edge of range. In the admin, Debug: received messages records what AIS-catcher sends for that MMSI and shows which message types arrive.
The admin shows a few MB of data but the database folder takes over 100 MB Normal. The admin shows the statistics themselves; MariaDB's folder also holds fixed-size files, mainly its 96 MB transaction log. Only the data part grows over time.

Security

  • Designed for a home network. To publish the page, read Exposing to the Internet first.
  • Ingestion requires the token (HTTP Basic or Bearer), compared in constant time; payload size is capped; every query is parameterised. Refused posts are not logged as batches.
  • The stats page is read-only and sets no cookie for visitors. The admin uses a hashed password, CSRF tokens and SameSite=Strict cookies; failed logins are limited (10 per address or 100 in total within 15 minutes, then refused for 15 minutes; bin/reset-admin.php lifts the lock), and an admin session ends after 8 hours without activity. A strict Content-Security-Policy is sent; JavaScript libraries are bundled.
  • The setup wizard asks for a one-time code that only the person running the server can see.
  • INGEST_ALLOW in .env can restrict ingestion to given networks (comma separated CIDRs such as 192.168.1.0/24; an invalid entry is ignored and logged, never read as "everything"). Behind a reverse proxy, the address seen is the proxy's.
  • Admin → Station can round the position shown on the public page and API to about 1 km (useful when the antenna is at home and the page is public).
  • Vessel photos are looked up online only for vessels your station received, at most 30 a minute.
  • The background worker container runs as www-data without any Linux capability; the database port is not published. docker-compose.hardened.yml (optional) also removes the web container's capabilities except those its servers need.
  • Each query of the public API is stopped after 20 seconds, so that nobody can keep the database busy; the image build fails if a required PHP extension is missing; a (non-blocking) warning is shown for an admin password under 8 characters.
  • MQTT checks the server's TLS certificate unless you turn it off; passwords and tokens are never shown back in the admin.
  • Radio reception and redistribution of AIS data depend on local regulations.

Exposing to the Internet

AISSeaStats is made for a home network. If you want the page reachable from outside:

  1. Put a reverse proxy with HTTPS in front (Caddy, Nginx Proxy Manager, Traefik, Cloudflare Tunnel…), never port 8095 directly. Example with Caddy, which gets the certificate by itself:

    ais.example.org {
        @private path /admin.php /setup.php /ingest.php
        respond @private 404
        reverse_proxy 127.0.0.1:8095
    }
    

    This publishes the statistics only: the admin, setup and ingestion stay reachable from your home network at http://<pi-address>:8095. If you need the admin from outside, use a VPN (WireGuard, Tailscale) rather than opening it.

  2. Listen on the Pi only when the proxy runs on the same machine. Create docker-compose.override.yml next to docker-compose.yml (Docker Compose 2.24 or later):

    services:
      app:
        ports: !override
          - "127.0.0.1:8095:8080"

    then docker compose up -d. AIS-catcher on the same Pi keeps posting to http://127.0.0.1:8095/ingest.php; an AIS-catcher on another machine then needs the proxy's address. Git does not track this file, so it survives updates.

  3. Limit the request rate at the proxy if it can (Nginx limit_req, Caddy's rate-limit plugin, Cloudflare rules), and open only ports 80/443 on the router or firewall.

  4. Set Admin → Station → public address so that alerts link to the public page, and consider rounding the published position.

  5. Optional: docker compose -f docker-compose.yml -f docker-compose.hardened.yml up -d for the extra container hardening.

Behind a proxy, the address seen by INGEST_ALLOW and the login limits is the proxy's: keep ingestion on the home network as in the example above.

Development

php tests/run.php                                         # unit tests
DB_HOST=127.0.0.1 DB_NAME=test DB_USER=… DB_PASSWORD=… php tests/run.php   # + integration tests
MQTT_TEST_HOST=127.0.0.1 …  php tests/run.php            # + MQTT tests against a broker (Mosquitto)
sh tests/stack.sh                                         # end-to-end test of a running Docker stack (CI)

Stack: PHP 8.3 without framework, MariaDB, vanilla JavaScript with Chart.js, Leaflet and Leaflet.heat bundled in public/assets/vendor. Scoping notes: docs/CADRAGE.md, docs/CADRAGE-1.2.0.md.

Licence

GPL-3.0-or-later, see LICENSE. Bundled: Chart.js (MIT), Leaflet (BSD-2-Clause), Leaflet.heat (BSD-2-Clause). AISSeaStats is not affiliated with AIS-catcher. Not for navigation.

About

AIS-catcher Statistics lite in PHP/MariaDB

Resources

Security policy

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages