Documentation
¶
Overview ¶
Package snmputil provides helper routines for gosnmp
Index ¶
- func DebugLogger(logger *log.Logger)
- func LoadMIBs(filename, mibs string) error
- func OIDList(mib string, oids []string, w io.Writer) error
- func Octets(in string) []int
- func Poller(p Profile, c Criteria, s Sender, fn ErrFunc, l *log.Logger) error
- func Quit()
- func Sampler(p Profile, c Criteria, s Sender) error
- type Collector
- type Criteria
- type ErrFunc
- type MibInfo
- type Profile
- type Recipe
- type Recipies
- type Sender
- func CalcSender(sender Sender, cook Recipies) Sender
- func DebugSender(sender Sender, logger *log.Logger) (Sender, error)
- func IntegerSender(sender Sender) Sender
- func RegexpSender(sender Sender, regexps []string, keep bool) (Sender, error)
- func SplitSender(s1, s2 Sender) (Sender, error)
- func StripSender(sender Sender, taglist []string) Sender
- type TimeStamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugLogger ¶
DebugLogger logs all SNMP debug data to the given logger
Types ¶
type Collector ¶
Collector collects unique strings (OIDs)
func NewCollector ¶
NewCollector returns a Collector to inspect OIDs used
type Criteria ¶
type Criteria struct { OID string // OID can be dotted string or symbolic name Index string // OID of table index Tags map[string]string // any additional tags to associate Aliases map[string]string // optional column aliases Rename map[string]string // rename from key to value Regexps []string // list of regular expressions to filter by name Keep bool // Keep matched names if true, discard matches if false OIDTag bool // add OID as a tag Suffix bool // save suffix portion of OID as tag["suffix"] Count int // how many times to poll for data (0 is forever) Freq int // how often to poll for data (in seconds) Refresh int // how often to refresh column data (in seconds) }
Criteria specifies what to query and what to keep
type MibInfo ¶
type MibInfo struct { Name string OID string Syntax string Default string Hint string Index string Units string Access string Augments string Status string Description string }
MibInfo contains all the details of a MIB entry
type Profile ¶
type Profile struct {
Host, Community, Version string
Port, Timeout, Retries int
// for SNMP v3
SecLevel, AuthUser, AuthPass, AuthProto, PrivProto, PrivPass string
}
Profile contains the settings needed to establish an SNMP connection
type Recipe ¶
type Recipe struct { Rename string // new name to give data (if set) Orig bool // send original data as well if set Rate bool // calculate rate instead of difference }
Recipe describes how to "cook" the data
type Sender ¶
Sender sends the interpreted PDU value to be saved or whathaveyou
func CalcSender ¶
CalcSender returns a sender that optionally "cooks" the data It requires OIDTag to be true in the snmp criteria to track state
A example:
r := snmp.Recipies{ "ifHCInOctets": {"OCTETS_PER_SECOND", true, true}, } sender := snmp.SampleSender(hostname) sender = snmp.StripTags(sender, []string{"oid"}) sender = snmp.CalcSender(sender, r) Bulkwalker(profile, criteria, freq, sender, nil, nil) error {
func DebugSender ¶
DebugSender returns a Sender that prints out data sent to it
func IntegerSender ¶
IntegerSender returns a sender that makes unsigned counters signed integers
func RegexpSender ¶
RegexpSender returns a Sender that filters results based on name
func SplitSender ¶
SplitSender returns a Sender that sends data to two senders
func StripSender ¶
StripSender returns a sender that strips matching tags