switch_legacy

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 14 Imported by: 0

README

switch_legacy

交换机监控插件,fork 自 https://github.com/gaochao1/swcollector 可以自动探测网络设备型号,获取 CPU、内存使用率,当然,还有各个网口的监控数据,这是通用的 oid

Configuration

最核心的配置就是指定 IP 列表,有三种写法:

[[instances]]
ips = [
    "172.16.2.1",
    "172.16.4/24",
    "192.168.56.102-192.168.56.120"
]

该插件只支持 SNMP v2c,所以认证信息就是一个 community 字符串

唯一标识标签

网络设备的监控数据,默认都会带有 ip 标签,指定监控数据来源于哪个设备,如果想把监控数据当做夜莺里的监控对象,让网络设备自动出现在夜莺的监控对象表格里,只需要把 switch_id_label 设置为 ident 即可,这样一来,网络设备的 IP 信息会作为 ident 标签的值上报,夜莺会自动读取 ident 标签的值入库

名称映射

有时,我们看到网络设备的 IP,无法分辨是具体哪个设备,此时可以给 IP 一个映射名称:

[mappings]
"192.168.88.160" = "switch001.bj"
"192.168.88.161" = "switch002.bj"

这样一来,上报的监控数据就不用 IP 做标识了,而是使用 switch001.bj 这样的字符串做标识,更易读一些

自定义 oid

[[instances.customs]] 部分可以配置多个,表示自定义 oid,默认情况下,该插件采集的都是设备各个网口的监控数据以及CPU和内存的使用率,如果要采集别的 oid,就需要使用这个自定义功能

监控大盘

社区有小伙伴帮忙做了一个监控大盘,就在该 README 同级目录下,大家可以导入夜莺使用

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChIfStat

type ChIfStat struct {
	IP          string
	UseTime     time.Duration
	IfStatsList []sw.IfStats
}

type Custom

type Custom struct {
	Metric string            `toml:"metric"`
	Tags   map[string]string `toml:"tags"`
	OID    string            `toml:"oid"`
}

type Instance

type Instance struct {
	config.InstanceConfig

	IPs          []string `toml:"ips"`
	Community    string   `toml:"community"`
	IndexTag     bool     `toml:"index_tag"`
	IgnoreIfaces []string `toml:"ignore_ifaces"`

	ConcurrencyForAddress int `toml:"concurrency_for_address"`
	ConcurrencyForRequest int `toml:"concurrency_for_request"`

	PingEnable       bool  `toml:"ping_enable"`
	PingModeFastping bool  `toml:"ping_mode_fastping"`
	PingTimeoutMs    int64 `toml:"ping_timeout_ms"`
	PingRetries      int   `toml:"ping_retries"`

	SnmpModeGosnmp bool  `toml:"snmp_mode_gosnmp"`
	SnmpTimeoutMs  int64 `toml:"snmp_timeout_ms"`
	SnmpRetries    int   `toml:"snmp_retries"`

	GatherPingMetrics   bool `toml:"gather_ping_metrics"`
	GatherFlowMetrics   bool `toml:"gather_flow_metrics"`
	GatherCpuMetrics    bool `toml:"gather_cpu_metrics"`
	GatherMemMetrics    bool `toml:"gather_mem_metrics"`
	GatherOperStatus    bool `toml:"gather_oper_status"`
	GatherPkt           bool `toml:"gather_pkt"`
	GatherBroadcastPkt  bool `toml:"gather_broadcast_pkt"`
	GatherMulticastPkt  bool `toml:"gather_multicast_pkt"`
	GatherDiscards      bool `toml:"gather_discards"`
	GatherErrors        bool `toml:"gather_errors"`
	GatherUnknownProtos bool `toml:"gather_unknown_protos"`
	GatherOutQlen       bool `toml:"gather_out_qlen"`

	SpeedLimit            float64 `toml:"speed_limit"`
	PktLimit              float64 `toml:"pkt_limit"`
	BroadcastPktLimit     float64 `toml:"broadcast_pkt_limit"`
	MulticastPktLimit     float64 `toml:"multicast_pkt_limit"`
	DiscardsPktLimit      float64 `toml:"discards_pkt_limit"`
	ErrorsPktLimit        float64 `toml:"errors_pkt_limit"`
	UnknownProtosPktLimit float64 `toml:"unknown_protos_pkt_limit"`
	OutQlenPktLimit       float64 `toml:"out_qlen_pkt_limit"`

	Customs []Custom `toml:"customs"`
	// contains filtered or unexported fields
}

func (*Instance) Gather

func (ins *Instance) Gather(slist *types.SampleList)

func (*Instance) RealInit

func (ins *Instance) RealInit() error

type LastifMap

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

func NewLastifMap

func NewLastifMap() *LastifMap

func (*LastifMap) Check

func (m *LastifMap) Check(k string) bool

func (*LastifMap) Get

func (m *LastifMap) Get(k string) []sw.IfStats

func (*LastifMap) Set

func (m *LastifMap) Set(k string, v []sw.IfStats)

type Switch

type Switch struct {
	config.PluginConfig
	Instances     []*Instance       `toml:"instances"`
	SwitchIdLabel string            `toml:"switch_id_label"`
	Mappings      map[string]string `toml:"mappings"`
}

func (*Switch) Clone

func (s *Switch) Clone() inputs.Input

func (*Switch) GetInstances

func (s *Switch) GetInstances() []inputs.Instance

func (*Switch) Init

func (s *Switch) Init() error

func (*Switch) MappingIP

func (s *Switch) MappingIP(ip string) string

func (*Switch) Name

func (s *Switch) Name() string

Jump to

Keyboard shortcuts

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