Agent Health Monitoring Script

Know when your agent is stuck, looping, or running out of context

Updated: 2/23/2026
Difficulty
easy
Time
20 minutes setup
Use Case
infrastructure
Popularity
0 views

About this automation

A lightweight monitoring setup that alerts you when your OpenClaw agent is in an error state, hasn't responded in too long, or is consuming excessive tokens. Essential for production autonomous agents.

How to implement

1

Create a monitoring cron (every 30min): check `openclaw status`

2

Alert conditions: last heartbeat > 2h ago, error count > 3, context > 90%

3

Send Telegram alert with agent state snapshot

4

Add auto-restart: `openclaw gateway restart` if gateway is down

5

Log daily token usage to track costs