Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip bad entries on interrupt input #4497

Merged
merged 3 commits into from
Aug 1, 2018
Merged

Skip bad entries on interrupt input #4497

merged 3 commits into from
Aug 1, 2018

Conversation

glinton
Copy link
Contributor

@glinton glinton commented Jul 31, 2018

Resolves #4470

@@ -62,7 +65,8 @@ func parseInterrupts(r io.Reader) ([]IRQ, error) {
if i < len(irqvals) {
irqval, err := strconv.ParseInt(irqvals[i], 10, 64)
if err != nil {
return irqs, fmt.Errorf("Unable to parse %q from %q: %s", irqvals[i], scanner.Text(), err)
log.Printf("I! skipping interrupt field '%s': %s", irqvals[i], err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be hit every interval with the example /proc/interrupts, so we don't want to log. However, we don't want to mask all errors either. I suggest checking if the line has at least cpucount fields before this loop and if not skip the line.

It makes sense to keep this code here still though, only the case of not enough columns should be skipped.

for scanner.Scan() {
fields := strings.Fields(scanner.Text())
if !strings.HasSuffix(fields[0], ":") {
continue
}
if cpucount > len(fields) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to say we need to compare this against irqvals since fields includes the name of the irq, but then I noticed this line from the existing tests:

 MIS:          0

So it is possible to have fewer fields than cpucount. Maybe we just continue with no error if the ParseInt call fails?

@glinton glinton merged commit 4fff507 into master Aug 1, 2018
@glinton glinton deleted the bugfix/4470 branch August 1, 2018 22:39
glinton added a commit that referenced this pull request Aug 1, 2018
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants