fix(inputs.s7comm): Allow PDU-size to be set as config option (#14045)
This commit is contained in:
parent
4759214471
commit
30bbf4fb62
|
|
@ -23,6 +23,9 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
rack = 0
|
||||
slot = 0
|
||||
|
||||
## Max count of fields to be bundled in one batch-request. (PDU size)
|
||||
# pdu_size = 20
|
||||
|
||||
## Timeout for requests
|
||||
# timeout = "10s"
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
//go:embed sample.conf
|
||||
var sampleConfig string
|
||||
|
||||
const maxRequestsPerBatch = 20
|
||||
const addressRegexp = `^(?P<area>[A-Z]+)(?P<no>[0-9]+)\.(?P<type>[A-Z]+)(?P<start>[0-9]+)(?:\.(?P<extra>.*))?$`
|
||||
|
||||
var (
|
||||
|
|
@ -85,6 +84,7 @@ type S7comm struct {
|
|||
Server string `toml:"server"`
|
||||
Rack int `toml:"rack"`
|
||||
Slot int `toml:"slot"`
|
||||
BatchMaxSize int `toml:"pdu_size"`
|
||||
Timeout config.Duration `toml:"timeout"`
|
||||
DebugConnection bool `toml:"debug_connection"`
|
||||
Configs []metricDefinition `toml:"metric"`
|
||||
|
|
@ -223,7 +223,7 @@ func (s *S7comm) createRequests() error {
|
|||
current.mappings = append(current.mappings, m)
|
||||
|
||||
// If the batch is full, start a new one
|
||||
if len(current.items) == maxRequestsPerBatch {
|
||||
if len(current.items) == s.BatchMaxSize {
|
||||
s.batches = append(s.batches, current)
|
||||
current = batch{}
|
||||
}
|
||||
|
|
@ -402,9 +402,10 @@ func fieldID(seed maphash.Seed, def metricDefinition, field metricFieldDefinitio
|
|||
func init() {
|
||||
inputs.Add("s7comm", func() telegraf.Input {
|
||||
return &S7comm{
|
||||
Rack: -1,
|
||||
Slot: -1,
|
||||
Timeout: config.Duration(10 * time.Second),
|
||||
Rack: -1,
|
||||
Slot: -1,
|
||||
BatchMaxSize: 20,
|
||||
Timeout: config.Duration(10 * time.Second),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
rack = 0
|
||||
slot = 0
|
||||
|
||||
## Max count of fields to be bundled in one batch-request. (PDU size)
|
||||
# pdu_size = 20
|
||||
|
||||
## Timeout for requests
|
||||
# timeout = "10s"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue