-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Snmpreceiver fix counter64 #26368
Snmpreceiver fix counter64 #26368
Conversation
…'t handeled. Internally we convert all numerical SNMP values to an int64. The conversion for a uint64, sent by the newly supported Conter64 SNMP data type, to int64 was lacking and is intruduced with this commit.
failed unit test should be fixed @technimad-splunk |
I'm still working on the tests. |
…rted float instead.
Test are green now. Fixed by ed97de1 |
@@ -513,7 +513,7 @@ func TestGetScalarData(t *testing.T) { | |||
expectedSNMPData := []SNMPData{} | |||
mockGoSNMP := new(mocks.MockGoSNMPWrapper) | |||
pdu1 := gosnmp.SnmpPDU{ | |||
Value: uint64(math.MaxUint64), | |||
Value: float64(math.MaxFloat64), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a test for an invalid data type.
If we receive an invalid or unsopported data type an error should be raised.
With this PR, uint64 becomes supported, and no error is raised anymore, causing the test to fail.
This change tests for an other, yet unsupported, data type (float64) which should generate an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, missed the context. Thanks for explaining.
Description:
SNMP data with type Counter64 can be sent as a uint64. This type wasn't handled.
Internally we convert all numerical SNMP values to an int64.
The conversion for a uint64, sent by the newly supported Conter64 SNMP data type, to int64
was lacking and is introduced with this PR.
Link to tracking Issue:
#23897, PR #26119
Testing:
Ran the collector with a config to collect oid 1.3.6.1.2.1.31.1.1.1.6, which is a Counter64.
This didn't work, showed value type as unsupported.
After the change data from this oid comes in as expected.
Documentation: n/a