shirou / gopsutil

psutil for golang
Other
10.47k stars 1.58k forks source link

Monitor specific ports for network #1545

Open Vibhu-Ag opened 10 months ago

Vibhu-Ag commented 10 months ago

Is your feature request related to a problem? Please describe. We use collectd for monitoring the health of VMs. While using collectd, we have the ability to monitor specific ports for network activity - https://collectd.org/wiki/index.php/Plugin:TCPConns.

Now as we migrate to Open Telemetry, this feature of monitoring specific ports is missing. This is crucial for us to have a parity between the systems during migration from one monitoring agent to another.

Opentelemetry uses gopsutil for picking hostmetrics, and this functionality is missing here.

Describe the solution you'd like Ability to monitor specific ports while observing network activity.

Describe alternatives you've considered

Additional context Refer the issue opened with OpenTelemetry here: https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24898

shirou commented 10 months ago

Thanks for the suggestion. Perhaps that functionality could be achieved by using net.Connections() to get all the connections, and then extracting the specified ports from them and counting them. (Perhaps there is a more efficient way to do this, though.)