Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNetsnmpTranslator ¶
func NewNetsnmpTranslator() *netsnmpTranslator
Types ¶
type ClientConfig ¶
type ClientConfig struct { // Timeout to wait for a response. Timeout config.Duration `toml:"timeout"` Retries int `toml:"retries"` // Values: 1, 2, 3 Version uint8 `toml:"version"` UnconnectedUDPSocket bool `toml:"unconnected_udp_socket"` // Path to mib files Path []string `toml:"path"` // Translator implementation Translator string `toml:"translator"` // Parameters for Version 1 & 2 Community string `toml:"community"` // Parameters for Version 2 & 3 MaxRepetitions uint32 `toml:"max_repetitions"` // Parameters for Version 3 ContextName string `toml:"context_name"` // Values: "noAuthNoPriv", "authNoPriv", "authPriv" SecLevel string `toml:"sec_level"` SecName string `toml:"sec_name"` // Values: "MD5", "SHA", "". Default: "" AuthProtocol string `toml:"auth_protocol"` AuthPassword string `toml:"auth_password"` // Values: "DES", "AES", "". Default: "" PrivProtocol string `toml:"priv_protocol"` PrivPassword string `toml:"priv_password"` EngineID string `toml:"-"` EngineBoots uint32 `toml:"-"` EngineTime uint32 `toml:"-"` }
type Field ¶
type Field struct { // Name will be the name of the field. Name string `toml:"name"` // OID is prefix for this field. The plugin will perform a walk through all // OIDs with this as their parent. For each value found, the plugin will strip // off the OID prefix, and use the remainder as the index. For multiple fields // to show up in the same row, they must share the same index. Oid string `toml:"oid"` // OidIndexSuffix is the trailing sub-identifier on a table record OID that will be stripped off to get the record's index. OidIndexSuffix string `toml:"oid_index_suffix"` // OidIndexLength specifies the length of the index in OID path segments. It can be used to remove sub-identifiers that vary in content or length. OidIndexLength int `toml:"oid_index_length"` // IsTag controls whether this OID is output as a tag or a value. IsTag bool `toml:"is_tag"` // Conversion controls any type conversion that is done on the value. // "float"/"float(0)" will convert the value into a float. // "float(X)" will convert the value into a float, and then move the decimal before Xth right-most digit. // "int" will conver the value into an integer. // "hwaddr" will convert a 6-byte string to a MAC address. // "ipaddr" will convert the value to an IPv4 or IPv6 address. Conversion string `toml:"conversion"` // Translate tells if the value of the field should be snmptranslated Translate bool `toml:"translate"` // Secondary index table allows to merge data from two tables with different index // that this filed will be used to join them. There can be only one secondary index table. SecondaryIndexTable bool `toml:"secondary_index_table"` // This field is using secondary index, and will be later merged with primary index // using SecondaryIndexTable. SecondaryIndexTable and SecondaryIndexUse are exclusive. SecondaryIndexUse bool `toml:"secondary_index_use"` // Controls if entries from secondary table should be added or not if joining // index is present or not. I set to true, means that join is outer, and // index is prepended with "Secondary." for missing values to avoid overlaping // indexes from both tables. // Can be set per field or globally with SecondaryIndexTable, global true overrides // per field false. SecondaryOuterJoin bool `toml:"secondary_outer_join"` // contains filtered or unexported fields }
Field holds the configuration for a Field to look up.
type GosnmpWrapper ¶
GosnmpWrapper wraps a *gosnmp.GoSNMP object so we can use it as a snmpConnection.
func NewWrapper ¶
func NewWrapper(s ClientConfig) (GosnmpWrapper, error)
func (GosnmpWrapper) Host ¶
func (gs GosnmpWrapper) Host() string
Host returns the value of GoSNMP.Target.
func (*GosnmpWrapper) SetAgent ¶
func (gs *GosnmpWrapper) SetAgent(agent string) error
SetAgent takes a url (scheme://host:port) and sets the wrapped GoSNMP struct's corresponding fields. This shouldn't be called after using the wrapped GoSNMP struct, for example after connecting.
type Instance ¶
type Instance struct { config.InstanceConfig // The SNMP agent to query. Format is [SCHEME://]ADDR[:PORT] (e.g. // udp://1.2.3.4:161). If the scheme is not specified then "udp" is used. Agents []string `toml:"agents"` // The tag used to name the agent host AgentHostTag string `toml:"agent_host_tag"` ClientConfig Tables []Table `toml:"table"` // Name & Fields are the elements of a Table. // Categraf chokes if we try to embed a Table. So instead we have to embed the // fields of a Table, and construct a Table during runtime. Name string `toml:"name"` Fields []Field `toml:"field"` Mappings map[string]map[string]string `toml:"mappings"` // contains filtered or unexported fields }
func (*Instance) Gather ¶
func (ins *Instance) Gather(slist *types.SampleList)
Gather retrieves all the configured fields and tables. Any error encountered does not halt the process. The errors are accumulated and returned at the end.
type RTable ¶
type RTable struct { // Name is the name of the field, copied from Table.Name. Name string `toml:"name"` // Time is the time the table was built. Time time.Time `toml:"time"` // Rows are the rows that were found, one row for each table OID index found. Rows []RTableRow `toml:"rows"` }
RTable is the resulting table built from a Table.
type RTableRow ¶
type RTableRow struct { // Tags are all the Field values which had IsTag=true. Tags map[string]string `toml:"tags"` // Fields are all the Field values which had IsTag=false. Fields map[string]interface{} `toml:"fields"` }
RTableRow is the resulting row containing all the OID values which shared the same index.
type Snmp ¶
type Snmp struct { config.PluginConfig Instances []*Instance `toml:"instances"` Mappings map[string]map[string]string `toml:"mappings"` }
Snmp holds the configuration for the plugin.
func (*Snmp) GetInstances ¶
type Table ¶
type Table struct { // Name will be the name of the measurement. Name string `toml:"name"` // Which tags to inherit from the top-level config. InheritTags []string `toml:"inherit_tags"` // Adds each row's table index as a tag. IndexAsTag bool `toml:"index_as_tag"` // Fields is the tags and values to look up. Fields []Field `toml:"field"` // OID for automatic field population. // If provided, init() will populate Fields with all the table columns of the // given OID. Oid string `toml:"oid"` IncludeFilter []string `toml:"include_filter"` Filters []string `toml:"filters"` FilterExpression string `toml:"filters_expression"` // contains filtered or unexported fields }
Table holds the configuration for an SNMP table.
func (Table) Build ¶
func (t Table) Build(gs snmpConnection, walk bool, tr Translator) (*RTable, error)
Build retrieves all the fields specified in the table and constructs the RTable.
func (*Table) Init ¶
func (t *Table) Init(tr Translator) error
Init builds & initializes the nested fields.