3 Star 0 Fork 0

Gitee 极速下载 / gosnmp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/soniah/gosnmp
克隆/下载
trapsend_v2plus.go 926 Bytes
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2012-2014 The GoSNMP Authors. All rights reserved. Use of this
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
package main
import (
g "github.com/soniah/gosnmp"
"log"
"os"
)
func main() {
// Default is a pointer to a GoSNMP struct that contains sensible defaults
// eg port 161, community public, etc
g.Default.Target = "127.0.0.1"
g.Default.Port = 162
g.Default.Version = g.Version2c
g.Default.Community = "public"
g.Default.Logger = log.New(os.Stdout, "", 0)
err := g.Default.Connect()
if err != nil {
log.Fatalf("Connect() err: %v", err)
}
defer g.Default.Conn.Close()
pdu := g.SnmpPDU{
Name: ".1.3.6.1.6.3.1.1.4.1.0",
Type: g.ObjectIdentifier,
Value: ".1.3.6.1.6.3.1.1.5.1",
}
trap := g.SnmpTrap{
Variables: []g.SnmpPDU{pdu},
}
_, err = g.Default.SendTrap(trap)
if err != nil {
log.Fatalf("SendTrap() err: %v", err)
}
}
1
https://gitee.com/mirrors/gosnmp.git
git@gitee.com:mirrors/gosnmp.git
mirrors
gosnmp
gosnmp
v1.17.0

搜索帮助