Пример #1
0
func printSystemInfo() {
	fmt.Println(collector.KernelHostname())
	fmt.Println(collector.KernelMaxFiles())
	fmt.Println(collector.KernelMaxProc())
	fmt.Println(collector.LoadAvg())
	fmt.Println(collector.CpuSnapShoot())
	mountPoints, _ := collector.ListMountPoint()
	fmt.Println(mountPoints)

	for idx := range mountPoints {
		fmt.Println(collector.BuildDeviceUsage(mountPoints[idx]))
	}

	netIfs, err := collector.NetIfs()
	fmt.Println("NetIfs.err: ", err)
	for _, netIf := range netIfs {
		fmt.Println(netIf)
	}

	fmt.Println(collector.MemInfo())

	fmt.Println("listening ports: ", collector.ListenPorts())

	fmt.Println(collector.SystemUptime())

	diskStats, _ := collector.ListDiskStats()
	for _, ds := range diskStats {
		fmt.Println(ds)
	}
}
Пример #2
0
func CfgKernelRouter() {
	m.Get("/proc/kernel/hostname", func(w http.ResponseWriter) string {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		hostname, err := collector.KernelHostname()
		if err != nil {
			return RenderErrDto(err.Error())
		}
		return RenderDataDto(hostname)
	})

	m.Get("/proc/kernel/maxproc", func(w http.ResponseWriter) string {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		maxProc, err := collector.KernelMaxProc()
		if err != nil {
			return RenderErrDto(err.Error())
		}
		return RenderDataDto(maxProc)
	})

	m.Get("/proc/kernel/maxfiles", func(w http.ResponseWriter) string {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		maxFiles, err := collector.KernelMaxFiles()
		if err != nil {
			return RenderErrDto(err.Error())
		}
		return RenderDataDto(maxFiles)
	})

	m.Get("/proc/kernel/version", func(w http.ResponseWriter) string {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		ver, err := systool.CmdOutNoLn("uname", "-r")
		if err != nil {
			return RenderErrDto(err.Error())
		}
		return RenderDataDto(ver)
	})
}