snmp

package
v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const MibSleepSecond = time.Duration(500) * time.Millisecond
View Source
const (
	SepEqual = " = "
)

Variables

This section is empty.

Functions

func ExecSnmpWalk

func ExecSnmpWalk(host string, oid string, community string, version string) ([]string, string, error, int)

@title 执行snmp扫描命令 @author xv 11/6/20 7:56 PM @param host 待扫描机器的ip地址 @param oid @param community snmp的团体字 @param version 1|2c|3 @return (result, command, error, lineNum)

func ExecSnmpWalkOnce added in v0.1.7

func ExecSnmpWalkOnce(host string, oid string, community string, version string) ([]string, string, error, int)

func ExecSnmpWalkWithTarget

func ExecSnmpWalkWithTarget(target Target) ([]string, string, error, int)

func ParseList

func ParseList(lines []string, entityMap EntityMap, config MibConfig)

func ParseMap

func ParseMap(lines []string, config MibConfig, dataMap map[string]string)

parse to map example in debug_service

func ParseObject

func ParseObject(lines []string, entity Entity, config MibConfig)

func ParseStringByPrefixRegex

func ParseStringByPrefixRegex(input string, prefix string) (string, error)

Types

type Entity

type Entity interface {
	AddProperty(property string, value string)
}

type EntityMap

type EntityMap interface {
	// find entity in map, set property
	AddProperty(key string, property string, value string)
}

type Log

type Log struct {
	Command string   `json:"command"`
	Logs    []string `json:"logs"`
}

type LogWrapper

type LogWrapper struct {
	Logs map[string]*Log
}

func (*LogWrapper) AddCommandLog added in v0.1.9

func (lw *LogWrapper) AddCommandLog(key string, command string, content []string, err error)

AddCommandLog @Description: @receiver lw @param key @param command @param content @param err

func (*LogWrapper) AddError

func (lw *LogWrapper) AddError(key string, err string)

func (*LogWrapper) AddLog

func (lw *LogWrapper) AddLog(key string, command string, content []string, err error)

func (*LogWrapper) AddSimpleLog added in v0.1.9

func (lw *LogWrapper) AddSimpleLog(key string, content ...interface{})

AddSimpleLog @Description: add log without command @receiver lw @param key if key exists, append @param content anything

func (*LogWrapper) AddStatsLog added in v0.1.9

func (lw *LogWrapper) AddStatsLog(key string, command string, stats string)

AddStats @Description: add command stats @receiver lw LogWrapper @param key log-group @param command log-group.command, add -stats suffix @param stats stats description

type MibConfig

type MibConfig struct {
	Id          int    `json:"id"`
	Name        string `json:"name"`
	Type        string `json:"type"`
	Mib         string `json:"mib"`
	KeyPrefix   string `json:"key-prefix"`
	ValuePrefix string `json:"value-prefix"`
	Attribute   string `json:"attribute"`
	Comment     string `json:"comment"`
}

type Target

type Target struct {
	Host      string // ip地址
	Oid       string
	Community string // snmp的团体字
	Version   string // 1|2c|3
}

Jump to

Keyboard shortcuts

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