snmp

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BgpLocalAS = ".3.6.1.2.1.15.2.0"

	BgpPeerLocalAddrOid  = ".1.3.6.1.2.1.15.3.1.5"
	BgpPeerLocalPortOid  = ".1.3.6.1.2.1.15.3.1.6"
	BgpPeerRemoteAddrOid = ".1.3.6.1.2.1.15.3.1.7"
	BgpPeerRemotePortOid = ".1.3.6.1.2.1.15.3.1.8"
	BgpPeerRemoteASOid   = ".1.3.6.1.2.1.15.3.1.9"
	BgpPeerStateOid      = ".1.3.6.1.2.1.15.3.1.2"
)

BGP oids

View Source
const (
	CdpInterfaceIfIndexOid       = ".1.3.6.1.4.1.9.9.23.1.1.1.1.1"
	CdpInterfaceIfEnableOid      = ".1.3.6.1.4.1.9.9.23.1.1.1.1.2"
	CdpInterfaceIfMsgIntervalOid = ".1.3.6.1.4.1.9.9.23.1.1.1.1.3"
	CdpInterfaceIfGroupOid       = ".1.3.6.1.4.1.9.9.23.1.1.1.1.4"
	CdpInterfaceIfPortOid        = ".1.3.6.1.4.1.9.9.23.1.1.1.1.5"
	CdpInterfaceIfNameOid        = ".1.3.6.1.4.1.9.9.23.1.1.1.1.6"
)

Const

View Source
const (
	SysObjectID = ".1.3.6.1.2.1.1.2.0"
	SysDescr    = ".1.3.6.1.2.1.1.1.0"
	SysUpTime   = ".1.3.6.1.2.1.1.3.0"
	SysContact  = ".1.3.6.1.2.1.1.4.0"
	SysName     = ".1.3.6.1.2.1.1.5.0"
	SysLocation = ".1.3.6.1.2.1.1.6.0"
	SysServices = ".1.3.6.1.2.1.1.7.0"
)

System

View Source
const (
	OIDIpAdEntAddr    = ".1.3.6.1.2.1.4.20.1.1"
	OIDIpAdEntIfIndex = ".1.3.6.1.2.1.4.20.1.2"
	OIDIpAdEntNetMask = ".1.3.6.1.2.1.4.20.1.3"
)

Oid of ipAddTable[.1.3.6.1.2.1.4.20]

View Source
const (
	IPForwardDest    = ".1.3.6.1.2.1.4.24.2.1.1"
	IPForwardMask    = ".1.3.6.1.2.1.4.24.2.1.2"
	IPForwardNextHop = ".1.3.6.1.2.1.4.24.2.1.4"
	IPForwardIfIndex = ".1.3.6.1.2.1.4.24.2.1.5"
)

IPforward table itme ,.1.3.6.1.2.1.4.24.2

View Source
const (
	//LLdpLocPortSubtype = [...]string{""}
	LldpLocPortNum       = ".1.0.8802.1.1.2.1.3.7.1.1"
	LldpLocPortIDSubtype = ".1.0.8802.1.1.2.1.3.7.1.2"
	LldpLocPortID        = ".1.0.8802.1.1.2.1.3.7.1.3"
	LldpLocPortDesc      = ".1.0.8802.1.1.2.1.3.7.1.4"

	LLdpRemTimeMark         = ".1.0.8802.1.1.2.1.4.1.1.1"
	LLdpRemLocalPortNum     = ".1.0.8802.1.1.2.1.4.1.1.2"
	LLdpRemIndex            = ".1.0.8802.1.1.2.1.4.1.1.3"
	LLdpRemChassisIDSubtype = ".1.0.8802.1.1.2.1.4.1.1.4"
	LLdpRemChassisID        = ".1.0.8802.1.1.2.1.4.1.1.5"
	LLdpRemPortIDSubtype    = ".1.0.8802.1.1.2.1.4.1.1.6"
	LLdpRemPortID           = ".1.0.8802.1.1.2.1.4.1.1.7"
	LLdpRemPortDesc         = ".1.0.8802.1.1.2.1.4.1.1.8"
	LLdpRemSysName          = ".1.0.8802.1.1.2.1.4.1.1.9"
	LLdpRemSysDesc          = ".1.0.8802.1.1.2.1.4.1.1.10"
	LLdpRemSysCapSupported  = ".1.0.8802.1.1.2.1.4.1.1.11"
	LLdpRemSysCapEnabled    = ".1.0.8802.1.1.2.1.4.1.1.12"
)

