diff options
Diffstat (limited to 'src/go')
4 files changed, 49 insertions, 19 deletions
diff --git a/src/go/plugin/go.d/agent/vnodes/vnodes.go b/src/go/plugin/go.d/agent/vnodes/vnodes.go index 9272f151..3d332c26 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 diff --git a/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go index 16e0f17d..a5774ae4 100644 --- a/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go +++ b/src/go/plugin/go.d/modules/dnsmasq_dhcp/dhcp_test.go @@ -193,6 +193,10 @@ func TestDnsmasqDHCP_parseDHCPRangeValue(t *testing.T) { wantFail: true, input: "1234::,ra-stateless", }, + "invalid": { + wantFail: true, + input: "192.168.0.0", + }, } for name, test := range tests { diff --git a/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go b/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go index 558ce7c6..5ef29f28 100644 --- a/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go +++ b/src/go/plugin/go.d/modules/dnsmasq_dhcp/parse_configuration.go @@ -108,14 +108,12 @@ func parseDHCPRangeValue(s string) (r string) { var start, end net.IP parts := strings.Split(s, ",") - for i, v := range parts { - if start = net.ParseIP(strings.TrimSpace(v)); start == nil { + for _, v := range parts { + if start == nil { + start = net.ParseIP(v) continue } - if len(parts) < i+1 { - return "" - } - if end = net.ParseIP(parts[i+1]); end == nil || iprange.New(start, end) == nil { + if end = net.ParseIP(v); end == nil || iprange.New(start, end) == nil { return "" } return fmt.Sprintf("%s-%s", start, end) diff --git a/src/go/plugin/go.d/modules/storcli/collect_drives.go b/src/go/plugin/go.d/modules/storcli/collect_drives.go index 5c2ecb38..95965d57 100644 --- a/src/go/plugin/go.d/modules/storcli/collect_drives.go +++ b/src/go/plugin/go.d/modules/storcli/collect_drives.go @@ -23,18 +23,18 @@ type drivesInfoResponse struct { type ( driveInfo struct { EIDSlt string `json:"EID:Slt"` - DID int `json:"DID"` - State string `json:"State"` - DG int `json:"DG"` - Size string `json:"Size"` - Intf string `json:"Intf"` - Med string `json:"Med"` - SED string `json:"SED"` - PI string `json:"PI"` - SeSz string `json:"SeSz"` - Model string `json:"Model"` - Sp string `json:"Sp"` - Type string `json:"Type"` + //DID int `json:"DID"` + //State string `json:"State"` + //DG int `json:"DG"` // FIX: can be integer or "-" + //Size string `json:"Size"` + //Intf string `json:"Intf"` + Med string `json:"Med"` + //SED string `json:"SED"` + //PI string `json:"PI"` + //SeSz string `json:"SeSz"` + //Model string `json:"Model"` + //Sp string `json:"Sp"` + //Type string `json:"Type"` } driveState struct { MediaErrorCount storNumber `json:"Media Error Count"` |