diff options
author | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2022-04-22 10:40:08 +0300 |
---|---|---|
committer | Vladislavs Sokurenko <vladislavs.sokurenko@zabbix.com> | 2022-04-22 10:48:02 +0300 |
commit | 89aeb3281a8d688569212781e9e9e65531da8b2b (patch) | |
tree | d872b0cb6bdb6ea5f1e9f2967af47c31054ea8be /src | |
parent | 51b750686659d89145bd1e7eacdbc6dcc1109011 (diff) |
A..G...... [ZBX-20783] fixed Zabbix agent2 not to fail when global regular expression is received with empty delimiter
Diffstat (limited to 'src')
-rw-r--r-- | src/go/internal/agent/serverconnector/serverconnector.go | 2 | ||||
-rw-r--r-- | src/go/pkg/glexpr/expression.go | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/go/internal/agent/serverconnector/serverconnector.go b/src/go/internal/agent/serverconnector/serverconnector.go index 275605e12ff..a0d2796d19b 100644 --- a/src/go/internal/agent/serverconnector/serverconnector.go +++ b/src/go/internal/agent/serverconnector/serverconnector.go @@ -284,7 +284,7 @@ func (c *Connector) refreshActiveChecks() { return } - if len(*response.Expressions[i].Delimiter) != 1 { + if len(*response.Expressions[i].Delimiter) > 1 { log.Errf(`[%d] cannot parse list of active checks from [%s]: invalid tag "exp_delimiter" value "%s"`, c.clientID, c.addresses[0], *response.Expressions[i].Delimiter) return diff --git a/src/go/pkg/glexpr/expression.go b/src/go/pkg/glexpr/expression.go index 44d328a3530..3f2ab0b48b5 100644 --- a/src/go/pkg/glexpr/expression.go +++ b/src/go/pkg/glexpr/expression.go @@ -86,7 +86,13 @@ func NewBundle(expressions []*Expression) (bundle *Bundle) { bundle = &Bundle{expressions: expressions} bundle.Cblob = zbxlib.NewGlobalRegexp() for _, e := range expressions { - zbxlib.AddGlobalRegexp(bundle.Cblob, e.Name, e.Body, *e.Type, (*e.Delimiter)[0], *e.Mode) + var delimeter byte = ',' + + if 0 != len(*e.Delimiter) { + delimeter = (*e.Delimiter)[0] + } + + zbxlib.AddGlobalRegexp(bundle.Cblob, e.Name, e.Body, *e.Type, delimeter, *e.Mode) } runtime.SetFinalizer(bundle, func(b *Bundle) { zbxlib.DestroyGlobalRegexp(b.Cblob) }) return |