Add flag to change the location of the procfs.
Remove all hardcoded references to `/proc`. For all collectors that do not use `github.com/prometheus/procfs` yet, provide a wrapper to generate the full paths. Reformulate help strings, errors and comments to remove absolute references to `/proc`. This is a breaking change: the `-collector.ipvs.procfs` flag is removed in favor of the general flag. Since it only affected that collector it was only useful for development, so this should not cause many issues.
This commit is contained in:
parent
cf3aa37f1a
commit
20b551ab2b
15 changed files with 57 additions and 67 deletions
|
|
@ -14,8 +14,6 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
procNetStat = "/proc/net/netstat"
|
||||
procSNMPStat = "/proc/net/snmp"
|
||||
netStatsSubsystem = "netstat"
|
||||
)
|
||||
|
||||
|
|
@ -36,11 +34,11 @@ func NewNetStatCollector() (Collector, error) {
|
|||
}
|
||||
|
||||
func (c *netStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
||||
netStats, err := getNetStats(procNetStat)
|
||||
netStats, err := getNetStats(procFilePath("net/netstat"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't get netstats: %s", err)
|
||||
}
|
||||
snmpStats, err := getNetStats(procSNMPStat)
|
||||
snmpStats, err := getNetStats(procFilePath("net/snmp"))
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't get SNMP stats: %s", err)
|
||||
}
|
||||
|
|
@ -58,7 +56,7 @@ func (c *netStatCollector) Update(ch chan<- prometheus.Metric) (err error) {
|
|||
Namespace: Namespace,
|
||||
Subsystem: netStatsSubsystem,
|
||||
Name: key,
|
||||
Help: fmt.Sprintf("%s %s from /proc/net/{netstat,snmp}.", protocol, name),
|
||||
Help: fmt.Sprintf("Protocol %s statistic %s.", protocol, name),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue