tutorial

Monitoring Mainsail and Klipper 3D Printers with Vigilmon

Mainsail is the go-to web UI for Klipper 3D printer firmware — but a silent Moonraker crash or a lost webcam feed can ruin a long print job. Here's how to monitor your entire 3D printing stack with Vigilmon.

Mainsail turns a Raspberry Pi into a professional 3D printer control center — real-time print progress, webcam streaming, G-code management, and remote access from any browser. But when Moonraker (the Python API bridge) crashes at hour 14 of a 20-hour print, you won't know until you check the webcam and see a cold, stalled extruder. Vigilmon watches your entire printing stack — Mainsail UI, Moonraker API, printer state, and webcam — and alerts you the moment something breaks.

What You'll Set Up

  • HTTP uptime monitor for the Mainsail web UI (nginx, port 80)
  • Moonraker API health check (port 7125)
  • Printer state endpoint response time monitoring (/printer/info)
  • Webcam stream availability check (mjpg-streamer/camera-streamer, port 8080)
  • TCP monitor for Moonraker socket connectivity
  • Alert channel configuration for print-failure notifications

Prerequisites

  • Mainsail installed and running (via MainsailOS, KIAUH, or manual setup)
  • Moonraker running on port 7125
  • A free Vigilmon account

Step 1: Monitor the Mainsail Web UI

Mainsail is served by nginx as a static Vue.js app. If nginx crashes or the Pi loses power, the web UI goes dark.

  1. Log in to vigilmon.online and click Add Monitor.
  2. Set Type to HTTP / HTTPS.
  3. Enter your Mainsail URL: http://mainsail.local or http://YOUR_PI_IP.
  4. Set Check interval to 2 minutes.
  5. Set Expected HTTP status to 200.
  6. Click Save.

If you've set up a domain with SSL (e.g. via Cloudflare Tunnel), use the HTTPS URL and enable Monitor SSL certificate with a 21-day alert threshold.


Step 2: Monitor the Moonraker API

Moonraker is the Python server that bridges Mainsail to Klipper. The web UI can appear available (nginx is up) while Moonraker is down — leaving you unable to start prints or read sensor data.

Add a dedicated Moonraker API health monitor:

  1. Click Add MonitorHTTP / HTTPS.
  2. URL: http://YOUR_PI_IP:7125/server/info.
  3. Set Check interval to 1 minute.
  4. Set Expected HTTP status to 200.
  5. Set Expected response body contains to moonraker.
  6. Click Save.

The /server/info endpoint returns JSON including the Moonraker version and component status. A 200 with a valid JSON body confirms the API server is running.

# Verify manually
curl -s http://YOUR_PI_IP:7125/server/info | python3 -m json.tool

Step 3: Monitor Printer State via /printer/info

Even with Moonraker up, Klipper (the MCU firmware daemon) can disconnect from the printer board — a firmware exception, a loose USB cable, or a failed MCU update. The /printer/info endpoint exposes Klipper's connection state.

  1. Click Add MonitorHTTP / HTTPS.
  2. URL: http://YOUR_PI_IP:7125/printer/info.
  3. Check interval: 2 minutes.
  4. Expected HTTP status: 200.
  5. Expected response body contains: ready (Klipper reports state: "ready" when connected to the MCU).
  6. Click Save.

A response containing "error" or "shutdown" in the state field means Klipper has crashed or the MCU is disconnected. Vigilmon will alert as soon as the expected string check fails.


Step 4: Monitor the Webcam Stream

Webcam streaming (mjpg-streamer or camera-streamer) runs on port 8080 independently of Moonraker. It can crash without affecting the print itself, but it leaves you flying blind on long jobs.

  1. Click Add MonitorHTTP / HTTPS.
  2. URL: http://YOUR_PI_IP:8080/?action=stream (mjpg-streamer) or http://YOUR_PI_IP:8080/stream (camera-streamer).
  3. Check interval: 5 minutes (streaming endpoints are heavier to probe).
  4. Expected HTTP status: 200.
  5. Click Save.

Alternatively, use the snapshot endpoint for a lighter check:

http://YOUR_PI_IP:8080/?action=snapshot

This fetches a single JPEG frame instead of initiating a stream connection, which is faster and more reliable for health checks.


Step 5: TCP Monitor for Moonraker Port

Add a TCP-level monitor to catch cases where Moonraker's HTTP server starts but the port becomes unresponsive (deadlock, socket exhaustion):

  1. Click Add MonitorTCP Port.
  2. Host: YOUR_PI_IP.
  3. Port: 7125.
  4. Check interval: 1 minute.
  5. Click Save.

Step 6: Heartbeat Monitor for Print Job Completion

For very long prints, you can send Vigilmon a heartbeat ping from a Moonraker macro or a small shell script that runs on the Pi to confirm the print is still progressing:

  1. Click Add MonitorCron Heartbeat.
  2. Set Expected interval to 30 minutes.
  3. Copy the heartbeat URL.

Add a shell script on the Pi that checks print progress and pings Vigilmon:

#!/bin/bash
# /home/pi/check_print.sh
STATE=$(curl -s http://localhost:7125/printer/objects/query?print_stats \
  | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['result']['status']['print_stats']['state'])")

if [ "$STATE" = "printing" ] || [ "$STATE" = "complete" ]; then
    curl -s https://vigilmon.online/heartbeat/YOUR_HEARTBEAT_ID
fi

Schedule it in crontab:

*/30 * * * * /home/pi/check_print.sh

If the Pi crashes or the print stalls without completing, the heartbeat stops and Vigilmon alerts.


Step 7: Configure Alert Channels

Long prints fail at inconvenient hours. Route alerts where you'll actually see them:

  1. Go to Alert Channels in Vigilmon.
  2. Add a Slack or Discord webhook for your home/lab notification channel.
  3. Add an email alert as a backup.
  4. On each Moonraker/printer monitor, set Consecutive failures before alert to 2 — this avoids false alarms from momentary API timeouts during high-load G-code processing.

For the webcam monitor, set the threshold to 3 — stream endpoints can be slow to respond during peak CPU usage (especially when running on a Pi 3).


Summary

| Monitor | Target | What It Catches | |---|---|---| | Mainsail UI | http://PI_IP:80 | nginx crash, Pi power loss | | Moonraker API | http://PI_IP:7125/server/info | Python API server down | | Printer state | http://PI_IP:7125/printer/info | Klipper MCU disconnect, firmware crash | | Webcam stream | http://PI_IP:8080/snapshot | Camera service crash | | TCP port | PI_IP:7125 | Moonraker socket unresponsive | | Cron heartbeat | Heartbeat URL | Pi crash during active print |

Mainsail gives you a beautiful interface for your Klipper printer — Vigilmon makes sure that interface and everything behind it stays up through 40-hour overnight prints.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →