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

fix: SNMP MIBs: use the correct path when evaluating symlink #10748

Merged
merged 2 commits into from
Mar 11, 2022

Conversation

reimda
Copy link
Contributor

@reimda reimda commented Feb 28, 2022

related #10674

This PR changes handling of symlinks to files when loading MIBs. Previously it would try to evaluate the parent directory's path as a symlink instead of the symlink's path.

This change should remove many "Couldn't stat target" warnings in logs like the following:

2022-02-17T18:06:33Z W! [inputs.snmp] Couldn't stat target /usr/share/snmp/mibs

@telegraf-tiger telegraf-tiger bot added the fix pr to fix corresponding bug label Feb 28, 2022
@reimda reimda changed the title fix: SNMP MIBs: don't use the directory path when evaluating the symlink fix: SNMP MIBs: use the correct path when evaluating symlink Feb 28, 2022
@ericjohncarlson
Copy link

@reimda I can confirm that this version works properly and does not throw the Couldn't stat target error that was called out in the original #10674 issue. Thanks!

Copy link
Contributor

@MyaLongmire MyaLongmire left a comment

Choose a reason for hiding this comment

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

Thanks for figuring this out!

@reimda
Copy link
Contributor Author

reimda commented Feb 28, 2022

@ericjohncarlson Thanks for testing so quickly. Did you also have the "translating: cannot make X numeric" error and did this PR fix that too?

@ericjohncarlson
Copy link

ericjohncarlson commented Feb 28, 2022

@ericjohncarlson Thanks for testing so quickly. Did you also have the "translating: cannot make X numeric" error and did this PR fix that too?

I'm sorry I did not have that translating error, mine was purely associated to the path issue and not being able to find the .mib files.

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Thanks for the patch @reimda! One question, can we add a unit-test for this case in order to make sure we don't break it in the future?

internal/snmp/translate_test.go Show resolved Hide resolved
@srebhan srebhan self-assigned this Mar 1, 2022
@Hipska Hipska linked an issue Mar 7, 2022 that may be closed by this pull request
@Hipska
Copy link
Contributor

Hipska commented Mar 7, 2022

According to all the responses in #10674, it seems like this PR fixes the "cannot stat" issue. Well done!

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

I don't want to hold this up due to a superfluous newline. ;-)
LGTM! Thanks @reimda for fixing!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Mar 11, 2022
@MyaLongmire MyaLongmire merged commit 35d69de into master Mar 11, 2022
@MyaLongmire MyaLongmire deleted the snmp-fix-10674 branch March 11, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/snmp fix pr to fix corresponding bug ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1.21.4 does not work with SNMP
5 participants