PiGallery2 is a fast, self-hosted photo gallery that reads directly from your directory structure — no imports, no re-encoding, no database migration. It renders map views, supports full-text search, and handles thousands of photos efficiently on low-powered hardware like a Raspberry Pi. But "self-hosted" means you're responsible when it goes down. If the Node.js process crashes, the SQLite metadata database gets corrupted, or your reverse proxy misconfigures, your gallery silently disappears. Vigilmon gives you external monitoring that watches PiGallery2 from outside your network and alerts you the moment something fails.
What You'll Build
- A Vigilmon ping monitor for web server availability at PiGallery2's default port
- A gallery API content check via
/pgapi/gallery/content/directory - SQLite health detection via the API response
- SSL certificate alerts if proxied through Nginx or Caddy
- An external uptime check confirming the gallery is accessible from the internet
Prerequisites
- A running PiGallery2 instance accessible over HTTPS (recommended: reverse proxy with Caddy or Nginx)
- A free account at vigilmon.online
Step 1: Understand PiGallery2's Endpoints
PiGallery2 runs on port :80 by default (or :3000 if configured as a non-root user). It doesn't ship a dedicated /health endpoint, but its gallery API provides reliable health signal.
The endpoint /pgapi/gallery/content/directory returns the root directory listing from PiGallery2's metadata database. If the SQLite database is accessible and the photo directory is mounted, this endpoint returns a 200 response with a JSON body. If the process has crashed or the database is locked, it returns an error.
curl https://your-pigallery2-domain.com/pgapi/gallery/content/directory
A healthy response returns JSON with directory and mediaCount fields. Any non-200 response or a {"error":...} body indicates a problem.
TLS setup: PiGallery2 doesn't handle TLS itself. Run it behind Caddy for automatic HTTPS:
photos.yourdomain.com { reverse_proxy localhost:80 }
Step 2: Create an HTTP Monitor for Web Availability
- Log in to Vigilmon → Add Monitor → HTTP.
- URL:
https://your-pigallery2-domain.com/. - Check interval: 60 seconds.
- Response timeout: 15 seconds (PiGallery2 may be slower on Raspberry Pi hardware).
- Expected status:
200. - Keyword:
PiGallery2(appears in the HTML page title). - Click Save.
This monitor confirms the web server is up and the frontend is rendering. Adjust the timeout to 20–30 seconds if you're running on a Pi Zero or other slow hardware.
Step 3: Add a Gallery API Content Check
The root HTML monitor confirms the server is up, but it doesn't tell you if the gallery data is accessible. Add a second monitor targeting the directory API:
- Add Monitor → HTTP.
- URL:
https://your-pigallery2-domain.com/pgapi/gallery/content/directory. - Expected status:
200. - Keyword:
mediaCount(present in a healthy directory API response). - Check interval: 5 minutes (API calls are heavier; less frequent is fine).
- Click Save.
If PiGallery2's SQLite database is locked or the photo directory becomes unmounted, this endpoint returns an error response. The keyword check catches it even if the HTTP status stays 200 due to a proxy intercepting the error.
Step 4: Detect SQLite Issues via API Response
PiGallery2 uses SQLite to store photo metadata (EXIF data, directory cache, search indexes). When SQLite is locked or corrupted, PiGallery2 can still serve the web UI from static assets while returning errors from all API calls.
The keyword monitor from Step 3 catches this: if mediaCount is missing from the directory API response, the check fails. For extra coverage, add a second keyword check:
- Keyword:
error(must not be present) - Set keyword must be absent: yes (if Vigilmon supports negated keyword checks)
Alternatively, monitor response time: a SQLite lock causes the directory API to stall before returning an error. Set a response time threshold of 5 seconds on the API monitor — a stalled SQLite database consistently breaks this threshold before returning an error.
Step 5: SSL Certificate Alerts
Photos are personal data. An expired certificate isn't just an inconvenience — it locks users out and flags the site as insecure in browsers.
Vigilmon checks SSL certificates automatically on every HTTPS monitor. Configure expiry alerts:
- Open any HTTPS monitor → SSL Certificate.
- Alert threshold: 14 days before expiry.
- Add a 30-day advance alert for renewal lead time.
If you're using Let's Encrypt via Caddy or Certbot, a certificate expiry alert often means the auto-renewal cron job has silently failed — catch it before users see a browser warning.
Step 6: External Uptime Confirmation
PiGallery2 often runs on home servers or Raspberry Pis behind a residential internet connection. NAT, ISP outages, and DDNS failures can make the gallery unreachable from the internet even when the server is running fine locally.
A Vigilmon external HTTP monitor acts as a probe from outside your network, confirming reachability from the public internet:
- Your root URL monitor from Step 2 already handles this if PiGallery2 is on a public IP.
- If you're using a DDNS hostname (e.g.,
photos.myhome.duckdns.org), ensure the monitor URL uses the DDNS hostname — Vigilmon probes from its own infrastructure, which is external to your network.
If your ISP changes your IP and DDNS doesn't update, the Vigilmon monitor catches it as a DNS resolution failure.
Step 7: Configure Alerting
In Vigilmon under Settings → Notifications:
| Trigger | Recommended action |
|---|---|
| Web UI returns non-200 or keyword missing | Email; check pm2 logs pigallery2 or journalctl -u pigallery2 |
| API returns non-200 or missing mediaCount | Email; SQLite may be locked or photo directory unmounted |
| Response time > 5 s on API monitor | Email; SQLite stall or high CPU on Pi hardware |
| SSL certificate < 14 days | Email; verify Caddy auto-HTTPS or run certbot renew |
Alert after: 2 consecutive failures. PiGallery2 can have brief slowdowns on Raspberry Pi under load — 2 failures avoids false positives from momentary spikes.
What Vigilmon Catches That PiGallery2 Logs Miss
| Scenario | PiGallery2 logs | Vigilmon | |---|---|---| | Node.js process OOM-killed | Kernel log only | HTTP monitor fires within 60–120 s | | Photo directory unmounted | API errors in log | API keyword check fires immediately | | ISP IP change; DDNS not updated | Not logged | External HTTP monitor catches DNS failure | | Let's Encrypt cert expires | Not logged by PiGallery2 | SSL monitor alerts 14 days early | | SQLite database corrupted | API errors in log | API monitor keyword check fires |
PiGallery2 is built for simplicity, but simplicity means there's no ops layer watching it. Vigilmon adds that external eye — watching your gallery from the internet's perspective, not just from inside your server room.
Start monitoring PiGallery2 in under 5 minutes — register free at vigilmon.online.