This commit is contained in:
Alfredo Funicello 2025-02-20 11:17:42 +01:00 committed by GitHub
commit 80d918325d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View file

@ -260,7 +260,7 @@ func NewDiskstatsCollector(logger *slog.Logger) (Collector, error) {
}
// Only enable getting device properties from udev if the directory is readable.
if stat, err := os.Stat(*udevDataPath); err != nil || !stat.IsDir() {
if stat, err := os.Stat(udevDataFilePath("")); err != nil || !stat.IsDir() {
logger.Error("Failed to open directory, disabling udev device properties", "path", *udevDataPath)
} else {
collector.getUdevDeviceProperties = getUdevDeviceProperties

View file

@ -42,6 +42,10 @@ func rootfsFilePath(name string) string {
}
func udevDataFilePath(name string) string {
// If rootfsPath flag is set, prepend to the udev data path
if *rootfsPath != "/" {
return filepath.Join(*rootfsPath, *udevDataPath, name)
}
return filepath.Join(*udevDataPath, name)
}