Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

为何端口监控结果有异常 #16

Open
zhanglei216 opened this issue Jun 28, 2019 · 8 comments
Open

为何端口监控结果有异常 #16

zhanglei216 opened this issue Jun 28, 2019 · 8 comments

Comments

@zhanglei216
Copy link

当win服务器开启监听多个端口,都是bind 0.0.0.0形式,为何有的端口可以得到值value=1,有的端口value=0,在cmd验证telnet这些端口都是监听状态的。

@zhanglei216
Copy link
Author

linux的agent端口监控使用的命令是ss,这个agent是用的什么形式?

@itmajing
Copy link

我也遇到了端口结果为0的情况

@yangding39
Copy link

同问,端口怎么也监控不到

@zhanglei216
Copy link
Author

同问,端口怎么也监控不到
这家伙用go的socket去listen windows端口,如果监听失败认为就是端口启用,go的socket我试了一下有问题

@itmajing
Copy link

@zhanglei216 我认为应该先获取当前所有的占用端口列表,然后和监控端口做比对会好一点

@CCColby
Copy link

CCColby commented Oct 9, 2019

@zhanglei216 我认为应该先获取当前所有的占用端口列表,然后和监控端口做比对会好一点

你们解决了这个问题吗。。。我这里也是检测值为0,但是端口是监听状态的

@zhangjianpinghik
Copy link

请教下 监控端口和进程该怎么配置?@zhanglei216

@signmem
Copy link

signmem commented Apr 28, 2021

1 修改 portstat.go
2 重构 CheckTCPPortUsed 即可解决

func CheckTCPPortUsed (port int64) bool {
	// use to check port is used
	// when multi ip in IP(), then return the first one.
	// IP() need to rewrite .. to be continue

	ipaddr := g.IP()
	timeout := 200 * time.Millisecond
	target := fmt.Sprintf("%s:%d", ipaddr, port)
	conn, err := net.DialTimeout("tcp", target, timeout)
	if err != nil {
		return false
	}
	if conn != nil {
		conn.Close()
		return true
	}
	return false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants