OpenClaw Token Usage Monitor
Paste the following prompt into your AI chat to install this skill:
Please follow https://skillhub.cn/install/skillhub.md to install @user_acdf755c/token-monitor.
About this skill
Problem
OpenClaw session logs keep appending usage data into JSONL files, where usage objects are scattered across assistant messages. Manually inspecting those files makes it hard to compare API calls, cache usage, model mix, or daily and hourly peaks. This skill turns dispersed session logs into a comparable usage view for local audits and anomaly review.
How It Works
The script reads ~/.openclaw/agents/*/sessions/*.jsonl and aggregates assistant message fields such as input, output, cacheRead, cacheWrite, totalTokens, and cost. It reports:
- Overview: total API calls, input/output/cache tokens, and average usage per call
- By Model: token breakdown and percentage share by model
- Daily Trend: UTC-date token consumption
- Hourly Breakdown: usage distribution for the latest active day
Use --days, --json, --top, and --base-dir to control the time window, output format, model count, and agents directory.
Boundaries
Cost depends on provider pricing; when absent, cost shows as $0.00. Daily grouping uses UTC, so cross-timezone analysis needs care. The script aggregates all agents rather than separating main agents from sub-agents.
Use Cases
- After running OpenClaw locally, review the last 7 days of API calls, input/output tokens, and cache token totals.
- When investigating unusual model spend, split token usage by model and identify the high-consumption models.
- During a peak-usage review, inspect the hourly distribution to distinguish overnight batch jobs from daytime interaction.
- Export session logs as JSON and feed the structured data into reporting scripts or alerting pipelines.
Best For
- Engineers maintaining local OpenClaw environments who need periodic token and API-call checks across agent sessions.
- Technical leads reconciling model spend who need model-level usage shares from session logs.
- Data engineers building usage reports who need JSONL session data converted into aggregate-ready JSON.
- Ops staff investigating overnight batch anomalies who need hourly token distribution for the latest active day.
Related Skills
Query Douyin creator videos, image/text posts, and short-drama series by sec_user_id or profile URL with paginated list retrieval.
Uses CDP-controlled browser screenshots of Douyin video pages and multimodal AI to extract teaching points into a Markdown report.
Query Douyin hot searches and works with SocialDataX API or MCP tools, supporting keyword, sorting, time range, duration, content type, and pagination.
Fetch the GitHub Trending leaderboard and generate fact-grounded project analysis, trend hypotheses, and directional insights.