netstat

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

netstat_filter

该插件采集网络连接情况,并根据用户条件进行过滤统计,以达到监控用户关心链接情况

指标列表

tcp_established
tcp_syn_sent tcp_syn_recv tcp_fin_wait1 tcp_fin_wait2 tcp_time_wait tcp_close tcp_close_wait tcp_last_ack tcp_listen tcp_closing tcp_none tcp_send_queue tcp_recv_queue

功能说明

对源IP、源端口、目标IP和目标端口过滤后进行网卡recv-Q、send-Q进行采集,该指标可以很好反应出指定连接的质量,例如rtt时间过长,导致收到服务端ack确认很慢就会使send-Q长期大于0,可以及时通过监控发现,从而提前优化网络或程序

当过滤结果为多个连接时会将send和recv值进行加和 例如: 配置文件raddr_port = 11883 当本地和不同IP的11883都有连接建立的情况下,会将多条连接的结果进行加和。或在并发多连接的情况下,会合并加合,总之过滤的越粗略被加合数就会越多。

多条规则请复制[[instances]]进行配置

注意事项

netstat_filter_tcp_send_queue和netstat_filter_tcp_recv_queue指标目前只支持linux。windows用户默认为0。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterEntries

func FilterEntries(entries []Entry, srcIP string, srcPort uint32, dstIP string, dstPort uint32) map[string]struct {
	Txq int
	Rxq int
}

func Trim

func Trim(s string) string

Trim remove trailing spaces from a string.

Types

type Entry

type Entry struct {
	Proto   string
	SrcIP   net.IP
	SrcPort uint
	DstIP   net.IP
	DstPort uint
	Txq     uint
	Rxq     uint
	UserId  int
	INode   int
}

Entry holds the information of a /proc/net/* entry. For example, /proc/net/tcp: sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000 1000 0 18083222

func NewEntry

func NewEntry(proto string, srcIP net.IP, srcPort uint, dstIP net.IP, dstPort uint, txq uint, rxq uint, userId int, iNode int) Entry

NewEntry creates a new entry with values from /proc/net/

func Parse

func Parse(proto string) ([]Entry, error)

Parse scans and retrieves the opened connections, from /proc/net/ files

type Instance

type Instance struct {
	config.InstanceConfig

	Laddr_IP   string `toml:"laddr_ip"`
	Laddr_Port uint32 `toml:"laddr_port"`
	Raddr_IP   string `toml:"raddr_ip"`
	Raddr_Port uint32 `toml:"raddr_port"`
	// contains filtered or unexported fields
}

func (*Instance) Gather

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

func (*Instance) Init

func (ins *Instance) Init() error

type NetStatFilter

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

func (*NetStatFilter) Clone

func (l *NetStatFilter) Clone() inputs.Input

func (*NetStatFilter) GetInstances

func (l *NetStatFilter) GetInstances() []inputs.Instance

func (*NetStatFilter) Name

func (l *NetStatFilter) Name() string

Jump to

Keyboard shortcuts

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