mibs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SysidMap = "SYSID_MAP.json"
)

Variables

This section is empty.

Functions

func ConvertJson2Yaml

func ConvertJson2Yaml(file string, log logger.ContextL) error

* Code to generate a yaml from file a .mib file. To run:

* Install https://github.com/etingof/pysmi. (pip install pysmi) * Install librenms. (git clone https://github.com/librenms/librenms.git) * Download your mib target. Place into /tmp/snmp_in directory. Create /tmp/snmp_out directory. Use https://help.zscaler.com/downloads/zia/documentation-knowledgebase/analytics/snmp-mibs/about-the-zscaler-snmp-mibs/zscaler-nss-mib.mib as a test if you need one.

* Run mibdump: mibdump.py --mib-source=file:///path/to/src/librenms/mibs --mib-source=file:///tmp/snmp_in --generate-mib-texts --ignore-errors --destination-format json --destination-directory=/tmp/snmp_out MY_MIB_NAME

For example, using mib ZSCALER-NSS-MIB: mibdump.py --mib-source=file:///home/pye/src/librenms/mibs --mib-source=file:///tmp/snmp_in --generate-mib-texts --ignore-errors --destination-format json --destination-directory=/tmp/snmp_out ZSCALER-NSS-MIB

* Verify that /tmp/snmp_out/ZSCALER-NSS-MIB.json exists

* Convert to yaml docker run --rm -v /tmp/snmp_out:/snmp_out kentik/ktranslate:v2 -snmp /etc/ktranslate/snmp-base.yaml -snmp_json2yaml /snmp_out/MY_MIB_NAME.json

For example, using ZSCALER-NSS-MIB: docker run --rm -v /tmp/snmp_out:/snmp_out kentik/ktranslate:v2 -snmp /etc/ktranslate/snmp-base.yaml -snmp_json2yaml /snmp_out/ZSCALER-NSS-MIB.json

* The final yaml file is at /tmp/snmp_out/ZSCALER-NSS-MIB.yaml

NOTE: human checking is still needed. Notably, you will need to:

1) Add an extends section. 2) Ensure that the sysobjectid section is present and sane.

Types

type Constraint

type Constraint struct {
	Enumeration map[string]int64 `json:"enumeration"`
}

type Device

type Device struct {
	Vendor string `yaml:"vendor,omitempty"`
}

type MIB

type MIB struct {
	Mib         string `yaml:"MIB,omitempty"`
	Table       OID    `yaml:"table,omitempty"`
	Symbols     []OID  `yaml:"symbols,omitempty"`
	MetricTags  []Tag  `yaml:"metric_tags,omitempty"`
	ForcedType  string `yaml:"forced_type,omitempty"`
	Symbol      OID    `yaml:"symbol,omitempty"`
	IsInterface bool   `yaml:"is_interface,omitempty"`
	// contains filtered or unexported fields
}

func ToMib

func ToMib(mibSet map[string]*PySMIMib, mibName string, pm *PySMIMib, log logger.ContextL) *MIB

type Match

type Match struct {
	Regex  string `yaml:"regex"`
	Target string `yaml:"target"`
}

type MibDB

type MibDB struct {
	// contains filtered or unexported fields
}

func NewMibDB

func NewMibDB(mibpath string, profileDir string, validate bool, log logger.ContextL) (*MibDB, error)

func (*MibDB) Close

func (db *MibDB) Close()

func (*MibDB) FindProfile

func (mdb *MibDB) FindProfile(sysid string, sysdesc string, mibProfile string) *Profile

func (*MibDB) GetForKey

func (db *MibDB) GetForKey(oid string) (*kt.Mib, error)

func (*MibDB) GetForOid

func (db *MibDB) GetForOid(oid string, profile string, description string) (map[string]*kt.Mib, kt.Provider, error)

func (*MibDB) GetForOidRecur

func (db *MibDB) GetForOidRecur(oid string, profile string, description string) (map[string]*kt.Mib, kt.Provider, bool, error)

Walk up the oid tree until we get something.

func (*MibDB) GetTrap

func (db *MibDB) GetTrap(oid string) *Trap

func (*MibDB) LoadProfiles

