コード例 #1
0
ファイル: main.go プロジェクト: taysom/va
func main() {
	flag.Parse()
	go func() {
		log.Println(http.ListenAndServe("localhost:6060", nil))
	}()
	if *cpuprofile != "" {
		f, err := os.Create(*cpuprofile)
		if err != nil {
			log.Fatal(err)
		}
		pprof.StartCPUProfile(f)
		defer pprof.StopCPUProfile()
	}
	reportChan = make(chan chan ktop.Callers)
	go ktop.Ktop(reportChan)
	http.HandleFunc("/favicon.ico", favicon)
	http.HandleFunc("/", report)
	http.ListenAndServe(":62832", nil)

	/*
		for i := 0; i < 3000; i++ {
			//n := ktop.NumSysCalls()
			//fmt.Println("n", n)
			time.Sleep(1 * time.Second)
			reportChan <- true
			//fmt.Println(ktop.CallTime)
		}
	*/
}
コード例 #2
0
ファイル: main.go プロジェクト: taysom/va
func main() {
	processFlags()
	procStat := []string{
		"user", "nice", "system", "idle", "iowait", "irq", "softirqs"}
	meminfo := []string{
		"MemTotal", "MemFree", "Buffers", "Cached", "SwapCached",
		"Unevicatable", "AnonPages", "Dirty", "Writeback",
		"Dirty+Writeback",
		"VmallocTotal", "VmallocUsed"}
	http.HandleFunc("/", handler)
	http.HandleFunc("/favicon.ico", favicon)
	http.HandleFunc("/plot.js", scriptPlot)
	http.HandleFunc("/smoothie.js", scriptSmoothie)
	http.HandleFunc("/rand", randHandler())
	http.HandleFunc("/sin", sinHandler())
	http.HandleFunc("/cos", cosHandler())
	for _, name := range procStat {
		http.HandleFunc("/"+name, procStatHandler(name))
	}
	for _, name := range meminfo {
		http.HandleFunc("/"+name, MeminfoHandler(name))
	}
	http.HandleFunc("/fib", fibHandler())
	http.HandleFunc("/ktop", ktopHandler())
	if false {
		go ktop.Ktop()
	}
	if true {
		go ReadMeminfo()
	}
	if true {
		fmt.Println("Listen on localhost:" + port)
		http.ListenAndServe(":"+port, nil)
	} else {
		homeTempl.Execute(os.Stdout, nil)
	}
}