Need help specifying args in rc.conf for a service

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Need help specifying args in rc.conf for a service

Scott Aitken-3
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.

It was suggested on the forum to try:
node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'
# OR
node_exporter_args="--collector.filesystem.ignored-mount-points='^/(dev)($|/)'"

However with the first suggestion I got:
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)(\$|/)""'
Badly placed (.

and with the second I got:
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)($|/)\'"\''
eval: 1: Syntax error: "(" unexpected

Can anyone please help?

Thanks,
Scott
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Polytropon
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, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Scott Aitken-3
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
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Polytropon
On Mon, 11 Jan 2021 23:55:39 +1100, Scott wrote:

> 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. ;-)
> >
> > [...]
> >
> 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.

So there seems to be another "layer" of possible interpretation.
The call to sh contains still a single $ which leads to the error.
Maybe using the quoted form \$ would help here?

        node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'

It's not entirely trivial to deal with several layers of
variable expansion, especially when you want to avoid it. ;-)

Another option is to make the ' part of the option argument, but
that would be quite ugly (and maybe doesn't work):

        node_exporter_args="--collector.filesystem.ignored-mount-points='^/(dev)(\$|/)'"

Maybe you can try that as well?




--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Scott Aitken-3
On Mon, Jan 11, 2021 at 02:31:39PM +0100, Polytropon wrote:

> On Mon, 11 Jan 2021 23:55:39 +1100, Scott wrote:
> > 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. ;-)
> > >
> > > [...]
> > >
> > 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.
>
> So there seems to be another "layer" of possible interpretation.
> The call to sh contains still a single $ which leads to the error.
> Maybe using the quoted form \$ would help here?
>
> node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'
>
> It's not entirely trivial to deal with several layers of
> variable expansion, especially when you want to avoid it. ;-)
>
> Another option is to make the ' part of the option argument, but
> that would be quite ugly (and maybe doesn't work):
>
> node_exporter_args="--collector.filesystem.ignored-mount-points='^/(dev)(\$|/)'"
>
> Maybe you can try that as well?
>
>
>
>
> --
> Polytropon
> Magdeburg, Germany
> Happy FreeBSD user since 4.0
> Andra moi ennepe, Mousa, ...

Thanks again, but no luck:

with: 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)(\$|/)""'
Badly placed (.

with: 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)($|/)\'"\''
eval: 1: Syntax error: "(" unexpected

Scott
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Scott Aitken-3
In reply to this post by Scott Aitken-3
On Tue, Jan 12, 2021 at 09:35:58AM -0500, James B. Byrne wrote:

>
>
> On Mon, January 11, 2021 07:55, Scott wrote:
> >
> > 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
> >
> >
>
> Try escaping the '$' character (\$).
>
>
> node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'
>
> --
> ***          e-Mail is NOT a SECURE channel          ***
>         Do NOT transmit sensitive data via e-Mail
>    Unencrypted messages have no legal claim to privacy
>  Do NOT open attachments nor follow links sent by e-Mail
>
> James B. Byrne                mailto:[hidden email]
> Harte & Lyne Limited          http://www.harte-lyne.ca
> 9 Brockley Drive              vox: +1 905 561 1241
> Hamilton, Ontario             fax: +1 905 561 0757
> Canada  L8E 3C3
>

No joy:

+ _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)(\$|/)""'
Badly placed (.

Cheers
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: Need help specifying args in rc.conf for a service

Polytropon
On Wed, 13 Jan 2021 10:36:01 +1100, Scott wrote:

> On Tue, Jan 12, 2021 at 09:35:58AM -0500, James B. Byrne wrote:
> >
> >
> > On Mon, January 11, 2021 07:55, Scott wrote:
> > >
> > > 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
> > >
> > >
> >
> > Try escaping the '$' character (\$).
> >
> >
> > node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'
> > [...]
>
> No joy:
>
> + _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)(\$|/)""'
> Badly placed (.

The last error indicates that there still is a problem with
escaping and quoting. You'd have to find a combination of ",
' and \ to make it work.

Another idea: Create a file /etc/ignore.txt with the following
content:

        "^/(dev)(\$|/)"

Make sure no \n follows - the 2nd " should be the last symbol
in the file, its size therefore be 15 bytes.

In /etc/rc.conf, try:

        node_exporter_args="--collector.filesystem.ignored-mount-points=`/in/cat /etc/ignore.txt`"

It's not fully clear to me where the expansion attempt happens,
but it seems that it happens in at least two places: first in
/etc/rc.conf, which turns \$ into literal $, and further down
in the "starter script" which reads $ and tries to expand it,
instead of using it "as is". The idea is to keep at least one
of those possible interpreters from interpreting, which almost
every time leads to a predictable mis-interpretation.

To avoid this, try /etc/ignore.txt with:

        '^/(dev)($|/)'

or maybe even:

        '^/(dev)(\$|/)'

Finally, you have the ability to hard-code the $ at the last
place it will be processed, checking the "surrounding" for any
possible variable evalation. That is of course not an ideal
solution, but it might be a working solution. Create a diff for
it so you can apply it after each program upgrade.


--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[hidden email]"