Skip to content

Commit 7a229e2

Browse files
vignemail1danielnelson
authored andcommitted
Update sudo config recommendation (influxdata#5337)
1 parent 35d18d3 commit 7a229e2

File tree

7 files changed

+68
-13
lines changed

7 files changed

+68
-13
lines changed

plugins/inputs/fail2ban/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,24 @@ Acquiring the required permissions can be done using several methods:
1010

1111
### Using sudo
1212

13-
You may edit your sudo configuration with the following:
13+
You will need the following in your telegraf config:
14+
```toml
15+
[[inputs.fail2ban]]
16+
use_sudo = true
17+
```
1418

15-
``` sudo
16-
telegraf ALL=(root) NOEXEC: NOPASSWD: /usr/bin/fail2ban-client status, /usr/bin/fail2ban-client status *
19+
You will also need to update your sudoers file:
20+
```bash
21+
$ visudo
22+
# Add the following line:
23+
Cmnd_Alias FAIL2BAN = /usr/bin/fail2ban-client status, /usr/bin/fail2ban-client status *
24+
telegraf ALL=(root) NOEXEC: NOPASSWD: FAIL2BAN
25+
Defaults!FAIL2BAN !logfile, !syslog, !pam_session
1726
```
1827

1928
### Configuration:
2029

21-
``` toml
30+
```toml
2231
# Read metrics from fail2ban.
2332
[[inputs.fail2ban]]
2433
## Use sudo to run fail2ban-client

plugins/inputs/ipset/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,19 @@ AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
2525

2626
### Using sudo
2727

28-
You may edit your sudo configuration with the following:
28+
You will need the following in your telegraf config:
29+
```toml
30+
[[inputs.ipset]]
31+
use_sudo = true
32+
```
2933

30-
```sudo
31-
telegraf ALL=(root) NOPASSWD: /sbin/ipset save
34+
You will also need to update your sudoers file:
35+
```bash
36+
$ visudo
37+
# Add the following line:
38+
Cmnd_Alias IPSETSAVE = /sbin/ipset save
39+
telegraf ALL=(root) NOPASSWD: IPSETSAVE
40+
Defaults!IPSETSAVE !logfile, !syslog, !pam_session
3241
```
3342

3443
### Configuration

plugins/inputs/iptables/README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,20 @@ Since telegraf will fork a process to run iptables, `AmbientCapabilities` is req
2828

2929
### Using sudo
3030

31-
You may edit your sudo configuration with the following:
31+
You will need the following in your telegraf config:
32+
```toml
33+
[[inputs.iptables]]
34+
use_sudo = true
35+
```
36+
37+
You will also need to update your sudoers file:
3238

33-
```sudo
34-
telegraf ALL=(root) NOPASSWD: /usr/bin/iptables -nvL *
39+
```bash
40+
$ visudo
41+
# Add the following line:
42+
Cmnd_Alias IPTABLESSHOW = /usr/bin/iptables -nvL *
43+
telegraf ALL=(root) NOPASSWD: IPTABLESSHOW
44+
Defaults!IPTABLESSHOW !logfile, !syslog, !pam_session
3545
```
3646

3747
### Using IPtables lock feature

plugins/inputs/opensmtpd/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ You will also need to update your sudoers file:
8686
```bash
8787
$ visudo
8888
# Add the following line:
89-
telegraf ALL=(ALL) NOPASSWD: /usr/sbin/smtpctl
89+
Cmnd_Alias SMTPCTL = /usr/sbin/smtpctl
90+
telegraf ALL=(ALL) NOPASSWD: SMTPCTL
91+
Defaults!SMTPCTL !logfile, !syslog, !pam_session
9092
```
9193

9294
Please use the solution you see as most appropriate.

plugins/inputs/smart/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,27 @@ smartctl -s on <device>
6161
# devices = [ "/dev/ada0 -d atacam" ]
6262
```
6363

64+
### Permissions:
65+
66+
It's important to note that this plugin references smartctl, which may require additional permissions to execute successfully.
67+
Depending on the user/group permissions of the telegraf user executing this plugin, you may need to use sudo.
68+
69+
70+
You will need the following in your telegraf config:
71+
```toml
72+
[[inputs.smart]]
73+
use_sudo = true
74+
```
75+
76+
You will also need to update your sudoers file:
77+
```bash
78+
$ visudo
79+
# Add the following line:
80+
Cmnd_Alias SMARTCTL = /usr/bin/smartctl
81+
telegraf ALL=(ALL) NOPASSWD: SMARTCTL
82+
Defaults!SMARTCTL !logfile, !syslog, !pam_session
83+
```
84+
6485
### Metrics:
6586

6687
- smart_device:

plugins/inputs/unbound/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ You will also need to update your sudoers file:
5656
```bash
5757
$ visudo
5858
# Add the following line:
59-
telegraf ALL=(ALL) NOPASSWD: /usr/sbin/unbound-control
59+
Cmnd_Alias UNBOUNDCTL = /usr/sbin/unbound-control
60+
telegraf ALL=(ALL) NOPASSWD: UNBOUNDCTL
61+
Defaults!UNBOUNDCTL !logfile, !syslog, !pam_session
6062
```
6163

6264
Please use the solution you see as most appropriate.

plugins/inputs/varnish/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ You will also need to update your sudoers file:
391391
```bash
392392
$ visudo
393393
# Add the following line:
394-
telegraf ALL=(ALL) NOPASSWD: /usr/bin/varnishstat
394+
Cmnd_Alias VARNISHSTAT = /usr/bin/varnishstat
395+
telegraf ALL=(ALL) NOPASSWD: VARNISHSTAT
396+
Defaults!VARNISHSTAT !logfile, !syslog, !pam_session
395397
```
396398

397399
Please use the solution you see as most appropriate.

0 commit comments

Comments
 (0)