mirror of
https://github.com/prometheus/node_exporter.git
synced 2025-03-05 21:00:12 -08:00
collector: Make udev data path optional
Instead of hard-coding the path to `/run/udev/data`, intoduce a `--path.udev.data` flag that defaults to that value. Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
This commit is contained in:
parent
75ceda8bb2
commit
833216dc9e
|
@ -349,7 +349,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func udevDeviceInformation(major, minor uint32) (udevInfo, error) {
|
func udevDeviceInformation(major, minor uint32) (udevInfo, error) {
|
||||||
filename := fmt.Sprintf("/run/udev/data/b%d:%d", major, minor)
|
filename := udevDataFilePath(fmt.Sprintf("b%d:%d", major, minor))
|
||||||
|
|
||||||
data, err := os.Open(filename)
|
data, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -23,9 +23,10 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// The path of the proc filesystem.
|
// The path of the proc filesystem.
|
||||||
procPath = kingpin.Flag("path.procfs", "procfs mountpoint.").Default(procfs.DefaultMountPoint).String()
|
procPath = kingpin.Flag("path.procfs", "procfs mountpoint.").Default(procfs.DefaultMountPoint).String()
|
||||||
sysPath = kingpin.Flag("path.sysfs", "sysfs mountpoint.").Default("/sys").String()
|
sysPath = kingpin.Flag("path.sysfs", "sysfs mountpoint.").Default("/sys").String()
|
||||||
rootfsPath = kingpin.Flag("path.rootfs", "rootfs mountpoint.").Default("/").String()
|
rootfsPath = kingpin.Flag("path.rootfs", "rootfs mountpoint.").Default("/").String()
|
||||||
|
udevDataPath = kingpin.Flag("path.udev.data", "udev data path.").Default("/run/udev/data").String()
|
||||||
)
|
)
|
||||||
|
|
||||||
func procFilePath(name string) string {
|
func procFilePath(name string) string {
|
||||||
|
@ -40,6 +41,10 @@ func rootfsFilePath(name string) string {
|
||||||
return filepath.Join(*rootfsPath, name)
|
return filepath.Join(*rootfsPath, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func udevDataFilePath(name string) string {
|
||||||
|
return filepath.Join(*udevDataPath, name)
|
||||||
|
}
|
||||||
|
|
||||||
func rootfsStripPrefix(path string) string {
|
func rootfsStripPrefix(path string) string {
|
||||||
if *rootfsPath == "/" {
|
if *rootfsPath == "/" {
|
||||||
return path
|
return path
|
||||||
|
|
Loading…
Reference in a new issue