Date: Mon, 11 Jan 2021 13:21:07 +0100 From: Polytropon <freebsd@edvax.de> To: Scott <freebsd-lists-5@thismonkey.com> Cc: freebsd-questions@freebsd.org Subject: Re: Need help specifying args in rc.conf for a service Message-ID: <20210111132107.82de40d0.freebsd@edvax.de> In-Reply-To: <X/w9IwVAFXyDr/ir@thismonkey.com> References: <X/w9IwVAFXyDr/ir@thismonkey.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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, ...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210111132107.82de40d0.freebsd>