2017-10-20 06:10:30 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-10-23 05:31:04 +00:00
|
|
|
"git.loafle.net/overflow/ssh_crawler/crawler"
|
2017-10-23 06:59:38 +00:00
|
|
|
"runtime"
|
2017-10-20 06:10:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-10-23 06:59:38 +00:00
|
|
|
runtime.GOMAXPROCS(4)
|
2017-10-20 06:10:30 +00:00
|
|
|
|
|
|
|
const ip = "192.168.1.15"
|
|
|
|
const port = "22"
|
|
|
|
const user = "administrator"
|
|
|
|
const pw = "!@#$qwer1234"
|
|
|
|
|
2017-10-23 05:31:04 +00:00
|
|
|
cr, err := crawler.New(ip, port, user, pw)
|
2017-10-20 06:10:30 +00:00
|
|
|
if err != nil {
|
2017-10-23 05:31:04 +00:00
|
|
|
fmt.Println(err)
|
2017-10-20 06:10:30 +00:00
|
|
|
}
|
|
|
|
|
2017-10-23 05:31:04 +00:00
|
|
|
//CPU
|
2017-10-23 06:59:38 +00:00
|
|
|
cpuCh := make(chan interface{})
|
|
|
|
cr.CPUStat(cpuCh)
|
|
|
|
fmt.Println(<-cpuCh)
|
|
|
|
close(cpuCh)
|
2017-10-20 06:10:30 +00:00
|
|
|
|
2017-10-23 06:59:38 +00:00
|
|
|
//Memory
|
|
|
|
memCh := make(chan interface{})
|
|
|
|
cr.MemStat(memCh)
|
|
|
|
fmt.Println(<-memCh)
|
|
|
|
close(memCh)
|
2017-10-20 06:10:30 +00:00
|
|
|
|
2017-10-23 05:31:04 +00:00
|
|
|
//Disk IO
|
2017-10-23 06:59:38 +00:00
|
|
|
diskioCh := make(chan interface{})
|
|
|
|
cr.DiskIOStat(diskioCh)
|
|
|
|
fmt.Println(<-diskioCh)
|
|
|
|
close(diskioCh)
|
2017-10-23 05:31:04 +00:00
|
|
|
|
|
|
|
//Disk Free
|
2017-10-23 06:59:38 +00:00
|
|
|
diskFreeCh := make(chan interface{})
|
|
|
|
cr.DiskFreeStat(diskFreeCh)
|
|
|
|
fmt.Println(<-diskFreeCh)
|
|
|
|
close(diskFreeCh)
|
2017-10-23 05:31:04 +00:00
|
|
|
|
|
|
|
//Network
|
2017-10-23 06:59:38 +00:00
|
|
|
netCh := make(chan interface{})
|
|
|
|
cr.NetworkStat(netCh)
|
|
|
|
fmt.Println(<-netCh)
|
|
|
|
close(netCh)
|
|
|
|
|
|
|
|
//Load Avg.
|
|
|
|
loadCh := make(chan interface{})
|
|
|
|
cr.LoadAvgStat(loadCh)
|
|
|
|
fmt.Println(<-loadCh)
|
|
|
|
close(loadCh)
|
2017-10-23 05:31:04 +00:00
|
|
|
|
2017-10-23 09:08:19 +00:00
|
|
|
//Process
|
|
|
|
psCh := make(chan interface{})
|
|
|
|
cr.ProcessStat(psCh)
|
|
|
|
fmt.Println(<-psCh)
|
|
|
|
close(psCh)
|
|
|
|
}
|