Zabbix server-active configuration syntax problem/bug in 1.4 and 1.5

System: VyOS 1.4, private build from the 1.4 Sagitta branch, pulled February 5, 2024.

I’ve verified the same issue exists in the latest 1.5 rolling image as well; tested on vyos-1.5-rolling-202408160021-amd64 – identical behavior

In brief:

I’m trying to write a custom migration script that sets the system monitoring zabbix-agent server-active parameter, as well as a server-active port when I install a new image, however, the resulting config formatting breaks the config parser.

In detail:

Goal: set the zabbix server-active hostname and port with a migration script.

What does work: CLI

If I use the CLI to set the parameter, the syntax goes like this:

config
set service monitoring zabbix-agent server zabbix.example.com
set service monitoring zabbix-agent port 10050
set service monitoring zabbix-agent server-active zabbix.example.com port 10051
commit
save

The resulting config looks like this:

monitoring {
    zabbix-agent {
        server-active zabbix.example.com {
            port 10051
        }
        port 10050
        server zabbix.example.com
    }
}

All good.

Where it breaks: migration script

However, if I try to set the server-active details in a custom migration script, like so:

config.set(['service', 'monitoring', 'zabbix-agent', 'server-active', 'zabbix.example.com', 'port'], value='10051')

THEN the resulting config looks like this:

    monitoring {
        zabbix-agent {
            server-active {
                zabbix.example.com {
                    port "10051"
                }
            }
            port "10050"
            server "zabbix.example.com"
        }
    }

which breaks the system at boot-time when the new image runs the migration: the config file parser chokes on the unexpected . in the zabbix.example.com “hostname” under server-active at boot time with this error (running with vyos-config-debug enabled at boot):

vyos@vyosrouter:~$ cat /tmp/boot-config-trace 
Traceback (most recent call last):
  File "/usr/libexec/vyos/vyos-boot-config-loader.py", line 141, in <module>
    load_out = session.load_config(file_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 201, in load_config
    out = self.__run_command(LOAD_CONFIG + [file_path])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configsession.py", line 144, in __run_command
    raise ConfigSessionError(output)
vyos.configsession.ConfigSessionError: Invalid config file (syntax error): error at line 1514, text [.]
Failed to parse specified config file

Can one of the developers weigh in on this? Or maybe someone sees what I’m doing wrong?

Proposed solution:

In my opinion, the relevant bit of config syntax should look like this instead:

set service monitoring zabbix-agent server-active host zabbix.example.com
set service monitoring zabbix-agent server-active port 10051

which would result in a config something like this:

    monitoring {
        zabbix-agent {
            server-active {
                host "zabbix.example.com"
                port "10051"
                }
            port "10050"
            server "zabbix.example.com"
        }
    }

I’m happy to open a ticket on Phabricator if that’s the preferred place to discuss further.

This topic was automatically closed after 14 days. New replies are no longer allowed.