valuestore

package
v0.0.0-...-234771b Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResultValueStoreAsString

func ResultValueStoreAsString(values *ResultValueStore) string

ResultValueStoreAsString used to format ResultValueStore for debug/trace logging

Types

type ColumnResultValuesType

type ColumnResultValuesType map[string]map[string]ResultValue

ColumnResultValuesType is used to store results fetched for column oids Structure: map[<COLUMN OIDS AS STRING>]map[<ROW INDEX>]ResultValue - the first map key is the table column oid - the second map key is the index part of oid (not prefixed with column oid)

func ResultToColumnValues

func ResultToColumnValues(columnOids []string, snmpPacket *gosnmp.SnmpPacket) (ColumnResultValuesType, map[string]string)

ResultToColumnValues builds column values - ColumnResultValuesType: column values - nextOidsMap: represent the oids that can be used to retrieve following rows/values

type ResultValue

type ResultValue struct {
	SubmissionType profiledefinition.ProfileMetricType `json:"sub_type,omitempty"` // used when sending the metric
	Value          interface{}                         `json:"value"`              // might be a `string`, `[]byte` or `float64` type
}

ResultValue represent a snmp value

func GetResultValueFromPDU

func GetResultValueFromPDU(pduVariable gosnmp.SnmpPDU) (string, ResultValue, error)

GetResultValueFromPDU converts gosnmp.SnmpPDU to ResultValue See possible types here: https://github.com/gosnmp/gosnmp/blob/master/helper.go#L59-L271

- gosnmp.Opaque: No support for gosnmp.Opaque since the type is processed recursively and never returned: is never returned https://github.com/gosnmp/gosnmp/blob/dc320dac5b53d95a366733fd95fb5851f2099387/helper.go#L195-L205 - gosnmp.Boolean: seems not exist anymore and not handled by gosnmp

func (ResultValue) ExtractStringValue

func (sv ResultValue) ExtractStringValue(extractValuePattern *regexp.Regexp) (ResultValue, error)

ExtractStringValue extract value using a regex

func (*ResultValue) ToFloat64

func (sv *ResultValue) ToFloat64() (float64, error)

ToFloat64 converts value to float64

func (ResultValue) ToString

func (sv ResultValue) ToString() (string, error)

ToString converts value to string

type ResultValueStore

type ResultValueStore struct {
	// TODO: make fields private + use a constructor instead
	ScalarValues ScalarResultValuesType `json:"scalar_values"`
	ColumnValues ColumnResultValuesType `json:"column_values"`
}

ResultValueStore store OID values

func (*ResultValueStore) GetColumnIndexes

func (v *ResultValueStore) GetColumnIndexes(columnOid string) ([]string, error)

GetColumnIndexes returns column indexes for a specific column oid

func (*ResultValueStore) GetColumnValueAsFloat

func (v *ResultValueStore) GetColumnValueAsFloat(oid string, index string) float64

GetColumnValueAsFloat look for oid/index in ResultValueStore and returns a float64

func (*ResultValueStore) GetColumnValues

func (v *ResultValueStore) GetColumnValues(oid string) (map[string]ResultValue, error)

GetColumnValues look for oid in ResultValueStore and returns a map[<fullIndex>]ResultValue where `fullIndex` refer to the entire index part of the instance OID. For example if the row oid (instance oid) is `1.3.6.1.4.1.1.2.3.10.11.12`, the column oid is `1.3.6.1.4.1.1.2.3`, the fullIndex is `10.11.12`.

func (*ResultValueStore) GetScalarValue

func (v *ResultValueStore) GetScalarValue(oid string) (ResultValue, error)

GetScalarValue look for oid in ResultValueStore and returns the value and boolean weather valid value has been found

type ScalarResultValuesType

type ScalarResultValuesType map[string]ResultValue

ScalarResultValuesType is used to store results fetched for scalar oids Structure: map[<INSTANCE OID VALUE>]ResultValue - the instance oid value (suffixed with `.0`)

func ResultToScalarValues

func ResultToScalarValues(result *gosnmp.SnmpPacket) ScalarResultValuesType

ResultToScalarValues converts result to scalar values

Jump to

Keyboard shortcuts

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