Skip to content

Commit

Permalink
[snmp] migrate to go-mackerel-plugin-helper and don't set default tem…
Browse files Browse the repository at this point in the history
…pfile name by plugin
  • Loading branch information
astj committed Oct 12, 2016
1 parent df1c3e8 commit 19dd3f0
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions mackerel-plugin-snmp/snmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"

"github.com/alouca/gosnmp"
mp "github.com/mackerelio/go-mackerel-plugin"
mp "github.com/mackerelio/go-mackerel-plugin-helper"
)

// SNMPMetrics metrics
Expand All @@ -29,8 +29,8 @@ type SNMPPlugin struct {
}

// FetchMetrics interface for mackerelplugin
func (m SNMPPlugin) FetchMetrics() (map[string]float64, error) {
stat := make(map[string]float64)
func (m SNMPPlugin) FetchMetrics() (map[string]interface{}, error) {
stat := make(map[string]interface{})

s, err := gosnmp.NewGoSNMP(m.Host, m.Community, gosnmp.Version2c, 30)
if err != nil {
Expand Down Expand Up @@ -108,12 +108,7 @@ func main() {
snmp.SNMPMetricsSlice = sms

helper := mp.NewMackerelPlugin(snmp)

if *optTempfile != "" {
helper.Tempfile = *optTempfile
} else {
helper.Tempfile = fmt.Sprintf("/tmp/mackerel-plugin-snmp-%s-%s", *optHost, *optGraphName)
}
helper.Tempfile = *optTempfile

if os.Getenv("MACKEREL_AGENT_PLUGIN_META") != "" {
helper.OutputDefinitions()
Expand Down

0 comments on commit 19dd3f0

Please sign in to comment.