func (mdb *MibDB) LoadProfiles(profileDir string) (int, error)

func (*MibDB) LoadPyMibSet

func (mdb *MibDB) LoadPyMibSet(profileDir string) (int, error)

type MibList

type MibList []MIB

Utils to sort

func (MibList) Len

func (s MibList) Len() int

func (MibList) Less

func (s MibList) Less(i, j int) bool

func (MibList) Swap

func (s MibList) Swap(i, j int)

type OID

type OID struct {
	Oid        string           `yaml:"OID,omitempty"`
	Name       string           `yaml:"name,omitempty"`
	Enum       map[string]int64 `yaml:"enum,omitempty"`
	Tag        string           `yaml:"tag,omitempty"`
	Desc       string           `yaml:"description,omitempty"`
	Conversion string           `yaml:"conversion,omitempty"`
	PollTime   int              `yaml:"poll_time_sec,omitempty"`
	MatchAttr  []string         `yaml:"match_attributes,omitempty"`
	Format     string           `yaml:"format,omitempty"`
	AllowDup   bool             `yaml:"allow_duplicate,omitempty"`
}

func (*OID) GetTableName

func (o *OID) GetTableName() string

type Profile

type Profile struct {
	logger.ContextL  `yaml:"-"`
	Metrics          []MIB             `yaml:"metrics,omitempty"`
	Extends          []string          `yaml:"extends,omitempty"`
	Device           Device            `yaml:"device,omitempty"`
	MetricTags       []Tag             `yaml:"metric_tags,omitempty"`
	Sysobjectid      kt.StringArray    `yaml:"sysobjectid,omitempty"`
	From             string            `yaml:"from,omitempty"`
	Provider         kt.Provider       `yaml:"provider,omitempty"`
	NoUseBulkWalkAll bool              `yaml:"no_use_bulkwalkall"`
	Matches          map[string]string `yaml:"matches"`
	MatchesList      []Match           `yaml:"matches_list"`
	SysMap           map[string]string
	// contains filtered or unexported fields
}

func (*Profile) DumpOids

func (p *Profile) DumpOids(log logger.ContextL)

func (*Profile) GetDeviceSysComment

func (p *Profile) GetDeviceSysComment(sysid string) string

func (*Profile) GetMetadata

func (p *Profile) GetMetadata(enabledMibs []string) (map[string]*kt.Mib, map[string]*kt.Mib)

func (*Profile) GetMetrics

func (p *Profile) GetMetrics(enabledMibs []string, counterTimeSec int) (map[string]*kt.Mib, map[string]*kt.Mib, int)

func (*Profile) GetMibs

func (p *Profile) GetMibs() map[string]bool

func (*Profile) GetProfileName

func (p *Profile) GetProfileName(override string) string

type PySMIMib

type PySMIMib struct {
	Name     string   `json:"name"`
	Oid      string   `json:"oid"`
	Syntax   PySyntax `json:"syntax"`
	Desc     string   `json:"description"`
	Class    string   `json:"class"`
	Nodetype string   `json:"nodetype"`
	Type     Type     `json:"type"`
}

type PySMIMibFile

type PySMIMibFile map[string]*PySMIMib

type PySyntax

type PySyntax struct {
	Type  string `json:"type"`
	Class string `json:"class"`
}

type PySysidMap

type PySysidMap map[string][]string

type Tag

type Tag struct {
	Column OID    `yaml:"column,omitempty"`
	Tag    string `yaml:"tag,omitempty"`
	Symbol string `yaml:"symbol,omitempty"`
	Index  int    `yaml:"index,omitempty"`
}

type Trap

type Trap struct {
	Oid           string `yaml:"trap_oid"`
	Name          string `yaml:"trap_name"`
	DropUndefined bool   `yaml:"drop_undefined"`
	Events        []OID  `yaml:"events"`
}

func (*Trap) DropUndefinedVars

func (t *Trap) DropUndefinedVars() bool

type TrapBase

type TrapBase struct {
	logger.ContextL `yaml:"-"`
	Traps           []Trap `yaml:"traps"`
	From            string `yaml:"from,omitempty"`
}

type Type

type Type struct {
	Constraints Constraint `json:"constraints"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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