OCM Monitor
Overview
Automated monitoring for OpenClaw Manager desktop app:
- Detect if OpenClaw gateway service is running (TCP port 18789, process check, pixel scan, CLI fallback)
- If NOT running: restart via CLI (
openclaw gateway restart), fallback to UI button click - After restart: automatically click Dashboard button to open web console
Files
monitor_ocm.ps1- PowerShell script with C# embedded mouse/window helpers
Usage
One-time check (default)
powershell -File <skill-path>/monitor_ocm.ps1
Continuous monitoring loop
# Check every 60 seconds (default)
powershell -File <skill-path>/monitor_ocm.ps1 -Loop
# Check every 30 seconds
powershell -File <skill-path>/monitor_ocm.ps1 -Loop -Sec 30
Dashboard only (skip monitoring)
powershell -File <skill-path>/monitor_ocm.ps1 -OnlyDash
As cron job:
openclaw cron add \
--name "OCM Monitor" \
--cron "*/5 * * * *" \
--session isolated \
--message "Run ocm-monitor skill check"
Detection Methods
Ordered by reliability:
- TCP port 18789 - Most reliable
- Process check - openclaw-manager / openclaw-gateway
- Green pixel scan - Detects "运行中" status indicator color
- CLI status -
openclaw gateway status
Restart Strategy
- CLI:
openclaw gateway restart(wait 12s) - Verify service
- If still down: UI click "重启" button via coordinate ratio
- On success: click Dashboard button
Coordinate Ratios
Buttons are clicked by window-relative ratios, so they work at different resolutions:
| Button | X ratio | Y ratio |
|---|---|---|
| Dashboard | 0.92 | 0.045 |
| Restart | 0.68 | 0.48 |
Log Output
All operations logged to: <skill-path>/ocm_monitor.log
Notes:
- No external dependencies (uses embedded C# via Add-Type)
- Works on Windows with .NET Framework
- Safe to run repeatedly (idempotent if already running)
