package main import ( "fmt" "git.loafle.net/overflow/ssh_crawler/crawler" "encoding/json" ) func main() { const ip = "192.168.1.15" const port = "22" const user = "administrator" const pw = "!@#$qwer1234" const keyFilePath = "" ///home/insanity/.ssh/id_rsa cr, err := crawler.New(ip, port, user, pw, keyFilePath) if err != nil { fmt.Println(err) } cpukeys := []string{ "cpu.usage.sum", "cpu.usage.user", "cpu.usage.system", "cpu.usage.nice", "cpu.usage.idle", "cpu.usage.iowait", "cpu.usage.irq", "cpu.usage.softirq", "cpu.usage.steal", "cpu.usage.guest", "cpu.usage.gnice", } cpuCh := make(chan interface{}) cr.CPUStat(cpuCh, cpukeys) print(<-cpuCh) //Memory memkeys := []string { "mem.usage.total", "mem.usage.free", "mem.usage.available", "mem.usage.buffers", "mem.usage.cached", "mem.swap.usage.total", "mem.swap.usage.free", "mem.swap.usage.cached", } memCh := make(chan interface{}) cr.MemStat(memCh, memkeys) print(<-memCh) //Disk IO ioKeys := []string { "disk[0].io.device", "disk[0].io.readcnt", "disk[0].io.merged_readcnt", "disk[0].io.readbytes", "disk[0].io.readtime", "disk[0].io.writecnt", "disk[0].io.merged_writecnt", "disk[0].io.writebytes", "disk[0].io.writetime", "disk[0].io.iotime", "disk[0].io.weighted", "disk[1].io.readcnt", "disk[1].io.merged_readcnt", "disk[1].io.readbytes", "disk[1].io.readtime", } diskioCh := make(chan interface{}) cr.DiskIOStat(diskioCh, ioKeys) print(<-diskioCh) //Disk Free diskFreekeys := []string { "disk[0].usage.fs", "disk[0].usage.used", "disk[0].usage.available", "disk[0].usage.usedperc", "disk[0].usage.mounted", "disk[1].usage.fs", "disk[2].usage.fs", } diskFreeCh := make(chan interface{}) cr.DiskFreeStat(diskFreeCh, diskFreekeys) print(<-diskFreeCh) //Disk Inode Free diskInodeKeys := []string { "disk[0].inode.usage.fs", "disk[0].inode.usage.used", "disk[0].inode.usage.available", "disk[0].inode.usage.usedperc", "disk[0].inode.usage.mounted", "disk[1].inode.usage.fs", "disk[2].inode.usage.fs", } diskInodeFreeCh := make(chan interface{}) cr.DiskIFreeStat(diskInodeFreeCh, diskInodeKeys) print(<-diskInodeFreeCh) //Network netKeys := []string { "net[0].transfer.iface", "net[0].transfer.recv_byte", "net[0].transfer.recv_packet", "net[0].transfer.recv_err", "net[0].transfer.recv_drop", "net[0].transfer.recv_fifo", "net[0].transfer.recv_frame", "net[0].transfer.recv_compressed", "net[0].transfer.recv_multicast", "net[0].transfer.send_byte", "net[0].transfer.send_packet", "net[0].transfer.send_err", "net[0].transfer.send_drop", "net[0].transfer.send_fifo", "net[0].transfer.send_frame", "net[0].transfer.send_compressed", "net[0].transfer.send_multicast", "net[1].transfer.recv_packet", "net[1].transfer.send_compressed", "net[1].transfer.send_packet", } netCh := make(chan interface{}) cr.NetworkStat(netCh, netKeys) print(<-netCh) //Load Avg. loadCh := make(chan interface{}) cr.LoadAvgStat(loadCh) print(<-loadCh) //Uptime uptCh := make(chan interface{}) cr.Uptime(uptCh) print(<-uptCh) //Process (It doesn't to be a Map. will be displayed by a list) psCh := make(chan interface{}) cr.ProcessStat(psCh) print(<-psCh) } func print(data interface{}) { jsonData, err := json.Marshal(data) if err != nil { } fmt.Println(string(jsonData)) }