snmpvar

package
v0.0.0-...-f8e7bcd Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package snmpvar maps SNMP variables to float64 values.

Index

Constants

This section is empty.

Variables

View Source
var Div = func(divisor float64) Float64 {
	return func(v snmpgo.Variable) (float64, error) {
		if i, ok := v.(*snmpgo.Integer); ok {
			return float64(i.Value) / divisor, nil
		}
		return 0, fmt.Errorf("unexpected non-integer SNMP variable type %s", v.Type())
	}
}

Div divides SNMP values by a divisor.

View Source
var Ident = func(v snmpgo.Variable) (float64, error) {
	if i, ok := v.(*snmpgo.Integer); ok {
		return float64(i.Value), nil
	}
	return 0, fmt.Errorf("unexpected non-integer SNMP variable type %s", v.Type())
}

Ident is an identify function that returns SNMP values as a float64.

View Source
var Match = func(set ...int) Float64 {
	m := make(map[int]struct{}, len(set))
	for _, element := range set {
		m[element] = struct{}{}
	}
	return func(v snmpgo.Variable) (float64, error) {
		if i, ok := v.(*snmpgo.Integer); ok {
			var value float64
			if _, found := m[int(i.Value)]; found {
				value = 1
			}
			return value, nil
		}
		return 0, fmt.Errorf("unexpected non-integer SNMP variable type %s", v.Type())
	}
}

Match returns 1 if an SNMP value matches an element of the given set.

View Source
var Mul = func(multiplier float64) Float64 {
	return func(v snmpgo.Variable) (float64, error) {
		if i, ok := v.(*snmpgo.Integer); ok {
			return float64(i.Value) * multiplier, nil
		}
		return 0, fmt.Errorf("unexpected non-integer SNMP variable type %s", v.Type())
	}
}

Mul multiplies SNMP values by a multiplier.

Functions

This section is empty.

Types

type Float64

type Float64 func(snmpgo.Variable) (float64, error)

Float64 maps SNMP variables to float64 values.

Jump to

Keyboard shortcuts

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