IndustryKit
IndustryKit 是独立的只读工业数据采集器,部署在能够访问设备网络的 Linux 或 Windows
主机上。它从 PLC、仪表、OPC UA Server、MQTT Broker 和 SNMP 设备采集数据,并通过
Dataway 上报为指标(metric)或日志(logging)。
IndustryKit 不提供写寄存器、写线圈、PLC 控制、SNMP SET 或远程配置功能。
功能概览¶
| 协议 | 典型设备 | 采集方式 | 采集内容 |
|---|---|---|---|
| Modbus TCP/RTU | PLC、电表、仪表、变频器 | 主动轮询 | Coil、Discrete Input、Input Register、Holding Register |
| OPC UA | PLC、SCADA、OPC UA Server | Read 或订阅 | 配置的 Node ID、质量状态和源时间戳 |
| MQTT 3.1.1 | IoT 网关、传感器、MQTT Broker | 订阅消息 | JSON 或 text payload,可映射为指标或日志 |
| Siemens S7 | Siemens S7 PLC | 主动轮询 | DB、Input、Output 和 Marker 区域 |
| SNMP v3 | 交换机、网关、工业网络设备 | 主动 GET | 配置的数字 OID |
一个 IndustryKit 进程可以配置多个 source。Modbus、OPC UA、S7 和 SNMP 通过 point 定义采集地址及输出字段;MQTT 通过 topic 和 fields 定义消息映射。不同 source 可以使用 不同的 measurement。
运行要求¶
- 提供 Linux
amd64/arm64和 Windowsamd64/arm64发布包,在线安装脚本会自动识别架构。 - Linux 安装器要求正在运行 systemd,本文 Linux 命令默认以 root 用户执行。
- Windows 要求 Windows 10、Windows Server 2016 或更高版本,并使用管理员 Windows PowerShell 5.1 或更高版本。
- 部署主机必须能够访问目标设备或 Broker 的协议端口,并能通过 HTTP/HTTPS 访问 Dataway。
- 设备地址从 IndustryKit 所在主机解释;
127.0.0.1只表示该主机自身。跨机连接模拟器或设备时,对端还需监听可访问地址并放通防火墙。 - 连接受保护设备时,需要提前准备设备账号、SNMP v3 凭据或 TLS 证书等信息。
- Modbus TCP、经典 S7、OPC UA
None和 MQTTtcp://本身不提供链路加密,应仅用于可信工业网络、VPN 或受防火墙限制的网段。 - 当前不提供官方容器镜像。
安装¶
首次安装必须提供包含 token query 参数的完整 Dataway URL。可选设置 INDUSTRYKIT_COLLECTOR_ID 指定采集器
实例 ID;未设置时使用主机名。ID 支持中文等 Unicode 字符,不能全为空白或包含控制字符。
Dataway URL 使用 http:// 或 https:// 绝对地址,必须包含唯一且非空的 token query 参数,
不得包含 userinfo 或 fragment;写入路径由 IndustryKit 自动追加。
安装最新版本:
INDUSTRYKIT_DATAWAY_URL="https://openway.guance.com?token=<DATAWAY_TOKEN>" \
sh -c "$(curl -fsSL https://static.guance.com/industrykit/install.sh)"
安装指定版本时,将下载地址中的 install.sh 替换为 install-<VERSION>.sh,
例如 install-v1.0.1.sh。
安装脚本会自动选择 amd64 或 arm64 软件包、校验 SHA-256、安装文件并注册
industrykit.service。默认配置尚未启用任何 source,因此服务保持 disabled/stopped。
在管理员 PowerShell 中安装最新版本:
Remove-Item -ErrorAction SilentlyContinue Env:INDUSTRYKIT_*;
$env:INDUSTRYKIT_DATAWAY_URL = "https://openway.guance.com?token=<DATAWAY_TOKEN>";
Set-ExecutionPolicy Bypass -Scope Process -Force;
Import-Module BitsTransfer;
Start-BitsTransfer -Source https://static.guance.com/industrykit/install.ps1 -Destination .install.ps1;
powershell ./.install.ps1;
安装指定版本时,将下载地址中的 install.ps1 替换为
install-<VERSION>.ps1。
安装脚本会自动选择 amd64 或 arm64 软件包、校验 SHA-256、安装文件,并将
industrykit 注册为 Manual 类型的 Windows 服务。默认配置尚未启用任何 source,
因此服务保持 stopped。
安装目录¶
| 内容 | Linux | Windows |
|---|---|---|
| 主程序 | /usr/local/bin/industrykit |
%ProgramFiles%\IndustryKit\industrykit.exe |
| 运行配置 | /etc/industrykit/industrykit.toml |
%ProgramFiles%\IndustryKit\industrykit.toml |
| 配置样例 | /etc/industrykit/industrykit.toml.sample |
%ProgramFiles%\IndustryKit\industrykit.toml.sample |
| WAL | /var/lib/industrykit/wal |
%ProgramData%\IndustryKit\wal |
| 运行日志 | /var/log/industrykit/industrykit.log |
%ProgramData%\IndustryKit\logs\industrykit.log |
| PKI(按需) | /etc/industrykit/pki(需管理员创建) |
%ProgramData%\IndustryKit\pki |
| 服务 | industrykit.service |
industrykit |
| 服务定义 | /etc/systemd/system/industrykit.service |
Windows SCM |
Linux 安装需要管理员权限,但服务默认以非 root 的 industrykit 用户运行。Modbus RTU
还需为该用户授予串口权限,详见 Modbus Linux 串口权限。
Linux 配置目录、数据根目录和日志目录为 0755,配置及样例为 0644,普通用户可浏览
目录、读取配置,修改配置仍需管理员权限。新建日志文件保留日志库的 0600 权限;新建
WAL 分类目录及数据文件沿用 diskcache 的 0750 / 0640,查看其内容可能仍需管理员权限。
Windows 安装目录、配置、日志、WAL 和 PKI 沿用父目录的权限,不额外限制为管理员专属。 实际读写权限取决于系统设置;安装、升级和服务管理仍需管理员权限。保存配置时若提示拒绝 访问,请以管理员身份启动编辑器。
配置并启动¶
安装生成的 industrykit.toml 已包含 Dataway、日志、WAL 和采集器 ID,并附带五种协议的
注释示例。默认没有生效的 [[sources]],此时启动进程不会采集设备数据。
配置格式版本使用 version = 1。公共配置字段如下,设备协议字段见后面的协议文档。
[collector]¶
| 字段 | 默认值 | 说明 |
|---|---|---|
id |
安装器默认使用主机名 | 采集器实例 ID,手写配置时必填;作为 collector_id 标签上报。 |
tags |
{} |
添加到所有数据的全局标签,例如站点、机房或环境。 |
listen |
127.0.0.1:19090 |
健康检查和自身指标监听地址;只允许 loopback 地址。 |
shutdown_timeout |
10s |
优雅停止各阶段的超时时间。 |
channel_capacity |
50000 |
metric 和 logging 输入通道容量,范围为 1..131072;通常无需修改。 |
[logging]¶
| 字段 | 默认值 | 说明 |
|---|---|---|
log |
平台默认日志路径 | IndustryKit 自身运行日志文件;相对路径按配置文件所在目录解析。 |
level |
info |
日志级别:debug、info、warn 或 error。 |
rotate |
32 |
单个日志文件达到该大小后轮转,单位 MiB。 |
rotate_backups |
5 |
保留的轮转备份文件数量。 |
日志最长保留 30 天,该时间目前不可配置。
这里的 [logging] 是 IndustryKit 自身运行日志,不是设备数据的 category = "logging"。
[dataway] 与可选的 [dataway.tls]¶
| 字段 | 默认值 | 说明 |
|---|---|---|
url |
无 | 必填的 Dataway http/https 绝对地址,必须包含唯一且非空的 token query 参数,不得包含 userinfo 或 fragment。 |
timeout |
10s |
单次 HTTP 请求超时。 |
tls.ca_file |
空 | 额外信任的 CA PEM 文件。 |
tls.cert_file |
空 | mTLS 客户端证书,必须与 tls.key_file 同时配置。 |
tls.key_file |
空 | mTLS 客户端私钥,必须与 tls.cert_file 同时配置。 |
tls.server_name |
空 | 可选的 TLS SNI 和证书校验名称。 |
TLS 证书使用相对路径时,以主配置文件所在目录为基准。
[dataway.batch]¶
| 字段 | 默认值 | 说明 |
|---|---|---|
max_points |
1000 |
每个 metric 或 logging 批次的最大点数,上限为 1000。 |
max_bytes |
524288 |
单批 gzip 压缩前的最大编码大小,单位字节,上限为 524288。 |
flush_interval |
1s |
即使未达到点数或大小限制,也会按该间隔发送当前批次。 |
点数、大小或等待时间任一条件先达到,当前批次就会进入 WAL 等待发送。
[dataway.wal]¶
| 字段 | 默认值 | 说明 |
|---|---|---|
path |
Linux:/var/lib/industrykit/wal;Windows:%ProgramData%\IndustryKit\wal |
WAL 根目录,内部按 metric 和 logging 分开保存;相对路径按配置文件所在目录解析。 |
max_bytes |
2147483648 |
metric 和 logging 每个队列各自的容量阈值,单位字节;达到阈值后拒绝新批次,默认两类合计约 4 GiB。 |
max_age |
12h |
未成功发送批次的最长保留时间。 |
retry_min |
1s |
可重试错误的最小退避时间。 |
retry_max |
1m |
最大退避时间,也会限制服务端 Retry-After。 |
Dataway 返回成功响应后才会删除 WAL 记录;容量已满时拒绝新批次,超过保留时间的记录在消费时丢弃。
[[sources]] 通用字段¶
| 字段 | 默认值 | 说明 |
|---|---|---|
id |
无 | 必填且在当前配置中唯一;作为 source_id 标签上报。 |
type |
无 | 必填:modbus、opcua、mqtt、s7 或 snmp。 |
measurement |
industrial |
上报到观测云的指标集或日志来源名称,建议按协议或业务显式命名。 |
interval |
10s |
轮询类 source 的采集周期;SNMP 建议显式使用 30s。MQTT 和 OPC UA subscribe 不依赖它控制消息频率。 |
tags |
{} |
当前 source 的静态标签,会与全局标签合并。 |
Point 通用字段¶
Modbus、OPC UA、S7 和 SNMP 的 [[sources.<type>.points]] 共用以下字段;MQTT 使用 topic
映射,字段见 MQTT 配置。
| 字段 | 默认值 | 说明 |
|---|---|---|
field |
无 | 必填的输出字段名。 |
category |
metric |
输出类型:metric 或 logging。 |
tags |
{} |
当前点位的静态标签,会与全局和 source 标签合并。 |
scale / offset |
1 / 0 |
Modbus、S7 和 SNMP 的数值转换公式为 value * scale + offset;当前 OPC UA 不应用这两个字段。 |
on_change |
false |
设为 true 时,metric 仅在值变化后发送;logging 本身始终按变化发送。 |
emit_initial |
false |
logging 或启用 on_change 的 metric 是否发送首次观察值;默认只建立变化基线。 |
status |
info |
logging 的状态字段。 |
collector_id、protocol 和 source_id 是系统自动添加的固定标签,不能在 tags 中配置。
选择需要的协议文档,将完整 source 示例取消注释或复制到配置文件,并替换设备地址、
点位、<...> 凭据占位值和证书路径:
| 协议配置 | 需要从设备侧确认的主要信息 |
|---|---|
| Modbus TCP/RTU | IP/串口、Unit ID、寄存器区域、地址和数据类型 |
| OPC UA | Endpoint、认证与安全策略、Node ID |
| MQTT | Broker、认证、topic filter 和 payload 结构 |
| Siemens S7 | PLC 地址、rack/slot、DB/区域和 byte offset |
| SNMP v3 | Agent 地址、USM 凭据和 OID |
每个 source 还必须配置与 type 同名的协议子表。输出映射如下:
category |
字段来源 | 发送方式 |
|---|---|---|
metric |
point 的 field,或 MQTT topic 的 fields/value_field |
轮询或收到消息时发送,可用 on_change 抑制未变化的 point。 |
logging |
point 固定为 message、status、value;MQTT 为 message、status |
point 默认只在值变化时发送;MQTT 每条匹配消息发送。 |
修改配置后先执行校验,校验通过后启动服务:
开机自启为可选项:Linux 执行 systemctl enable industrykit;Windows 在管理员
PowerShell 中执行 Set-Service -Name industrykit -StartupType Automatic。
配置只在启动时读取,后续修改配置需要重启服务。
配置支持 ${ENV_NAME} 变量引用,但 systemd 和 Windows 服务不会自动继承当前终端中的
临时环境变量。使用该写法时,应通过对应服务管理器持久配置环境变量;否则直接在 TOML 中
填写实际值。配置含有凭据,请根据本机安全要求检查并设置读取权限。
验证采集与上报¶
服务启动后,先检查本地健康端点:
重点关注以下自身指标:
| 指标 | 说明 |
|---|---|
industrykit_source_up |
source 最近一次连接或轮询是否成功,正常值为 1。 |
industrykit_samples_total |
已接收的设备样本数,正常采集时持续增加。 |
industrykit_dataway_points_total |
已成功发送到 Dataway 的点数,正常上报时持续增加。 |
/readyz 只表示进程和 WAL 可以继续接收数据,不代表设备一定在线。判断完整链路时,应同时
检查 source 状态、样本数、Dataway 发送数和运行日志。Modbus、S7、SNMP 或 OPC UA poll
至少等待一轮 interval;OPC UA subscribe 等待节点更新;MQTT 则需要发布端产生匹配消息。
随后在观测云中查询 source 配置的 measurement;category = "logging" 的数据在日志中查询。
查看运行日志:
升级¶
升级必须显式设置 INDUSTRYKIT_UPGRADE=1。默认升级保留现有 Dataway;提供新的完整 URL
时只更新 [dataway].url。
升级到最新版本:
如需同时更新 Dataway,在命令中增加包含 token 的 INDUSTRYKIT_DATAWAY_URL。
升级到最新版本:
Remove-Item -ErrorAction SilentlyContinue Env:INDUSTRYKIT_*;
$env:INDUSTRYKIT_UPGRADE = "1";
Set-ExecutionPolicy Bypass -Scope Process -Force;
Import-Module BitsTransfer;
Start-BitsTransfer -Source https://static.guance.com/industrykit/install.ps1 -Destination .install.ps1;
powershell ./.install.ps1;
如果升级时需要同时更新 Dataway,请在 $env:INDUSTRYKIT_UPGRADE 之后、
Set-ExecutionPolicy 之前插入:
升级到指定版本时,使用 install-<VERSION>.sh 或 install-<VERSION>.ps1。升级会替换
程序;Linux 同时刷新 systemd unit,Windows 校验并沿用已有 SCM 服务定义。现有配置、WAL、
日志、Linux enable 状态和 Windows 启动类型会保留;升级前正在运行的服务会重启,原本停止
的服务仍保持停止。
服务与命令¶
| 操作 | Linux | Windows 管理员 PowerShell |
|---|---|---|
| 校验配置 | industrykit validate --config /etc/industrykit/industrykit.toml |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" validate --config "$env:ProgramFiles\IndustryKit\industrykit.toml" |
| 查看版本 | industrykit version |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" version |
| 启动服务 | systemctl start industrykit |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" service start |
| 停止服务 | systemctl stop industrykit |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" service stop |
| 重启服务 | systemctl restart industrykit |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" service restart |
| 查看状态 | systemctl status industrykit |
Get-Service industrykit |
| 前台运行 | industrykit run --config /etc/industrykit/industrykit.toml |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" run --config "$env:ProgramFiles\IndustryKit\industrykit.toml" |
| 注销服务 | industrykit service uninstall |
& "$env:ProgramFiles\IndustryKit\industrykit.exe" service uninstall |
service uninstall 只注销服务,不删除程序、配置、WAL 或日志。Linux 注销后可重新执行
安装命令(不带 INDUSTRYKIT_UPGRADE),保留已有配置并重新注册服务,仍需手动启动。
已有配置时可省略 Dataway 参数;提供时只更新 [dataway].url。Windows 暂不支持保留文件直接重装。
注意事项¶
validate只校验配置结构和参数,不连接设备、Broker 或 Dataway。- 点位地址、Node ID、DB offset 和 OID 并不由 IndustryKit 自动发现,应以设备手册、工程配置或现场扫描结果为准。