Skip to content

Commit 4b2e2c5

Browse files
authored
Log snmpv3 auth failures (#8917)
1 parent 7cbde18 commit 4b2e2c5

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ require (
6666
github.com/google/go-github/v32 v32.1.0
6767
github.com/gopcua/opcua v0.1.13
6868
github.com/gorilla/mux v1.7.3
69-
github.com/gosnmp/gosnmp v1.30.0
69+
github.com/gosnmp/gosnmp v1.31.0
7070
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
7171
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
7272
github.com/harlow/kinesis-consumer v0.3.1-0.20181230152818-2f58b136fee0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,8 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
590590
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
591591
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
592592
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
593-
github.com/gosnmp/gosnmp v1.30.0 h1:P6uUvPaoZCZh2EXvSUIgsxYZ1vdD/Sonl2BSVCGieG8=
594-
github.com/gosnmp/gosnmp v1.30.0/go.mod h1:EIp+qkEpXoVsyZxXKy0AmXQx0mCHMMcIhXXvNDMpgF0=
593+
github.com/gosnmp/gosnmp v1.31.0 h1:l18tqymKfReKBPr3kMK4mMM+n3DHlIpsZbBBSy8nuko=
594+
github.com/gosnmp/gosnmp v1.31.0/go.mod h1:EIp+qkEpXoVsyZxXKy0AmXQx0mCHMMcIhXXvNDMpgF0=
595595
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
596596
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
597597
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=

plugins/inputs/snmp/snmp.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bufio"
55
"bytes"
66
"encoding/binary"
7+
"errors"
78
"fmt"
89
"log"
910
"math"
@@ -434,7 +435,17 @@ func (t Table) Build(gs snmpConnection, walk bool) (*RTable, error) {
434435
// empty string. This results in all the non-table fields sharing the same
435436
// index, and being added on the same row.
436437
if pkt, err := gs.Get([]string{oid}); err != nil {
437-
return nil, fmt.Errorf("performing get on field %s: %w", f.Name, err)
438+
if errors.Is(err, gosnmp.ErrUnknownSecurityLevel) {
439+
return nil, fmt.Errorf("unknown security level (sec_level)")
440+
} else if errors.Is(err, gosnmp.ErrUnknownUsername) {
441+
return nil, fmt.Errorf("unknown username (sec_name)")
442+
} else if errors.Is(err, gosnmp.ErrWrongDigest) {
443+
return nil, fmt.Errorf("wrong digest (auth_protocol, auth_password)")
444+
} else if errors.Is(err, gosnmp.ErrDecryption) {
445+
return nil, fmt.Errorf("decryption error (priv_protocol, priv_password)")
446+
} else {
447+
return nil, fmt.Errorf("performing get on field %s: %w", f.Name, err)
448+
}
438449
} else if pkt != nil && len(pkt.Variables) > 0 && pkt.Variables[0].Type != gosnmp.NoSuchObject && pkt.Variables[0].Type != gosnmp.NoSuchInstance {
439450
ent := pkt.Variables[0]
440451
fv, err := fieldConvert(f.Conversion, ent.Value)

0 commit comments

Comments
 (0)