Пример #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 CfgDfRouter() {
	m.Get("/proc/df/bytes", func(w http.ResponseWriter) string {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")

		mountPoints, err := collector.ListMountPoint()
		if err != nil {
			return RenderErrDto(err.Error())
		}

		var ret [][]interface{} = make([][]interface{}, 0)
		for idx := range mountPoints {
			var du *collector.DeviceUsageStruct
			du, err = collector.BuildDeviceUsage(mountPoints[idx])
			if err == nil {
				ret = append(ret,
					[]interface{}{
						du.FsSpec,
						formatter.DisplaySize(float64(du.BlocksAll)),
						formatter.DisplaySize(float64(du.BlocksUsed)),
						formatter.DisplaySize(float64(du.BlocksFree)),
						fmt.Sprintf("%.1f%%", du.BlocksUsedPercent),
						du.FsFile,
						formatter.DisplaySize(float64(du.InodesAll)),
						formatter.DisplaySize(float64(du.InodesUsed)),
						formatter.DisplaySize(float64(du.InodesFree)),
						fmt.Sprintf("%.1f%%", du.BlocksUsedPercent),
						du.FsVfstype,
					})
			}
		}

		return RenderDataDto(ret)

	})

}