RuleGo RuleGo
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • 快速入门

  • 规则链

  • 标准组件

  • 扩展组件

    • 扩展组件概述
    • 过滤器

    • 转换器

    • 外部的

    • AI

    • CI

      • git拉取
      • git 提交
      • git创建标签
      • git推送
      • git 日志
      • 服务器指标监控
        • 配置
        • 执行结果
          • 返回值结构
          • HostInfoStat: 主机信息
          • CpuInfoStat: CPU信息
          • VirtualMemoryStat: 虚拟内存信息
          • SwapMemoryStat: 交换内存信息
          • UsageStat: 磁盘使用情况
          • DiskIOCountersStat: 磁盘IO计数器信息
          • NetIOCountersStat: 网络IO计数器信息
          • NetInterfaceStat: 网络接口信息
          • 返回值示例
    • IoT

  • 自定义组件

  • 组件市场

  • 可视化

  • AOP

  • 触发器

  • 高级主题

  • RuleGo-Server

  • 问题

目录

服务器指标监控

ci/ps组件:v0.23.0+ 服务器指标监控,用于监控服务器信息,如CPU、内存、磁盘等信息。

需要额外引入扩展库:https://github.com/rulego/rulego-components-ci

# 配置

字段 类型 说明 默认值
options []string 指定要查询的指标列表,如果为空,则查询所有指标 空

options可选值:

  • host/info: 查询主机信息
  • cpu/info: 查询CPU信息
  • cpu/percent: 查询CPU使用率
  • mem/virtualMemory: 查询虚拟内存信息
  • mem/swapMemory: 查询交换内存信息
  • disk/usage: 查询磁盘使用情况
  • disk/ioCounters: 查询磁盘IO计数器信息
  • net/ioCounters: 查询网络IO计数器信息
  • net/interfaces: 查询网络接口信息

# 执行结果

每个指标都有对应的结构体,具体结构如下:

# 返回值结构

字段 类型 说明
host/info HostInfoStat 主机信息
cpu/info []CpuInfoStat CPU信息
cpu/percent []float64 CPU使用率
mem/virtualMemory VirtualMemoryStat 虚拟内存信息
mem/swapMemory SwapMemoryStat 交换内存信息
disk/usage UsageStat 磁盘使用情况
disk/ioCounters []DiskIOCountersStat 磁盘IO计数器信息
net/ioCounters []NetIOCountersStat 网络IO计数器信息
net/interfaces []NetInterfaceStat 网络接口信息

# HostInfoStat: 主机信息

字段 类型 说明
hostname string 主机名
uptime int 系统运行时间,单位为秒
bootTime int 系统启动时间,Unix 时间戳
procs int 正在运行的进程数
os string 操作系统名称
platform string 平台名称,如 Windows/Linux 等
platformFamily string 平台系列,如 Standalone Workstation
platformVersion string 平台版本号
kernelVersion string 内核版本
kernelArch string 内核架构,如 x86_64
virtualizationSystem string 虚拟化系统
virtualizationRole string 虚拟化角色
hostId string 主机的唯一标识,如 UUID 等

# CpuInfoStat: CPU信息

字段 类型 说明
cpu int CPU 编号
vendorId string 厂商ID
family string CPU 系列
model string 型号
stepping int 步进版本
physicalId string 物理ID
coreId string 核心ID
cores int 物理核心数
modelName string 完整的CPU型号名称
mhz int 主频
cacheSize int 缓存大小
flags []string CPU 支持的功能标志集合
microcode string 微码版本

# VirtualMemoryStat: 虚拟内存信息

字段 类型 说明
total int 总内存大小
available int 可用内存大小
used int 已使用内存大小
usedPercent int 内存使用百分比
free int 空闲内存大小

# SwapMemoryStat: 交换内存信息

字段 类型 说明
total int 交换区总大小
used int 交换区已使用大小
free int 交换区空闲大小
usedPercent int 交换区使用百分比
sin int 从交换区写入内存的次数
sout int 从内存写入交换区的次数

# UsageStat: 磁盘使用情况

字段 类型 说明
path string 磁盘路径
fstype string 文件系统类型
total int 磁盘总大小
free int 磁盘空闲大小
used int 磁盘已使用大小
usedPercent float 磁盘使用百分比
inodesTotal int 总的inode数量
inodesUsed int 已使用的inode数量
inodesFree int 空闲的inode数量
inodesUsedPercent float inode使用百分比

# DiskIOCountersStat: 磁盘IO计数器信息

字段 类型 说明
readCount int 读操作次数
writeCount int 写操作次数
readBytes int 读取的字节数
writeBytes int 写入的字节数
readTime int 读操作耗时
writeTime int 写操作耗时

# NetIOCountersStat: 网络IO计数器信息

字段 类型 说明
name string 网络接口名称
bytesSent int 发送的字节数
bytesRecv int 接收的字节数
packetsSent int 发送的数据包数
packetsRecv int 接收的数据包数
errin int 接收时发生的错误数
errout int 发送时发生的错误数

# NetInterfaceStat: 网络接口信息

字段 类型 说明
index int 网络接口索引
mtu int 最大传输单元
name string 网络接口名称
hardwareAddr string 硬件地址,即MAC地址
flags []string 网络接口标志集合
addrs []Addr 网络接口地址列表

