npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

koishi-plugin-server-monitor

v1.0.2

Published

服务器监控插件,支持文本和可视化图片两种展示模式

Readme

koishi-plugin-server-monitor

npm

一个功能强大的 Koishi 服务器监控插件,支持文本和可视化图片两种展示模式。

功能特性

  • 🖥️ 多服务器监控 - 支持监控多台服务器的实时状态
  • 📊 双模式显示 - 文本模式、图片模式、或两者结合
  • 🎨 多种主题 - 暗色、亮色、赛博朋克三种视觉主题
  • 🌍 地区分布 - 按国家/地区显示服务器分布情况
  • 实时数据 - CPU、内存、磁盘、网络等实时监控
  • 🚨 智能告警 - 可配置的资源使用阈值告警
  • 📈 可视化面板 - 高科技感的监控仪表板
  • 🔐 JWT认证 - 自动token管理和刷新
  • 🔄 热重载 - 支持配置热更新

安装

通过 Koishi 插件市场安装(推荐)

在 Koishi 控制台的插件市场中搜索 "server-monitor" 或 "服务器监控" 进行安装。

通过 npm 安装

npm install koishi-plugin-server-monitor

🔧 系统依赖(Linux服务器)

如果你在 Linux 服务器上安装,需要先安装系统依赖:

Ubuntu/Debian:

# 更新包管理器
apt update

# 安装 canvas 图形库依赖
apt install -y build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev libpixman-1-dev

# 然后安装插件
npm install koishi-plugin-server-monitor

CentOS/RHEL:

# 安装开发工具和依赖
yum groupinstall -y "Development Tools"
yum install -y cairo-devel pango-devel libjpeg-devel giflib-devel librsvg2-devel

# 然后安装插件
npm install koishi-plugin-server-monitor

Alpine Linux (Docker):

apk add --no-cache build-base cairo-dev pango-dev jpeg-dev giflib-dev librsvg-dev pixman-dev

配置

基本配置

| 配置项 | 类型 | 默认值 | 说明 | |--------|------|--------|------| | apiUrl | string | - | 服务器监控API地址 | | username | string | - | API认证用户名 | | password | string | - | API认证密码 | | displayMode | 'text' | 'image' | 'both' | text | 显示模式 | | theme | 'dark' | 'light' | 'cyber' | dark | 可视化主题 | | refreshInterval | number | 300 | 数据刷新间隔(秒) | | autoRefreshToken | boolean | true | 自动刷新JWT token | | tokenRefreshInterval | number | 3600 | Token刷新间隔(秒) |

告警阈值设置

plugins:
  server-monitor:
    apiUrl: https://your-api-server.com/api/v1/server
    username: admin
    password: your-password
    displayMode: both
    theme: dark
    enableAlerts: true
    alertThresholds:
      cpu: 0.8        # CPU使用率告警阈值 (80%)
      memory: 0.9     # 内存使用率告警阈值 (90%)
      disk: 0.85      # 磁盘使用率告警阈值 (85%)

使用命令

基础命令

server              # 显示服务器概览
server list         # 显示服务器列表
server <name>       # 查看特定服务器详情
server top          # 按资源使用率排序显示
server refresh      # 强制刷新数据

示例

server                    # 显示所有服务器概览
server hk-server-01       # 显示指定服务器详情
server list               # 显示简洁的服务器列表
server top                # 显示资源使用率最高的服务器

显示模式

文本模式 (text)

🖥️ 服务器监控概览
📊 总计: 13 台 | 🟢 在线: 13 台

🌍 地区分布:
🇭🇰 HK: 4 台  🇸🇬 SG: 3 台  🇺🇸 US: 2 台  🇨🇳 CN: 2 台

📈 资源使用概况:
🔥 平均CPU: 3.2%
🧠 内存: 8.1GB / 26.8GB (30.2%)
💾 磁盘: 195.4GB / 847.2GB (23.1%)

图片模式 (image)

生成包含以下元素的可视化仪表板:

  • 📊 服务器状态概览卡片
  • 🎯 CPU/内存/磁盘使用率环形图
  • 📋 服务器状态列表
  • 🌍 地区分布统计
  • 🎨 主题化的视觉设计

组合模式 (both)

同时显示文本信息和可视化图片,提供最完整的信息展示。

主题风格

暗色主题 (dark)

  • 深色背景配色
  • 现代简洁设计
  • 适合日常使用

亮色主题 (light)

  • 明亮背景配色
  • 清晰易读
  • 适合正式场合

赛博朋克主题 (cyber)

  • 黑绿配色方案
  • 霓虹发光效果
  • 科幻未来风格

🔐 认证说明

插件支持JWT自动认证:

  • 配置用户名和密码后,插件会自动获取JWT token
  • 支持token自动刷新,无需手动管理
  • 当token过期时会自动重新登录

API 数据格式

插件支持标准的服务器监控API,期望返回格式:

{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "服务器名称",
      "host": {
        "platform": "debian",
        "cpu": ["CPU型号"],
        "mem_total": 内存总量,
        "disk_total": 磁盘总量
      },
      "state": {
        "cpu": CPU使用率,
        "mem_used": 内存使用量,
        "disk_used": 磁盘使用量,
        "net_in_speed": 入站速度,
        "net_out_speed": 出站速度,
        "uptime": 运行时间
      },
      "geoip": {
        "country_code": "国家代码"
      },
      "last_active": "最后活跃时间"
    }
  ]
}

故障排除

Canvas 安装失败

如果遇到 canvas 相关的安装错误,请参考上面的系统依赖安装说明。

图片模式不工作

  1. 确保已安装系统图形库依赖
  2. 检查 canvas 模块是否正确安装
  3. 可以先使用文本模式测试功能

API 连接问题

  1. 检查 API 地址是否正确
  2. 确认用户名密码是否正确
  3. 检查网络连接和防火墙设置

开发

# 克隆项目
git clone https://github.com/jiusiguer/koishi-plugin-server-monitor.git
cd koishi-plugin-server-monitor

# 安装依赖
npm install

# 构建
npm run build

# 开发模式
npm run dev

依赖

  • koishi ^4.18.0
  • canvas ^2.11.2 - 用于图片生成
  • axios ^1.6.7 - 用于API调用

许可证

MIT License

贡献

欢迎提交 Issue 和 Pull Request!

支持

如有问题,请通过以下方式联系:

更新日志

v1.0.0

  • ✨ 初始版本发布
  • 📊 支持文本和图片双模式显示
  • 🎨 提供三种视觉主题
  • 🌍 支持多地区服务器监控
  • ⚡ 实时数据监控和告警功能
  • 🔐 JWT自动认证和token管理