mibdb

package module
v0.0.0-...-9138707 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: Apache-2.0 Imports: 3 Imported by: 3

README

go-mibdb

Library that converts SNMP MIB names and OIDs

Godoc Reference Build Status Coverage Status Go Report Card

Usage (使用方法)

Import (インポート)
	import mibdb "github.com/twsnmp/go-mibdb"
Load MIBDB / Convert Name to OID / Convert OID to Name

名前とOID間の相互変換

	m, err := mibdb.NewMIBDB("./mib.txt")
	if err != nil {
		fmt.Printf("NewMIBDB failed err=%v", err)
		return
	}
	fmt.Printf("sysDescr=%s", m.NameToOID("sysDescr"))
	fmt.Printf(".1.3.6.1.2.1.1.1.0=%s", m.OIDToName(".1.3.6.1.2.1.1.1.0"))

How to make MIB DB File(mib.txt)

To create mib.txt, execute the snmptranslate command of Net-SNMP as follows.

mib.txtを作るには、Net-SNMPのsnmptranslateコマンドを次のように実行します。

$snmptranslate  -T os  > mib.txt

If an extended MIB is installed in the Net-SNMP environment, it can also be extended.

Net-SNMPの環境に拡張MIBをインストールすれば、拡張MIBにも対応できます。

see ./LICENSE

Copyright 2019 Masayuki Yamai

Documentation

Overview

Package mibdb : SNMP MIB Name to/from OID

Example
m, err := NewMIBDB("./mib.txt")
if err != nil {
	fmt.Printf("NewMIBDB failed err=%v", err)
	return
}
fmt.Printf("sysDescr=%s", m.NameToOID("sysDescr"))
fmt.Printf(".1.3.6.1.2.1.1.1.0=%s", m.OIDToName(".1.3.6.1.2.1.1.1.0"))
fmt.Println(m.GetNameList())
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MIBDB

type MIBDB struct {
	Errors []string
	// contains filtered or unexported fields
}

MIBDB is MIB Name OID Database

func NewMIBDB

func NewMIBDB(path string) (*MIBDB, error)

NewMIBDB create new MIBDB struct

func NewMIBDBFromStr

func NewMIBDBFromStr(s, path string) (*MIBDB, error)

NewMIBDBFromStr create new MIBDB struct

func (*MIBDB) Add

func (m *MIBDB) Add(name, oid string) error

Add : Add name and oid to MIBDB

func (*MIBDB) Clear

func (m *MIBDB) Clear()

Clear : clear MIBDB

func (*MIBDB) GetNameList

func (m *MIBDB) GetNameList() []string

GetNameList : retrun Name list

func (*MIBDB) Load

func (m *MIBDB) Load(path string) error

Load : Laod MIBDB

func (*MIBDB) LoadFromStr

func (m *MIBDB) LoadFromStr(s string) error

LoadFromStr : Load MIBDB from String

func (*MIBDB) NameToOID

func (m *MIBDB) NameToOID(name string) string

NameToOID convert Name to OID function

func (*MIBDB) OIDToName

func (m *MIBDB) OIDToName(oid string) string

OIDToName convert OID to Name function

Jump to

Keyboard shortcuts

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