Date: Mon, 11 Jan 2021 23:55:39 +1100 From: Scott <freebsd-lists-5@thismonkey.com> To: Polytropon <freebsd@edvax.de> Cc: freebsd-questions@freebsd.org Subject: Re: Need help specifying args in rc.conf for a service Message-ID: <X/xKy6Y6Cl4%2Bzkhd@thismonkey.com> In-Reply-To: <20210111132107.82de40d0.freebsd@edvax.de> References: <X/w9IwVAFXyDr/ir@thismonkey.com> <20210111132107.82de40d0.freebsd@edvax.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 11, 2021 at 01:21:07PM +0100, Polytropon wrote: > 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, ... > Thanks Poly, here's what I get using: node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)($|/)"' + _doit=$' 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)($|/)""\'' + _run_rc_doit $' 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)($|/)""\'' + debug $'run_rc_command: doit: 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)($|/)""\'' + eval $' 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)($|/)""\'' + 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. Thanks
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?X/xKy6Y6Cl4%2Bzkhd>