fix panic when /proc/stat is empty

don't really know why this would be the case, but I suppose there are
always edge-cases.

see https://github.com/influxdata/telegraf/issues/2356
pull/311/head
Cameron Sparr 8 years ago
parent 3b18639664
commit 0c9a1d33cb
No known key found for this signature in database
GPG Key ID: 19E67263DCB25D0F

@ -36,6 +36,9 @@ func Times(percpu bool) ([]TimesStat, error) {
var startIdx uint = 1
for {
linen, _ := common.ReadLinesOffsetN(filename, startIdx, 1)
if len(linen) == 0 {
break
}
line := linen[0]
if !strings.HasPrefix(line, "cpu") {
break

Loading…
Cancel
Save