Перейти к содержанию

modbus_rtu collector

modbus_rtu collector performs Modbus RTU requests over the serial line to collect performance data.

Configuration

ParameterTypeDefaultDescription
idStringCollector's ID. Must be unique per agent instance. Will be returned along with the metrics.
typeStringMust be modbus_rtu
serviceStringEqual to idService id for output metrics
intervalIntegerRepetition interval in seconds
labelsArray of StringsList of additional labels. Will be returned along with metrics
serial_pathStringPath to the serial port device (i.e. /dev/ttyS1)
slaveIntegerModbus RTU slave id
baud_rateIntegerSerial port speed
data_bitsIntegerSerial port data bits: 5, 6, 7 or 8
parityStringnoneSerial port parity, either none, even or odd
stop_bitsIntegerSerial port stop bits, either 1 or 2
registerIntegerStarting register of modbus request, zero-based
register_typeStringholdingModbus request type. Either holding, input or coil
formatStringExpected response format. See Response format for details
timeout_msInteger5000Request timeout, ms.

Check address notation

Take note the starting register address is zero-based, while vendors can document the registers starting from 1. Refer to the vendor documentation and subtract 1 when necessary.

Response Format

Modbus' response is as an array of 16-bit integers. Actual data encoding should be set as format parameter. Some encodings may require reading 2 or 4 adjacent registers.

FormatCountDescription
i16_be116-bit signed integer, big-endian.
u16_be116-bit unsigned integer, big-endian.
i32_be232-bit signed integer, big-endian
i32_le232-bit signed integer, low-endian
i32_bs232-bit signed integer, big-endian, swapped
i32_ls232-bit signed integer, low-endian, swapped
u32_be232-bit unsigned integer, big-endian
u32_le232-bit unsigned integer, low-endian
u32_bs232-bit unsigned integer, big-endian, swapped
u32_ls232-bit unsigned integer, low-endian, swapped
f32_be232-bit floating point, big-endian
f32_le232-bit floating point, low-endian
f32_bs232-bit floating point, big-endian, swapped
f32_ls232-bit floating point, low-endian, swapped

Big/Low/Swapped endian

32-bit integer 0x01020304 stored as a sequence of 4 octets. 4 different approaches widely used between modbus devices:

Format1234
Big-endian (be)01020304
Low-endian (le)04030201
Big-endian, swapped (bs)02010403
Low-endian, swapped (ls)03040102

Collected Metrics

MetricMetric TypePlatformDescription
tsAllISO 8601 Timestamp
collectorAllCollector Id
labelsAllList of labels
valueAllMeasured value

Compilation Features

Enable modbus_rtu feature during compiling the agent (Enabled by default).