Skip to content

Commit 3b2042d

Browse files
committed
fix: dont fail when reading /proc fails
Fixes #249
1 parent ca1ad74 commit 3b2042d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cmd/collectors/unix/process.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,10 @@ func (me *Process) loadSmaps() error {
228228
fields []string
229229
)
230230

231+
// this may fail see https://github.com/NetApp/harvest/issues/249
232+
// when it does, ignore so the other /proc checks are given a chance to run
231233
if data, err = ioutil.ReadFile(path.Join(me.dirpath, "smaps")); err != nil {
232-
return errors.New(FILE_READ, "smaps: "+err.Error())
234+
return nil
233235
}
234236

235237
me.mem = make(map[string]uint64)
@@ -263,8 +265,10 @@ func (me *Process) loadIo() error {
263265
num uint64
264266
)
265267

268+
// this may fail see https://github.com/NetApp/harvest/issues/249
269+
// when it does, ignore so the other /proc checks are given a chance to run
266270
if data, err = ioutil.ReadFile(path.Join(me.dirpath, "io")); err != nil {
267-
return errors.New(FILE_READ, "io: "+err.Error())
271+
return nil
268272
}
269273

270274
for _, line = range strings.Split(string(data), "\n") {
@@ -274,7 +278,7 @@ func (me *Process) loadIo() error {
274278
}
275279
}
276280
}
277-
return err
281+
return nil
278282
}
279283

280284
func (me *Process) loadNetDev() error {
@@ -327,9 +331,11 @@ func (me *Process) loadNetDev() error {
327331
}
328332

329333
func (me *Process) loadFdinfo() error {
334+
// this may fail see https://github.com/NetApp/harvest/issues/249
335+
// when it does, ignore so the other /proc checks are given a chance to run
330336
files, err := ioutil.ReadDir(path.Join(me.dirpath, "fdinfo"))
331337
if err != nil {
332-
return errors.New(DIR_READ, "fdinfo: "+err.Error())
338+
return nil
333339
}
334340
me.numFds = uint64(len(files))
335341
return nil

0 commit comments

Comments
 (0)