mirror of
https://github.com/xtaci/kcptun.git
synced 2024-04-21 12:32:32 +00:00
send -SIGUSR1 to dump KCP snmp
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/yamux"
|
||||
@@ -50,6 +52,7 @@ func checkError(err error) {
|
||||
|
||||
func main() {
|
||||
rand.Seed(int64(time.Now().Nanosecond()))
|
||||
go sig_handler()
|
||||
myApp := cli.NewApp()
|
||||
myApp.Name = "kcptun"
|
||||
myApp.Usage = "kcptun client"
|
||||
@@ -178,3 +181,15 @@ func main() {
|
||||
}
|
||||
myApp.Run(os.Args)
|
||||
}
|
||||
|
||||
func sig_handler() {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGUSR1)
|
||||
|
||||
for {
|
||||
switch <-ch {
|
||||
case syscall.SIGUSR1:
|
||||
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import (
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/yamux"
|
||||
@@ -78,6 +80,7 @@ func handleClient(p1, p2 net.Conn) {
|
||||
|
||||
func main() {
|
||||
rand.Seed(int64(time.Now().Nanosecond()))
|
||||
go sig_handler()
|
||||
myApp := cli.NewApp()
|
||||
myApp.Name = "kcptun"
|
||||
myApp.Usage = "kcptun server"
|
||||
@@ -175,3 +178,14 @@ func main() {
|
||||
}
|
||||
myApp.Run(os.Args)
|
||||
}
|
||||
func sig_handler() {
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGUSR1)
|
||||
|
||||
for {
|
||||
switch <-ch {
|
||||
case syscall.SIGUSR1:
|
||||
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user