github.com/songzhibin97/gkit@v1.2.13/watching/example/cpu_explode/cpu_explode.go (about) 1 package main 2 3 import ( 4 "net/http" 5 "time" 6 7 "github.com/songzhibin97/gkit/watching" 8 ) 9 10 func init() { 11 http.HandleFunc("/cpuex", cpuex) 12 go http.ListenAndServe(":10003", nil) 13 } 14 15 func main() { 16 w := watching.NewWatching( 17 watching.WithCollectInterval("2s"), 18 watching.WithCoolDown("1m"), 19 watching.WithDumpPath("/tmp"), 20 watching.WithCPUDump(20, 25, 80), 21 ) 22 w.EnableCPUDump().Start() 23 time.Sleep(time.Hour) 24 } 25 26 func cpuex(wr http.ResponseWriter, req *http.Request) { 27 go func() { 28 for { 29 time.Sleep(time.Millisecond) 30 } 31 }() 32 }