net_response

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: 13 Imported by: 0

README

net_response

网络探测插件,通常用于监控本机某个端口是否在监听,或远端某个端口是否能连通

code meanings

  • 0: Success
  • 1: Timeout
  • 2: ConnectionFailed
  • 3: ReadFailed
  • 4: StringMismatch

Configuration

最核心的配置就是 targets 部分,指定探测的目标,下面的例子:

[[instances]]
targets = [
    "10.2.3.4:22",
    "localhost:6379",
    ":9090"
]
  • 10.2.3.4:22 表示探测 10.2.3.4 这个机器的 22 端口是否可以连通
  • localhost:6379 表示探测本机的 6379 端口是否可以连通
  • :9090 表示探测本机的 9090 端口是否可以连通

监控数据或告警事件中只是一个 IP 和端口,接收告警的人看到了,可能不清楚只是哪个业务的模块告警了,可以附加一些更有价值的信息放到标签里,比如例子中:

labels = { region="cloud", product="n9e" }

标识了这是 cloud 这个 region,n9e 这个产品,这俩标签会附到时序数据上,告警的时候自然也会报出来。

监控大盘和告警规则

该 README 的同级目录下,提供了 dashboard.json 就是监控大盘的配置,alerts.json 是告警规则,可以导入夜莺使用。

Documentation

Index

Constants

View Source
const (
	Success          uint64 = 0
	Timeout          uint64 = 1
	ConnectionFailed uint64 = 2
	ReadFailed       uint64 = 3
	StringMismatch   uint64 = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Instance

type Instance struct {
	config.InstanceConfig

	Targets     []string        `toml:"targets"`
	Protocol    string          `toml:"protocol"`
	Timeout     config.Duration `toml:"timeout"`
	ReadTimeout config.Duration `toml:"read_timeout"`
	Send        string          `toml:"send"`
	Expect      string          `toml:"expect"`

	Mappings map[string]map[string]string `toml:"mappings"`
}

func (*Instance) Gather

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

func (*Instance) Init

func (ins *Instance) Init() error

func (*Instance) TCPGather

func (ins *Instance) TCPGather(address string) (map[string]string, map[string]interface{}, error)

func (*Instance) UDPGather

func (ins *Instance) UDPGather(address string) (map[string]string, map[string]interface{}, error)

UDPGather will execute if there are UDP tests defined in the configuration. It will return a map[string]interface{} for fields and a map[string]string for tags

type NetResponse

type NetResponse struct {
	config.PluginConfig
	Instances []*Instance `toml:"instances"`

	Mappings map[string]map[string]string `toml:"mappings"`
}

func (*NetResponse) Clone

func (n *NetResponse) Clone() inputs.Input

func (*NetResponse) GetInstances

func (n *NetResponse) GetInstances() []inputs.Instance

func (*NetResponse) Name

func (n *NetResponse) Name() string

Jump to

Keyboard shortcuts

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