LLDP

View Source
const (
	OspfIfIPAddressOid = ".1.3.6.1.2.1.14.7.1.1"
	OspfIfAdminStatOid = ".1.3.6.1.2.1.14.7.1.5"
	OspfIfStateOid     = ".1.3.6.1.2.1.14.7.1.12"
	OspfIfStatusOid    = ".1.3.6.1.2.1.14.7.1.17"
)

OspfIfTable oids

View Source
const (
	OspfNbrIPAddrOid = ".1.3.6.1.2.1.14.10.1.1"
	OspfNbrRtrIDOid  = ".1.3.6.1.2.1.14.10.1.3"
	OspfNbrStateOid  = ".1.3.6.1.2.1.14.10.1.6"
)

OspfIfTable oids

View Source
const (
	IfIndex           = ".1.3.6.1.2.1.2.2.1.1"
	IfDescr           = ".1.3.6.1.2.1.2.2.1.2"
	IfType            = ".1.3.6.1.2.1.2.2.1.3"
	IfMtu             = ".1.3.6.1.2.1.2.2.1.4"
	IfSpeed           = ".1.3.6.1.2.1.2.2.1.5"
	IfPhysAddress     = ".1.3.6.1.2.1.2.2.1.6"
	IfAdminStatus     = ".1.3.6.1.2.1.2.2.1.7"
	IfOperStatus      = ".1.3.6.1.2.1.2.2.1.8"
	IfLastChange      = ".1.3.6.1.2.1.2.2.1.9"
	IfInOctets        = ".1.3.6.1.2.1.2.2.1.10"
	IfInUcastPkts     = ".1.3.6.1.2.1.2.2.1.11"
	IfInNUcastPkts    = ".1.3.6.1.2.1.2.2.1.12"
	IfInDiscards      = ".1.3.6.1.2.1.2.2.1.13"
	IfInErrors        = ".1.3.6.1.2.1.2.2.1.14"
	IfInUnknownProtos = ".1.3.6.1.2.1.2.2.1.15"
	IfOutOctets       = ".1.3.6.1.2.1.2.2.1.16"
	IfOutUcastPkts    = ".1.3.6.1.2.1.2.2.1.17"
	IfOutNUcastPkts   = ".1.3.6.1.2.1.2.2.1.18"
	IfOutDiscards     = ".1.3.6.1.2.1.2.2.1.19"
	IfOutErrors       = ".1.3.6.1.2.1.2.2.1.20"
	IfOutQLen         = ".1.3.6.1.2.1.2.2.1.21"
	IfSpecific        = ".1.3.6.1.2.1.2.2.1.22"
)

IfTable

View Source
const (
	WinStorageDescr = ".1.3.6.1.2.1.25.2.3.1.3"
	WinStorageUnits = ".1.3.6.1.2.1.25.2.3.1.4"
	WinStorageSize  = ".1.3.6.1.2.1.25.2.3.1.5"
	WinStorageUsed  = ".1.3.6.1.2.1.25.2.3.1.6"
)

Const

View Source
const (
	TrapOID   = ".1.3.6.1.6.3.1.1.4.1.0"
	WarmStart = ".1.3.6.1.6.3.1.1.5.2"
	ColdStart = ".1.3.6.1.6.3.1.1.5.1"
	LinkDown  = ".1.3.6.1.6.3.1.1.5.3"
	LinkUp    = ".1.3.6.1.6.3.1.1.5.4"
)

Trap OID

View Source
const (
	InvalidValue = "invalid value"
)

MSG

View Source
const (
	OIDHrProcessorLoad = ".1.3.6.1.2.1.25.3.3.1.2"
)

Const

Variables

