# Need help specifying args in rc.conf for node_exporter



## scotia (Jan 1, 2021)

Hi all,

I've been struggling for an hour 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 node_exporter
#               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 someone please help me format the line in /etc/rc.conf so that I can start the daemon?

Thanks,
Scott


----------



## SirDice (Jan 2, 2021)

The `node_exporter_args` string is in double quotes, that gives special meaning to the $ character as the start of a variable to interpret. Escape it, you want a _literal_ $, not as a variable. That's what the error is telling you, the `$|` is an illegal variable.

You can also use single quotes ' instead of double quotes ": Strong versus weak quoting, so you don't need to escape the double quotes.


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

NB. rc.conf is in essence a shell script that only contains variables. It gets sourced multiple times by the various rc(8) scripts.


----------



## scotia (Jan 3, 2021)

SirDice said:


> The `node_exporter_args` string is in double quotes, that gives special meaning to the $ character as the start of a variable to interpret. Escape it, you want a _literal_ $, not as a variable. That's what the error is telling you, the `$|` is an illegal variable.
> 
> You can also use single quotes ' instead of double quotes ": Strong versus weak quoting, so you don't need to escape the double quotes.
> 
> ...



Thanks SirDice 

With `node_exporter_args='--collector.filesystem.ignored-mount-points="^/(dev)(\$|/)"'` I get:

```
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 `node_exporter_args="--collector.filesystem.ignored-mount-points='^/(dev)($|/)'"` I get:

```
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
```

Thanks


----------



## 0mp (Nov 16, 2022)

scotia said:


> And with `node_exporter_args="--collector.filesystem.ignored-mount-points='^/(dev)($|/)'"` I get:
> 
> ```
> 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)($|/)\'"\''
> ...


Unfortunately, the rc framework is running eval on the list of arguments which makes sh(1) explode. You'll need to escape those special characters like ( or $.


----------

