Skip to content

Commit

Permalink
fix: grant cap_net_raw to blackbox_exporter (#1250)
Browse files Browse the repository at this point in the history
  • Loading branch information
STRRL authored Mar 30, 2021
1 parent 50932b4 commit 3836c20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions embed/templates/systemd/system.service.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ LimitCORE={{.LimitCORE}}
LimitNOFILE=1000000
LimitSTACK=10485760

{{- if .GrantCapNetRaw}}
AmbientCapabilities=CAP_NET_RAW
{{- end}}
User={{.User}}
ExecStart={{.DeployDir}}/scripts/run_{{.ServiceName}}.sh
{{- if eq .ServiceName "prometheus"}}
Expand Down
5 changes: 5 additions & 0 deletions pkg/cluster/task/monitored_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func (m *MonitoredConfig) syncMonitoredSystemConfig(ctx context.Context, exec ct
WithIOReadBandwidthMax(resource.IOReadBandwidthMax).
WithIOWriteBandwidthMax(resource.IOWriteBandwidthMax)

// blackbox_exporter needs cap_net_raw to send ICMP ping packets
if comp == spec.ComponentBlackboxExporter {
systemCfg.GrantCapNetRaw = true
}

if err := systemCfg.ConfigToFile(sysCfg); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cluster/template/systemd/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Config struct {
LimitCORE string
DeployDir string
DisableSendSigkill bool
GrantCapNetRaw bool
// Takes one of no, on-success, on-failure, on-abnormal, on-watchdog, on-abort, or always.
// The Template set as always if this is not setted.
Restart string
Expand Down

0 comments on commit 3836c20

Please sign in to comment.