gotoolkits / libnetgo Goto Github PK
View Code? Open in Web Editor NEWLinux网络分析工具(golang版本类nethogs工具)
Linux网络分析工具(golang版本类nethogs工具)
cd ~
sudo apt install libpcap-dev gcc
wget https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
go get github.com/gotoolkits/libnetgo
cd ~/go/src/github.com/gotoolkits/libnetgo
go build libnet.go
chmod +x libnet
./libnet -c -ip 192.168.168.165
⇨ http server started on [::]:18081
=======================================================================================================================
| PID | USER | IPLINK |IN|OUT(k)|SENT|RECEIVED(kB/s)| PROGRAM |
=======================================================================================================================
26700 root 192.168.168.165:22-192.168.168.2:50010 0 0 0 0 /usr/sbin/sshd
26736 root 192.168.168.165:22-192.168.168.2:50012 0 0 0 0 /usr/sbin/sshd
12212 root 127.0.0.1:36462-127.0.0.1:8024 0 0 0 0 /root/nps/npc
12212 root 127.0.0.1:36464-127.0.0.1:8024 0 0 0 0 /root/nps/npc
go run -race libnet.go -ip 10.211.55.30
⇨ http server started on [::]:18081
==================
WARNING: DATA RACE
Write at 0x0000015293b0 by goroutine 12:
github.com/gotoolkits/libnetgo/packet.StartNetSniff()
/home/parallels/go/src/github.com/gotoolkits/libnetgo/packet/sniff.go:57 +0x80
github.com/gotoolkits/libnetgo/api.FnSniffOn()
/home/parallels/go/src/github.com/gotoolkits/libnetgo/api/api.go:119 +0xe0
github.com/labstack/echo.(*Echo).add.func1()
/home/parallels/go/src/github.com/labstack/echo/echo.go:505 +0xdd
github.com/labstack/echo/middleware.CORSWithConfig.func1.1()
/home/parallels/go/src/github.com/labstack/echo/middleware/cors.go:121 +0x67b
github.com/labstack/echo.(*Echo).ServeHTTP()
/home/parallels/go/src/github.com/labstack/echo/echo.go:616 +0x447
net/http.serverHandler.ServeHTTP()
/snap/go/4301/src/net/http/server.go:2774 +0xce
net/http.(*conn).serve()
/snap/go/4301/src/net/http/server.go:1878 +0x811
Previous read at 0x0000015293b0 by main goroutine:
[failed to restore the stack]
Goroutine 12 (running) created at:
net/http.(*Server).Serve()
/snap/go/4301/src/net/http/server.go:2884 +0x4c4
github.com/labstack/echo.(*Echo).StartServer()
/home/parallels/go/src/github.com/labstack/echo/echo.go:707 +0x6fc
github.com/gotoolkits/libnetgo/api.ServerRun()
/home/parallels/go/src/github.com/labstack/echo/echo.go:627 +0x9bc
==================
root@ubuntu:~# go get github.com/gotoolkits/libnetgo
/home/go/src/github.com/google/gopacket/pcap/pcap.go:30:22: undefined: pcapErrorNotActivated
/home/go/src/github.com/google/gopacket/pcap/pcap.go:52:17: undefined: pcapTPtr
/home/go/src/github.com/google/gopacket/pcap/pcap.go:64:10: undefined: pcapPkthdr
打开sniff_on开关后,过一段时间,出现broken pipe错误
➜ libnetgo git:(master) ✗ ./libnet -ip 192.168.203.129
⇨ http server started on [::]:18081
ERRO[0032] write tcp 127.0.0.1:18081->127.0.0.1:51516: write: broken pipe
使用ubuntu 20操作系统环境
谢谢!
lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
yum install golang
go get github.com/gotoolkits/libnetgo
cd $GOPATH/src/github.com/gotoolkits/libnetgo
go run libnet.go -ip 10.233.47.169
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.