[实战]Zabbix5.2下MODBUS对接IOT设备

自10月份Zabbix发布5.2版本宣布兼容MODBUS和MQTT协议以来,我就有一种万物皆为我所监控的冲动,于是乎我开始了漫长的搜罗MODBUS的监控场景。

终于,我找到了一套优秀的MODBUS的设备,并且做了一套适配的模版,下面来详细讲讲我的实战过程与期间遇到的各种坑。如果你对我的文章感兴趣,请加入我们的QQ群:Zabbix研究院(QQ群:1107902496)

 

1、Zabbix 的modbus接口在哪里?

根据https://support.zabbix.com/browse/ZBXNEXT-6090发布的说明,我找到了agent2对modbus支持的相关说明。

那么,创建主机的时候,监控的接口选择肯定是Zabbix Agent/主动式的AGENT了。

2、Zabbix的Modbus模版怎么做?

于是乎我就创建了一个监控项寻找了一番。如下图:

3、这个modbus的键值,对应的参数,该怎么设置?

参照zabbix链接:https://www.zabbix.com/documentation/current/manual/appendix/items/modbus

ParameterDescriptionDefaultsExample
endpointProtocol and address of the endpoint, defined as protocol://connection_string

Possible protocol values: rtuascii (Agent 2 only), tcp

Connection string format:

with tcp - address:port
with serial line: rtuascii - port_name:speed:params
where
'speed' - 1200, 9600 etc
'params' - data bits (5,6,7 or 8), parity (n,e or o for none/even/odd), stop bits (1 or 2)
protocol: none

rtu/ascii protocol:
port_name: none
speed: 115200
params: 8n1

tcp protocol:
address: none
port: 502
tcp://192.168.6.1:511
tcp://192.168.6.2
tcp://[::1]:511
tcp://::1
tcp://localhost:511
tcp://localhost
rtu://COM1:9600:8n
ascii://COM2:1200:7o2
rtu://ttyS0:9600
ascii://ttyS1
slave idModbus address of the device it is intended for (1 to 247), see MODBUS Messaging Implementation Guide (page 23)

tcp device (not GW) will ignore the field
serial: 1

tcp: 255 (0xFF)
2
functionEmpty or value of a supported function:

1 - Read Coil,
2 - Read Discrete Input,
3 - Read Holding Registers,
4 - Read Input Registers
empty3
addressAddress of the first registry, coil or input.

If 'function' is empty, then 'address' should be in range for:
Coil - 00001 - 09999
Discrete input - 10001 - 19999
Input register - 30001 - 39999
Holding register - 40001 - 49999

If 'function' is not empty, the 'address' field will be from 0 till 65535 and used without modification (PDU)
empty function: 00001

non-empty function: 0
9999
countCount of sequenced 'type' which will be read from device, where:

for Coil or Discrete input the 'type' = 1 bit
for other cases: (count*type)/2 = real count of registers for reading
If 'offset' is not 0, the value will be added to 'real count'
Acceptable range for 'real count' is 1:65535
12
typeData type:

for Read Coil and Read Discrete Input - bit

for Read Holding Registers and Read Input Registers:
int8 - 8bit
uint8 - 8bit (unsigned)
int16 - 16bit
uint16 - 16bit (unsigned)
int32 - 32bit
uint32 - 32bit (unsigned)
float - 32bit
uint64 - 64bit (unsigned)
double - 64bit
bit
uint16
uint64
endiannessEndianness type:
be - Big Endian
le - Little Endian
mbe - Mid-Big Endian
mle - Mid-Little Endian

Limitations:
for 1 bit - be
for 8 bits - be,le
for 16 bits - be,le
bele
offsetNumber of registers, starting from 'address', the result of which will be discarded.

The size of each register is 16bit (needed to support equipment that does not support random read access).
04

4、我们根据以上的配置,做了数据中心机房的机柜门的开关探测、温湿度、PDU的监测、UPS、精密空调等监控。结合之前做的基础架构的监控。实现了统一监控管理的目标。

 

5、参考:基于MODBUS协议的PDU指标监控

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值