Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Version 2.2.2. Update sdk to latest. (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewHink authored Oct 27, 2021
1 parent f0671c2 commit 6a4f750
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#

PLUGIN_NAME := snmp
PLUGIN_VERSION := 2.2.1
PLUGIN_VERSION := 2.2.2
IMAGE_NAME := vaporio/snmp-plugin
BIN_NAME := synse-snmp-plugin

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/creasty/defaults v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gosnmp/gosnmp v1.32.0
github.com/gosnmp/gosnmp v1.33.0
github.com/imdario/mergo v0.3.12 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/prometheus/common v0.31.1 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20210413152122-9d6dea743ebb
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20211022200300-95f96541a99d
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/net v0.0.0-20211006190231-62292e806868 // indirect
golang.org/x/sys v0.0.0-20211006194710-c8a6f5223071 // indirect
golang.org/x/net v0.0.0-20211020060615-d418f374d309 // indirect
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.1.5 // indirect
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e // indirect
google.golang.org/genproto v0.0.0-20211026145609-4688e4c4e024 // indirect
google.golang.org/grpc v1.41.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
16 changes: 16 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -152,6 +153,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/gosnmp/gosnmp v1.32.0 h1:gctewmZx5qFI0oHMzRnjETqIZ093d9NgZy9TQr3V0iA=
github.com/gosnmp/gosnmp v1.32.0/go.mod h1:EIp+qkEpXoVsyZxXKy0AmXQx0mCHMMcIhXXvNDMpgF0=
github.com/gosnmp/gosnmp v1.33.0 h1:WNwN5Rj/9Y70VplIKXuaUiYVxdcaXhfAuLElKx4lnpU=
github.com/gosnmp/gosnmp v1.33.0/go.mod h1:QWTRprXN9haHFof3P96XTDYc46boCGAh5IXp0DniEx4=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
Expand Down Expand Up @@ -217,6 +220,8 @@ github.com/prometheus/common v0.30.0 h1:JEkYlQnpzrzQFxi6gnukFPdQ+ac82oRhzMcIduJu
github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.31.1 h1:d18hG4PkHnNAKNMOmFuXFaiY8Us0nird/2m60uS1AMs=
github.com/prometheus/common v0.31.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
Expand Down Expand Up @@ -244,6 +249,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20210413152122-9d6dea743ebb h1:uzeiSuOy9M1uXvZtzzaVK4zOWaL0UWaz0L6nR7KiRog=
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20210413152122-9d6dea743ebb/go.mod h1:WbxVnJA1M3mwGhXSP0EmYn1/bDNc+UcTSL89XsZaQCs=
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20211022200300-95f96541a99d h1:z11/PwM0nOylOIa0WbWflba6QjMa4gUNy32NBOkx5jo=
github.com/vapor-ware/synse-sdk v0.1.0-alpha.0.20211022200300-95f96541a99d/go.mod h1:A/bj/1VFJQtNv2GTddZVuEJ9jBZp8ypjld/juHvHFVs=
github.com/vapor-ware/synse-server-grpc v0.0.2-0.20210119190824-c4d4f681c30c h1:ttdkJAZsjfcz1UJjPV9kjCtqp7+H137Fj41bvAH9JzQ=
github.com/vapor-ware/synse-server-grpc v0.0.2-0.20210119190824-c4d4f681c30c/go.mod h1:66oRQ1KV/ZevAiiXbSUjRbx/h91xG/ArE/V39Jh872I=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -331,6 +338,8 @@ golang.org/x/net v0.0.0-20210913180222-943fd674d43e h1:+b/22bPvDYt4NPDcy4xAGCmON
golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211006190231-62292e806868 h1:KlOXYy8wQWTUJYFgkUI40Lzr06ofg5IRXUK5C7qZt1k=
golang.org/x/net v0.0.0-20211006190231-62292e806868/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211020060615-d418f374d309 h1:A0lJIi+hcTR6aajJH4YqKWwohY4aW9RO7oRMcdv+HKI=
golang.org/x/net v0.0.0-20211020060615-d418f374d309/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -394,6 +403,9 @@ golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 h1:xrCZDmdtoloIiooiA9q0OQb9r
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211006194710-c8a6f5223071 h1:PjhxBct4MZii8FFR8+oeS7QOvxKOTZXgk63EU2XpfJE=
golang.org/x/sys v0.0.0-20211006194710-c8a6f5223071/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359 h1:2B5p2L5IfGiD7+b9BOoRMC6DgObAVZV+Fsp050NqXik=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -455,6 +467,7 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
Expand Down Expand Up @@ -524,6 +537,9 @@ google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af h1:aLMMXFYqw01RA6X
google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY=
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e h1:Im71rbA1N3CbIag/PumYhQcNR8bLNmuOtRIyOnnLsT8=
google.golang.org/genproto v0.0.0-20211005153810-c76a74d43a8e/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211026145609-4688e4c4e024 h1:aePO4E0x+Urj9V5NQHjqOpaNG4oMeHQq0l2ob05z5tI=
google.golang.org/genproto v0.0.0-20211026145609-4688e4c4e024/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
Expand Down
15 changes: 12 additions & 3 deletions pkg/devices/current.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpCurrent is the handler for the SNMP OIDs that report current.
Expand All @@ -15,14 +16,19 @@ var SnmpCurrent = sdk.DeviceHandler{
func SnmpCurrentRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.ElectricCurrent.MakeReading(nil)
reading, err = output.ElectricCurrent.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return readings, nil
}
Expand All @@ -35,7 +41,10 @@ func SnmpCurrentRead(device *sdk.Device) (readings []*output.Reading, err error)
}

