summaryrefslogtreecommitdiffstats
path: root/src/go/plugin/go.d/agent/vnodes/vnodes.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-10 20:12:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-10 20:12:09 +0000
commit18fcf4e9717a2b3809a032003842c45107f5b59a (patch)
treee55aed1f1feb4e114e3a5b89763766e781cbc831 /src/go/plugin/go.d/agent/vnodes/vnodes.go
parentAdding upstream version 1.47.0. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 1.47.1.upstream/1.47.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/go/plugin/go.d/agent/vnodes/vnodes.go30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/go/plugin/go.d/agent/vnodes/vnodes.go b/src/go/plugin/go.d/agent/vnodes/vnodes.go
index 9272f1514..3d332c261 100644
--- a/src/go/plugin/go.d/agent/vnodes/vnodes.go
+++ b/src/go/plugin/go.d/agent/vnodes/vnodes.go
@@ -61,11 +61,39 @@ func (vn *Vnodes) readConfDir() {
return nil
}
- if !d.Type().IsRegular() || !isConfigFile(path) {
+ if d.Type()&os.ModeSymlink != 0 {
+ dst, err := os.Readlink(path)
+ if err != nil {
+ vn.Warningf("failed to resolve symlink '%s': %v", path, err)
+ return nil
+ }
+
+ if !filepath.IsAbs(dst) {
+ dst = filepath.Join(filepath.Dir(path), filepath.Clean(dst))
+ }
+
+ fi, err := os.Stat(dst)
+ if err != nil {
+ vn.Warningf("failed to stat resolved path '%s': %v", dst, err)
+ return nil
+ }
+ if !fi.Mode().IsRegular() {
+ vn.Debugf("'%s' is not a regular file, skipping it", dst)
+ return nil
+ }
+ path = dst
+ } else if !d.Type().IsRegular() {
+ vn.Debugf("'%s' is not a regular file, skipping it", path)
+ return nil
+ }
+
+ if !isConfigFile(path) {
+ vn.Debugf("'%s' is not a config file (wrong extension), skipping it", path)
return nil
}
var cfg []VirtualNode
+
if err := loadConfigFile(&cfg, path); err != nil {
vn.Warning(err)
return nil