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

Use gosmi for SNMP traps #9343

Merged
merged 9 commits into from
Jun 16, 2021
Merged

Use gosmi for SNMP traps #9343

merged 9 commits into from
Jun 16, 2021

Conversation

MyaLongmire
Copy link
Contributor

@MyaLongmire MyaLongmire commented Jun 8, 2021

Required for all PRs:

  • Updated associated README.md.
  • Wrote appropriate unit tests.

resolves #9307

config file now takes paths to where mib files are located
plugin now uses gosmi instead of snmptranslate
new unit test
added fake mibs for the tests

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Jun 8, 2021
@MyaLongmire MyaLongmire requested a review from Hipska June 9, 2021 19:42
@MyaLongmire
Copy link
Contributor Author

@loganmc10 Would mind reviewing this?

}
return out.Bytes(), nil
func (s *SnmpTrap) Init() error {
// must init, append path for each directory, laod module for every file
Copy link
Contributor

Choose a reason for hiding this comment

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

laod module for every file

typo here


e.oidText = scanner.Text()
e.oidText = node.RenderQualified()
fmt.Printf("node %v\n", node)
Copy link
Contributor

Choose a reason for hiding this comment

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

leftover debugging

@loganmc10
Copy link
Contributor

I think it looks good, I don't know about the unit tests, but I assume once they are passing that is good.

I know that gosmi has a gosmi.Exit(), I haven't looked at what it does, but I assume it should be called somewhere? I don't know if Telegraf plugins have some kind of an exit function.

Copy link
Contributor

@reimda reimda left a comment

Choose a reason for hiding this comment

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

Just a couple things I noticed in a very quick review

Comment on lines -1296 to +1293
require.Nil(t, s.Init())
// Don't look up oid with snmptranslate.
s.execCmd = fakeExecCmd

require.NoError(t, s.Init())

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, it looks like s.Init() was there originally. We must have removed it before we found it was definitely necessary and put it back :)

@Hipska Hipska added area/snmp plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Jun 10, 2021
Copy link
Contributor

@Hipska Hipska left a comment

Choose a reason for hiding this comment

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

Looks good in general, but I cannot test since I'm not using this plugin. I'm using the snmp plugin.

Anyway, I think it would be better to add the MIB path to the general snmp config (internal/snmp/config.go) and add the generic translation/lookup functions in that section, so both plugins can benefit from it.

go.mod Outdated
module github.com/influxdata/telegraf

go 1.16
module github.com/golang-migrate/migrate/v4
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this intended? And relevant for this PR?

@MyaLongmire MyaLongmire marked this pull request as ready for review June 10, 2021 19:31
@MyaLongmire MyaLongmire self-assigned this Jun 10, 2021
@MyaLongmire MyaLongmire linked an issue Jun 14, 2021 that may be closed by this pull request
@Hipska
Copy link
Contributor

Hipska commented Jun 16, 2021

@MyaLongmire this PR will not solve #5720 in this current state. As it is about snmp plug-in and the PR only covers snmp_trap.

@Hipska
Copy link
Contributor

Hipska commented Nov 18, 2021

The readme still says it uses snmptranslate, that's not correct I guess?

@MyaLongmire
Copy link
Contributor Author

MyaLongmire commented Nov 19, 2021

It is not correct and I will fix this in a new pr, good catch!

Here is the pr for the fixed readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/snmp feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants