Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "github.com/shirou/gopsutil/cpu"
- "github.com/shirou/gopsutil/mem"
- "github.com/shirou/gopsutil/process"
- "github.com/shirou/gopsutil/load"
- "github.com/shirou/gopsutil/disk"
- "github.com/shirou/gopsutil/host"
- "reflect"
- "time"
- )
- func main() {
- driveC := "C:"
- processor, _ := cpu.Times(false)
- memory,_ := mem.VirtualMemory()
- cpuPercent,_ := cpu.Percent(time.Second,false)
- fmt.Println(reflect.TypeOf(processor))
- fmt.Println(reflect.TypeOf(memory))
- fmt.Println(reflect.TypeOf(cpuPercent))
- fmt.Println("CPU")
- fmt.Println("CPU name",processor[0].CPU)
- fmt.Println("User time",processor[0].User)
- fmt.Println("Idle time",processor[0].Idle)
- fmt.Println("System time",processor[0].System)
- fmt.Println("Nice time",processor[0].Nice)
- fmt.Println("IOwait time",processor[0].Iowait)
- fmt.Println("Irq time",processor[0].Irq)
- fmt.Println("SoftIrq time",processor[0].Softirq)
- fmt.Println("CPU Percent",cpuPercent)
- //fmt.Println(memory.Total)
- infoStat, _ := cpu.Info()
- fmt.Printf("n")
- fmt.Println("--> Hardware Info with Context: ", infoStat)
- procCount, _ := cpu.ProcInfo()
- fmt.Printf("n")
- fmt.Println("--> Process Count: ", procCount)
- fmt.Println("-----------------DISK--------------------------------->")
- driveUsage, _ := disk.Usage(driveC)
- fmt.Printf("n")
- fmt.Println("--> Disk Usage for :", driveUsage)
- partitionInfo, _ := disk.Partitions(true)
- fmt.Printf("n")
- fmt.Println("--> Partitions :", partitionInfo)
- folderInfo, _ := disk.IOCounters("C:", "D:")
- //fmt.Printf("nDisk IO counter remainingn")
- fmt.Printf("n")
- fmt.Println("-->Disk IO counter :", folderInfo)
- fmt.Printf("Docker remainingn")
- fmt.Printf("n")
- fmt.Println("-----------------Host--------------------------------->")
- hostInfo, _ := host.Info()
- fmt.Printf("n")
- fmt.Println("--> Host Info :", hostInfo)
- /*userName, _ := host.Users()
- fmt.Printf("n")
- fmt.Println("--> Username :", userName)*/
- fmt.Println("-----------------Load--------------------------------->")
- avgLoad, _ := load.Avg()
- fmt.Printf("n")
- fmt.Println("--> Average Load :", avgLoad)
- avgMisc, _ := load.Misc()
- fmt.Printf("n")
- fmt.Println("--> Misc :", avgMisc)
- fmt.Println("-----------------RAM--------------------------------->")
- virtMemory, _ := mem.VirtualMemory()
- fmt.Printf("n")
- fmt.Println("--> Virtual Memory :", virtMemory)
- swapMemory, _ := mem.SwapMemory()
- fmt.Printf("n")
- fmt.Println("--> Swap Memory :", swapMemory)
- //fmt.Println("Process running list")
- //processList()
- }
- Can creating application as windows service reduce CPU usage ?
Add Comment
Please, Sign In to add comment