Addr 结构体可能包含如下字段:

字段 类型 说明
addr string 网络地址

# 返回值示例

{
  "cpu/info": [
    {
      "cpu": 0,
      "vendorId": "AuthenticAMD",
      "family": "107",
      "model": "",
      "stepping": 0,
      "physicalId": "",
      "coreId": "",
      "cores": 16,
      "modelName": "AMD Ryzen 7 4800U with Radeon Graphics",
      "mhz": 1800,
      "cacheSize": 0,
      "flags": [],
      "microcode": ""
    }
  ],
  "cpu/percent": [
    2.019230769230769
  ],
  "disk/ioCounters": [
    {
      "readCount": 3551912,
      "mergedReadCount": 0,
      "writeCount": 3128504,
      "mergedWriteCount": 0,
      "readBytes": 146734894592,
      "writeBytes": 106254207488,
      "readTime": 2026,
      "writeTime": 1708,
      "iopsInProgress": 0,
      "ioTime": 0,
      "weightedIO": 0,
      "name": "C:",
      "serialNumber": "",
      "label": ""
    },
    {
      "readCount": 960056,
      "mergedReadCount": 0,
      "writeCount": 1004377,
      "mergedWriteCount": 0,
      "readBytes": 14221063168,
      "writeBytes": 10532502016,
      "readTime": 209,
      "writeTime": 616,
      "iopsInProgress": 0,
      "ioTime": 0,
      "weightedIO": 0,
      "name": "D:",
      "serialNumber": "",
      "label": ""
    }
  ],
  "disk/usage": [
    {
      "path": "C:",
      "fstype": "",
      "total": 171798687744,
      "free": 7824457728,
      "used": 163974230016,
      "usedPercent": 95.445566068782,
      "inodesTotal": 0,
      "inodesUsed": 0,
      "inodesFree": 0,
      "inodesUsedPercent": 0
    },
    {
      "path": "D:",
      "fstype": "",
      "total": 338971062272,
      "free": 3926061056,
      "used": 335045001216,
      "usedPercent": 98.84177102620943,
      "inodesTotal": 0,
      "inodesUsed": 0,
      "inodesFree": 0,
      "inodesUsedPercent": 0
    }
  ],
  "host/info": {
    "hostname": "",
    "uptime": 360057,
    "bootTime": 1722819631,
    "procs": 345,
    "os": "windows",
    "platform": "",
    "platformFamily": "",
    "platformVersion": "22H2",
    "kernelVersion": "",
    "kernelArch": "x86_64",
    "virtualizationSystem": "",
    "virtualizationRole": "",
    "hostId": "1e81ede4-3433-8b94-990f-9438b1945ca2"
  },
  "mem/swapMemory": {
    "total": 19346468864,
    "used": 2621607936,
    "free": 16724860928,
    "usedPercent": 13.6,
    "sin": 0,
    "sout": 0,
    "pgIn": 0,
    "pgOut": 0,
    "pgFault": 0,
    "pgMajFault": 0
  },
  "mem/virtualMemory": {
    "total": 16499134464,
    "available": 900419584,
    "used": 15598714880,
    "usedPercent": 94,
    "free": 900419584,
    "active": 0,
    "inactive": 0,
    "wired": 0,
    "laundry": 0,
    "buffers": 0,
    "cached": 0,
    "writeBack": 0,
    "dirty": 0,
    "writeBackTmp": 0,
    "shared": 0,
    "slab": 0,
    "sreclaimable": 0,
    "sunreclaim": 0,
    "pageTables": 0,
    "swapCached": 0,
    "commitLimit": 0,
    "committedAS": 0,
    "highTotal": 0,
    "highFree": 0,
    "lowTotal": 0,
    "lowFree": 0,
    "swapTotal": 0,
    "swapFree": 0,
    "mapped": 0,
    "vmallocTotal": 0,
    "vmallocUsed": 0,
    "vmallocChunk": 0,
    "hugePagesTotal": 0,
    "hugePagesFree": 0,
    "hugePagesRsvd": 0,
    "hugePagesSurp": 0,
    "hugePageSize": 0,
    "anonHugePages": 0
  },
  "net/interfaces": [
    {
      "index": 14,
      "mtu": 1500,
      "name": "xx",
      "hardwareAddr": "fe:3a:35:21:0a:10",
      "flags": [
        "broadcast",
        "multicast"
      ],
      "addrs": [
        {
          "addr": "fe51::3521:5d11:2560:3917/64"
        },
        {
          "addr": "169.254.1.2/16"
        }
      ]
    }
  ],
  "net/ioCounters": [
    {
      "name": "WLAN",
      "bytesSent": 239207252,
      "bytesRecv": 140244972,
      "packetsSent": 161174,
      "packetsRecv": 292636,
      "errin": 0,
      "errout": 0,
      "dropin": 0,
      "dropout": 0,
      "fifoin": 0,
      "fifoout": 0
    }
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/04/02, 01:29:50
git 日志
OPC_UA订阅

← git 日志 OPC_UA订阅→

Theme by Vdoing | Copyright © 2023-2025 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式