Documentation ¶
Index ¶
- Constants
- Variables
- func ParseUint16(content []byte) int
- func Uvarint(buf []byte) (x uint64)
- type Asn1BER
- type BitStringValue
- type GoSNMP
- func (x *GoSNMP) BulkWalk(max_repetitions uint8, oid string) (results []SnmpPDU, err error)
- func (x *GoSNMP) Debug(data []byte) (*SnmpPacket, error)
- func (x *GoSNMP) Get(oid string) (ret *SnmpPacket, err error)
- func (x *GoSNMP) GetBulk(non_repeaters, max_repetitions uint8, oids ...string) (ret *SnmpPacket, err error)
- func (x *GoSNMP) GetMulti(oids []string) (ret *SnmpPacket, err error)
- func (x *GoSNMP) GetNext(oid string) (ret *SnmpPacket, err error)
- func (x *GoSNMP) SetDebug(d bool)
- func (x *GoSNMP) SetTimeout(seconds int64)
- func (x *GoSNMP) SetVerbose(v bool)
- func (x *GoSNMP) StreamWalk(oid string, c chan *Variable) error
- func (x *GoSNMP) Walk(oid string) (results []SnmpPDU, err error)
- type RawBER
- type SnmpPDU
- type SnmpPacket
- type SnmpVersion
- type Variable
Constants ¶
const ( Integer Asn1BER = 0x02 BitString = 0x03 OctetString = 0x04 Null = 0x05 ObjectIdentifier = 0x06 Sequence = 0x30 IpAddress = 0x40 Counter32 = 0x41 Gauge32 = 0x42 TimeTicks = 0x43 Opaque = 0x44 NsapAddress = 0x45 Counter64 = 0x46 Uinteger32 = 0x47 NoSuchObject = 0x80 NoSuchInstance = 0x81 GetRequest = 0xa0 GetNextRequest = 0xa1 GetResponse = 0xa2 SetRequest = 0xa3 Trap = 0xa4 GetBulkRequest = 0xa5 EndOfMibView = 0x82 )
SNMP Data Types
Variables ¶
var DEFAULT_PORT = 161
Functions ¶
Types ¶
type BitStringValue ¶
type BitStringValue struct { Bytes []byte // bits packed into bytes. BitLength int // length in bits. }
BitStringValue is the structure to use when you want an ASN.1 BIT STRING type. A bit string is padded up to the nearest byte in memory and the number of valid bits is recorded. Padding bits will be zero.
func (BitStringValue) At ¶
func (b BitStringValue) At(i int) int
At returns the bit at the given index. If the index is out of range it returns false.
func (BitStringValue) RightAlign ¶
func (b BitStringValue) RightAlign() []byte
RightAlign returns a slice where the padding bits are at the beginning. The slice may share memory with the BitString.
type GoSNMP ¶
type GoSNMP struct { Target string Community string Version SnmpVersion Timeout time.Duration Log *l.Logger // contains filtered or unexported fields }
func NewGoSNMP ¶
func NewGoSNMP(target, community string, version SnmpVersion, timeout int64) (*GoSNMP, error)
Creates a new SNMP Client. Target is the IP address, Community the SNMP Community String and Version the SNMP version. Currently only v2c is supported. Timeout parameter is measured in seconds.
func (*GoSNMP) Debug ¶
func (x *GoSNMP) Debug(data []byte) (*SnmpPacket, error)
Debug function. Unmarshals raw bytes and returns the result without the network part
func (*GoSNMP) Get ¶
func (x *GoSNMP) Get(oid string) (ret *SnmpPacket, err error)
Sends an SNMP GET request to the target. Returns a Variable with the response or an error
func (*GoSNMP) GetBulk ¶
func (x *GoSNMP) GetBulk(non_repeaters, max_repetitions uint8, oids ...string) (ret *SnmpPacket, err error)
Sends an SNMP BULK-GET request to the target. Returns a Variable with the response or an error
func (*GoSNMP) GetMulti ¶
func (x *GoSNMP) GetMulti(oids []string) (ret *SnmpPacket, err error)
Sends an SNMP GET request to the target. Returns a Variable with the response or an error
func (*GoSNMP) GetNext ¶
func (x *GoSNMP) GetNext(oid string) (ret *SnmpPacket, err error)
Sends an SNMP Get Next Request to the target. Returns the next variable response from the OID given or an error
func (*GoSNMP) SetTimeout ¶
Sets the timeout for network read/write functions. Defaults to 5 seconds.
func (*GoSNMP) StreamWalk ¶
StreamWalk will start walking a specified OID, and push through a channel the results as it receives them, without waiting for the whole process to finish to return the results
type SnmpPacket ¶
type SnmpPacket struct { Version SnmpVersion Community string RequestType Asn1BER RequestID uint8 Error uint8 ErrorIndex uint8 NonRepeaters uint8 MaxRepetitions uint8 Variables []SnmpPDU }
func Unmarshal ¶
func Unmarshal(packet []byte) (*SnmpPacket, error)
type SnmpVersion ¶
type SnmpVersion uint8
const ( Version1 SnmpVersion = 0x0 Version2c SnmpVersion = 0x1 )
func (SnmpVersion) String ¶
func (s SnmpVersion) String() string