360 Secure SkillHub
360 安全技能中心

OCM Monitor

面向 OpenClaw Manager 桌面应用的监控技能:通过 TCP 端口 18789、进程、绿色像素与 CLI 状态依次检测网关是否运行;若停止则先用 openclaw CLI 重启,失败后改为点击界面按钮,成功后点击 Dashboard 打开控制台,支持循环与定时检查。

poyobi
poyobi
热度 20.23
最近更新 2026-04-05 23:26:53
分类:自动化依赖:代码执行 / 读写文件应用场景:自动化脚本 / DevOps / 工作流 / 日程安排

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add ocm-monitor
Metadata
name
ocm-monitor
description
OpenClaw Manager monitoring & auto-restart. Detect if service is down (port 18789 / process), auto-restart via CLI then UI, opens Dashboard page. Supports loop mode for continuous monitoring.

OCM Monitor

Overview

Automated monitoring for OpenClaw Manager desktop app:

  1. Detect if OpenClaw gateway service is running (TCP port 18789, process check, pixel scan, CLI fallback)
  2. If NOT running: restart via CLI (openclaw gateway restart), fallback to UI button click
  3. 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:

  1. TCP port 18789 - Most reliable
  2. Process check - openclaw-manager / openclaw-gateway
  3. Green pixel scan - Detects "运行中" status indicator color
  4. CLI status - openclaw gateway status

Restart Strategy

  1. CLI: openclaw gateway restart (wait 12s)
  2. Verify service
  3. If still down: UI click "重启" button via coordinate ratio
  4. 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)