Need help specifying args in rc.conf for a service
Polytropon
freebsd at edvax.de
Mon Jan 11 12:21:22 UTC 2021
On Mon, 11 Jan 2021 22:57:23 +1100, Scott wrote:
> Hi all,
>
> I posted this on the forums and was unsuccessful so I thought I'd try here:
>
> I've been struggling to pass additional arguments to the Prometheus
> node_exporter daemon in /etc/rc.conf.
>
> The help for node_exporter provides an example argument (mount points to
> ignore) as:
>
> --collector.filesystem.ignored-mount-points="^/(dev)($|/)"
> Regexp of mount points to ignore for filesystem collector.
>
> The rc script says to use the _args variable to specify arguments to
> node_exporter:
> # node_exporter_args (string): Set extra arguments to pass to
> # Default is "".
>
> Adding the line:
>
> node_exporter_args="--collector.filesystem.ignored-mount-points=\"^/(dev)($|/)\""
>
> to /etc/rc.conf and running sh -x /usr/local/etc/rc.d/node_exporter start
> results in:
>
> + limits -C daemon su -m nobody -c 'sh -c "/usr/sbin/daemon -f -p /var/run/node_exporter.pid -T node_exporter /usr/bin/env /usr/local/bin/node_exporter --web.listen-address=:9100 --collector.textfile.directory=/var/tmp/node_exporter --collector.filesystem.ignored-mount-points="^/(dev)($|/)""'
>
> Illegal variable name.
>
> [...]
>
> Can anyone please help?
If I see this correctly, the argument given to to the program's
option --collector.filesystem.ignored-mount-points= is to be a
regex, not the result of evaluating the regex (which the program
surely does internally). So my suggestion, without knowing any
further details, is to use this in /etc/rc.conf:
node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)($|/)"'
Always remember that /etc/rc.conf is, more or less, just a simple
shell script, so all rules applying to sh will apply to rc.conf
exactly. That's why 'single quotes' will stop any expansion and
transfer the value 1:1, which I think is what you are require to
do here. Characters such as $, " or ^ will be part of the string
handed over to the program, and will _not_ be interpreted by the
shell prior to assigning to the _args variable.
Within "double quotes", symbols such as $ have a specific meaning,
that's why you see the error ($ not properly quoted). So the
error message is completely valid and logical - and expected. ;-)
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions
mailing list