// Create the reading.
reading := output.ElectricCurrent.MakeReading(resultFloat)
reading, err = output.ElectricCurrent.MakeReading(resultFloat)
if err != nil {
return nil, err
}

readings = []*output.Reading{reading}
return readings, nil
Expand Down
15 changes: 12 additions & 3 deletions pkg/devices/frequency.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpFrequency is the handler for the SNMP OIDs that report frequency.
Expand All @@ -15,14 +16,19 @@ var SnmpFrequency = sdk.DeviceHandler{
func SnmpFrequencyRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.Frequency.MakeReading(nil)
reading, err = output.Frequency.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return readings, nil
}
Expand All @@ -35,7 +41,10 @@ func SnmpFrequencyRead(device *sdk.Device) (readings []*output.Reading, err erro
}

// Create the reading.
reading := output.Frequency.MakeReading(resultFloat)
reading, err = output.Frequency.MakeReading(resultFloat)
if err != nil {
return nil, err
}

readings = []*output.Reading{reading}
return readings, nil
Expand Down
15 changes: 12 additions & 3 deletions pkg/devices/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/outputs"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpIdentity is the handler for the snmp-identity device.
Expand All @@ -18,17 +19,22 @@ var SnmpIdentity = sdk.DeviceHandler{
func SnmpIdentityRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Should be a string.
var reading *output.Reading
resultData, ok := result.Data.(string)
if !ok {
if result.Data == nil {
// We got nil, so create a nil reading.
reading := outputs.Identity.MakeReading(nil)
reading, err = outputs.Identity.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return readings, nil
}
Expand All @@ -38,7 +44,10 @@ func SnmpIdentityRead(device *sdk.Device) (readings []*output.Reading, err error
}

// Create the reading.
reading := outputs.Identity.MakeReading(resultData)
reading, err = outputs.Identity.MakeReading(resultData)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return readings, nil
}
15 changes: 12 additions & 3 deletions pkg/devices/minutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpMinutes is the handler for the SNMP OIDs that report minutes.
Expand All @@ -15,20 +16,28 @@ var SnmpMinutes = sdk.DeviceHandler{
func SnmpMinutesRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.Minutes.MakeReading(nil)
reading, err = output.Minutes.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}

// Create the reading.
reading := output.Minutes.MakeReading(result.Data)
reading, err = output.Minutes.MakeReading(result.Data)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}
15 changes: 12 additions & 3 deletions pkg/devices/percentage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpPercentage is the handler for the SNMP OIDs that report percentage.
Expand All @@ -15,20 +16,28 @@ var SnmpPercentage = sdk.DeviceHandler{
func SnmpPercentageRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.Percentage.MakeReading(nil)
reading, err = output.Percentage.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}

// Create the reading.
reading := output.Percentage.MakeReading(result.Data)
reading, err = output.Percentage.MakeReading(result.Data)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}
9 changes: 6 additions & 3 deletions pkg/devices/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpPower is the handler for SNMP OIDs that report power.
Expand All @@ -15,14 +16,16 @@ var SnmpPower = sdk.DeviceHandler{
func SnmpPowerRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.Watt.MakeReading(nil)
reading, err = output.Watt.MakeReading(nil)
readings = []*output.Reading{reading}
return readings, nil
}
Expand All @@ -36,7 +39,7 @@ func SnmpPowerRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Create the reading.
// FIXME (etd): differentiate between watts/VA
reading := output.Watt.MakeReading(resultFloat)
reading, err = output.Watt.MakeReading(resultFloat)

readings = []*output.Reading{reading}
return readings, nil
Expand Down
15 changes: 12 additions & 3 deletions pkg/devices/seconds.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devices
import (
"github.com/vapor-ware/synse-sdk/sdk"
"github.com/vapor-ware/synse-sdk/sdk/output"
"github.com/vapor-ware/synse-snmp-plugin/pkg/snmp/core"
)

// SnmpSeconds is the handler for the SNMP OIDs that report seconds.
Expand All @@ -15,20 +16,28 @@ var SnmpSeconds = sdk.DeviceHandler{
func SnmpSecondsRead(device *sdk.Device) (readings []*output.Reading, err error) {

// Get the raw reading from the SNMP server.
result, err := getRawReading(device)
var result core.ReadResult
result, err = getRawReading(device)
if err != nil {
return nil, err
}

// Check for nil reading.
var reading *output.Reading
if result.Data == nil {
reading := output.Seconds.MakeReading(nil)
reading, err = output.Seconds.MakeReading(nil)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}

// Create the reading.
reading := output.Seconds.MakeReading(result.Data)
reading, err = output.Seconds.MakeReading(result.Data)
if err != nil {
return nil, err
}
readings = []*output.Reading{reading}
return
}
Loading

0 comments on commit 6a4f750

Please sign in to comment.