View Source
var (
	IfState      = []string{"down (1)", "loopback (2)", "waiting (3)", "pointToPoint (4)", "designatedRouter (5)", "backupDesignatedRouter (6)", "otherDesignatedRouter (7)"}
	IfAdminState = []string{"enabled (1)", "disabled (2)"}
	NbrState     = []string{"down (1)", "attempt (2)", "init (3)", "twoWay (4)", "exchangeStart (5)", "exchange (6)", "loading (7)", "full (8)"}
)

Values

View Source
var (
	Enable = []string{"true(1)", "false(2)"}
)

Var

View Source
var (
	OIDs = make(map[string]string, 0)
)

OIDs

View Source
var (
	PeerState = []string{"idle(1)", "connect(2)", "active(3)", "opensent(4)", "openconfirm(5)", "established(6)"}
)

Var

View Source
var (
	SNMPVersion = g.Version2c
)

Common set

Functions

func GetDeviceInfo

func GetDeviceInfo(ip string, communit string, ver g.SnmpVersion) (d model.Device, err error)

GetDeviceInfo get base system information

func GetHostName

func GetHostName(ip string, community string, ver g.SnmpVersion) (host string, err error)

GetHostName RT

func GetIPTable

func GetIPTable(ip string, communit string, ver g.SnmpVersion) (ips map[int]string, err error)

GetIPTable get basic port information

func GetLocalAS

func GetLocalAS(ip, community string, ver g.SnmpVersion) (as int, err error)

GetLocalAS get local as

func GetOne

func GetOne(ip, community, oid string, ver g.SnmpVersion) (rs g.SnmpPDU, err error)

GetOne ip,comunity,oid string

func GetPortInformation

func GetPortInformation(ip, communit, index string, ver g.SnmpVersion) (port *model.Port, err error)

GetPortInformation device,communit,index string

func GetPortsInformation

func GetPortsInformation(ip string, communit string, ver g.SnmpVersion) (ports map[int]*model.Port, err error)

GetPortsInformation get basic port information

func GetPortsStatus

func GetPortsStatus(ip string, communit string, ver g.SnmpVersion) (ports map[int]*model.Port, err error)

GetPortsStatus get basic port information

func GetSnmpInt

func GetSnmpInt(p g.SnmpPDU) (v int)

GetSnmpInt convert result 2 itn

func GetSnmpInt64

func GetSnmpInt64(p g.SnmpPDU) (v int64)

GetSnmpInt64 get counter64

func GetSnmpMacString

func GetSnmpMacString(p g.SnmpPDU) (v string)

GetSnmpMacString get mac address

func GetSnmpString

func GetSnmpString(p g.SnmpPDU) (v string)

GetSnmpString convert result 2 string

func GetSystem

func GetSystem(ip string, communit string, ver g.SnmpVersion) (d model.Device, e error)

GetSystem get base system information

func GetTable

func GetTable(ip string, communit string, ver g.SnmpVersion, oids []string) (tableRows map[string](map[string]g.SnmpPDU), e error)

GetTable implement by BulkWalkAll

func NewSNMP

func NewSNMP(target string, community string, ver g.SnmpVersion) (s *g.GoSNMP)

NewSNMP get a snmp instance

func Ping

func Ping(ip string, communit string, ver g.SnmpVersion) (d model.Device, e error)

Ping snmp pring

Types

type BGPPeer

type BGPPeer struct {
	LocalAddr  string
	LocalPort  int
	RemoteAddr string
	RemotePort int
	RemoteAS   int
	PeerState  int
}

BGPPeer snmp struct

func GetBGPPeerTable

func GetBGPPeerTable(ip string, communit string, ver g.SnmpVersion) (rs []*BGPPeer, err error)

GetBGPPeerTable get Nbr table

func (*BGPPeer) PeerStateStr

func (p *BGPPeer) PeerStateStr() string

PeerStateStr readable state

type CDPItem

type CDPItem struct {
	IfIndex     int
	Enable      int
	MsgInterval int
	Group       int
	Port        int
	Name        string
}

CDPItem basic information wap

func GetCDPTable

func GetCDPTable(ip string, communit string, ver g.SnmpVersion) (ips []*CDPItem, err error)

GetCDPTable get loclTable

func (*CDPItem) ParseEnable

func (i *CDPItem) ParseEnable() string

ParseEnable value

type HrProcessorLoad

