Projects/Home Monitoring Dashboard
Monitoring

Home Monitoring Dashboard

View all machines in the household on a single page: status of three nodes, DeepSeek/Bocha balances, and alert history.

What Is This

The dashboard is a single page running on the intranet .164, bringing four machines—at home and in the cloud—into one screen: who is online, how CPU, memory, and disk are doing, which services are down, what the probe latency is, and how much balance remains for DeepSeek and Bocha. The page itself is lightweight: the frontend is plain HTML + JS, and the backend is a Python service serving /api/stats, with no framework and no build step.

Why Build It

As machines multiply, status gets scattered everywhere: on the Windows local machine you have to check whether scheduled tasks are down; on the Hong Kong VPS you have to SSH in and run commands; and the model API balance requires a separate login to check. When something actually goes wrong, you are often the last to know—the Windows reporting script had been down for three days before it was noticed, and on recharge day the panel even displayed "recharge" as negative consumption, making everything look misunderstood at a glance. So I simply consolidated it into one page, where the numbers must reconcile.

What It Looks Like Now

  • Overview bar: machines online 4/4, site-wide probes 21/21, N items requiring attention, data freshness (including the oldest node)
  • Four machine cards arranged at equal height; services and containers, network ports, and process logs are collapsed into three blocks, with the summary line directly giving the key values
  • Site-wide health probes form a separate block; latency is color-coded (<200 green / <600 orange / ≥600 red), with anomalies sorted first
  • DeepSeek and Bocha each have a balance card: today's/yesterday's consumption, a bar chart for the last 14 days, and color-coded balance
  • Problematic nodes are automatically sorted to the front to avoid frequent jumping

Status: Running; publicly accessible via Nginx reverse proxy at https://xiejun-server.top/con/.

Features

  • 一屏汇总四台机器的在线状态、CPU、内存与磁盘用量
  • 服务容器、网络端口、进程日志折叠展示,摘要行给关键值
  • 全站探测单独成块,延迟颜色分级,组内异常优先
  • DeepSeek / 博查余额卡片:今日与昨日消耗、近 14 天柱状图
  • 充值不再算成负消耗:余额下降计消耗、上升计充值,只累加不抵消
  • 采集失败不清空面板,数据陈旧超过 45 分钟给出提示

Stack: Python · JavaScript · Nginx · systemd · JSON · PowerShell

Deployment Steps

1. Place the Files

Keep all files in /opt/dashboard: the backend server.py, collector scripts deepseek_balance.py / bocha_balance.py, shared stats library balancelib.py, and frontend index.html + app.js. The frontend is vanilla — no build step needed. The only dependencies are Python 3, systemd, and Nginx.

2. Prepare the Keys

Write the API Key to /opt/dashboard/.deepseek-key, chmod 600, and add it to the exclusion list in /opt/homelab-git/sync.sh so it never ends up in the git backup.

3. Run a Collection Manually First

python3 /opt/dashboard/deepseek_balance.py

Confirm that deepseek.json contains cny, available, and daily. Note that at first there are only 1–2 sample points, so "Today's Spend" won't be accurate until a little while later, and the bar chart won't take shape until there's data from a second day.

4. Configure systemd

Add dashboard-deepseek.service (oneshot) and dashboard-deepseek.timer (every 15 minutes), then:

systemctl enable --now dashboard-deepseek.timer
systemctl restart dashboard

5. Verify the API

curl -s http://127.0.0.1:9090/api/stats

Check whether cny, available, the number of daily entries, and samples in the deepseek field look right. At the UI level, you can do a reconciliation check: balance at start of day − today's spend = current balance.

6. Nginx Reverse Proxy

Proxy /con/ to port 9090 on localhost, and access it publicly at https://xiejun-server.top/con/. After changing the frontend, remember to confirm that the app.js served publicly has been updated — otherwise you'll still be seeing the old rendering logic.

7. Back Up Before Changing Anything

Before every change to server.py / app.js / index.html, back up the whole set to /root/dashboard-backup-<date>/. To roll back, just cp those files back and run systemctl restart dashboard; if the problem is in the balance portion, also run systemctl disable --now dashboard-deepseek.timer.

8. Adding Other Providers

To pull in balances for Kimi, Zhipu, and the like, change the API and parsing logic in deepseek_balance.py and reuse balancelib.py for the stats portion.