gopsutil
gopsutil copied to clipboard
replace lsof to platform dependent method
#142 , #143 are related to using lsof to get Network connection info.
To replace lsof, we needs at least these functions. inet_ntop porting, sysctl decode functions, and so on are little bit heavy to implement. I will update this issue step by step.
- [x] Linux (see #169)
- [x] getting inode list from processes
- [x] porting socket.inet_ntop to pure golang (linux struct)
- [x] IPv6
- [x] Unix Pipe
- [x] windows
- [x] needs research
- [x] rtlIpv4AddressToStringA
- [x] rtlIpv6AddressToStringA
- [x] getExtendedTcpTable
- [ ] darwin
- [ ] proc_pidinfo and retrieve proc_fdtype
- [ ] inet_ntop
- [ ] freebsd
- [ ] sysctl net.inet.tcp.pcblist for TCP
- [ ] sysctl net.inet.udp.pcblist for UDP
- [ ] sysctl net.local.stream.pcblist for socket stream
- [ ] sysctl net.local.dgram.pcblist for socket dgram
- [ ] porting inet_ntop to pure golang (freebsd struct)
- [ ] porting kinfo_file
:+1: great to see that you are taking this on!
looking forward to this, thanks for your work @shirou!
OK. now I have implemented linux version at #169. The output is same as psutil, but more tests are required.
FreeBSD
sysctl net.inet.tcp.pcblist returnes xtcpcb struct. But since it is complicated to parse to golang struct, time should be required.
Darwin
To get NetConnections, proc_pidinfo() is required and it seems to invoke by only CGO. I am thinking net is also use CGO or not. Or, the net.inet.tcp.pcblist is exists on Darwin also, the FreeBSD code may be used on Darwin, too. I will challenge after FreeBSD.
windows
not yet...
v2 migration
It takes a time to implement, I think prioritize v2.
Is this dead in the water? I'm seeing flakiness with using lsof where the command never finishes.
@NullSoldier what platform do you want to replace lsof?