type HrProcessorLoad struct {
	Load int
}

HrProcessorLoad process load wap

func GetHrProcessorLoad

func GetHrProcessorLoad(ip string, communit string, ver g.SnmpVersion) (table []*HrProcessorLoad, err error)

GetHrProcessorLoad get loclTable

type IPAddr

type IPAddr struct {
	IP      string
	IfIndex int
	Netmask string
	IfDesc  string
}

IPAddr Entity

func GetIPAddrTable

func GetIPAddrTable(ip string, communit string, ver g.SnmpVersion) (ips []*IPAddr, err error)

GetIPAddrTable get loclTable

type IPForwardItem

type IPForwardItem struct {
	Dest    string `json:"dest"`
	Mask    string `json:"mask"`
	NextHop string `json:"nexthop"`
	IfIndex int    `json:"ifIndex"`
}

IPForwardItem from if table

func GetIPForwardTable

func GetIPForwardTable(ip string, communit string, ver g.SnmpVersion) (items []*IPForwardItem, err error)

GetIPForwardTable get loclTable

type LLdpLoc

type LLdpLoc struct {
	LldpLocPortNum       string
	LldpLocPortIDSubtype string
	LldpLocPortID        string
	LldpLocPortDesc      string
}

LLdpLoc lldap

func GetLLdpLocalTable

func GetLLdpLocalTable(ip string, communit string, ver g.SnmpVersion) (lldpls []*LLdpLoc, err error)

GetLLdpLocalTable get loclTable

type LLdpRem

type LLdpRem struct {
	LLdpRemLocalPortNum string
	LLdpRemSysName      string
	LLdpRemPortID       string
	LLdpRemPortDesc     string
}

LLdpRem lldprem

func GetLLdpRemTable

func GetLLdpRemTable(ip string, communit string, ver g.SnmpVersion) (lldpls []*LLdpRem, err error)

GetLLdpRemTable get remote table

func (*LLdpRem) GetLocalIndex

func (l *LLdpRem) GetLocalIndex() string

GetLocalIndex RT

func (*LLdpRem) GetRemIndex

func (l *LLdpRem) GetRemIndex() string

GetRemIndex RT

type OspfItem

type OspfItem struct {
	OspfIfIPAddress string
	OspfIfAdminStat int
	OspfIfState     int
	OspfIfStatus    int
}

OspfItem ospf iftable item

func GetOspfIfTable

func GetOspfIfTable(ip string, communit string, ver g.SnmpVersion) (ips []*OspfItem, err error)

GetOspfIfTable get loclTable

func (*OspfItem) AdminStateStr

func (o *OspfItem) AdminStateStr() string

AdminStateStr parse meaningful value

func (*OspfItem) StateStr

func (o *OspfItem) StateStr() string

StateStr parse meaningful value

type OspfNbrItem

type OspfNbrItem struct {
	NbrIPAddress string
	NbrRtrID     string
	NbrState     int
}

OspfNbrItem ospf iftable item

func GetOspfNbrTable

func GetOspfNbrTable(ip string, communit string, ver g.SnmpVersion) (rs []*OspfNbrItem, err error)

GetOspfNbrTable get Nbr table

func (*OspfNbrItem) NbrStateStr

func (o *OspfNbrItem) NbrStateStr() string

NbrStateStr RT

type TrapReciver

type TrapReciver struct {
	Address string

	TrapHandler func(s *gosnmp.SnmpPacket, u *net.UDPAddr)
	// contains filtered or unexported fields
}

TrapReciver RT

func (*TrapReciver) Close

func (r *TrapReciver) Close()

Close instance

func (*TrapReciver) Start

func (r *TrapReciver) Start()

Start start an Reciver instance

type WinStorage

type WinStorage struct {
	Descr string `json:"descr"`
	Units int    `json:"units"`
	Size  int64  `json:"size"`
	Used  int64  `json:"used"`
}

WinStorage wap

func GetWinStorage

func GetWinStorage(ip string, communit string, ver g.SnmpVersion) (table []*WinStorage, err error)

GetWinStorage get loclTable

Directories

Path Synopsis
Package main Code generated by go-bindata.
Package main Code generated by go-bindata.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL