ssh_crawler/main.go

87 lines
1.7 KiB
Go
Raw Normal View History

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-20 06:10:30 +00:00
)
func main() {
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-24 07:09:17 +00:00
//사용자가 cpu.usage.total을 선택했을 때의 수집항목들 (..출력 항목도 포함시켜서 계산결과 리턴해야하나?)
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.guestNice",
}
2017-10-23 06:59:38 +00:00
cpuCh := make(chan interface{})
2017-10-24 07:09:17 +00:00
cr.CPUStat(cpuCh, cpukeys)
2017-10-23 06:59:38 +00:00
fmt.Println(<-cpuCh)
2017-10-20 06:10:30 +00:00
2017-10-23 06:59:38 +00:00
//Memory
2017-10-24 07:09:17 +00:00
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",
}
2017-10-23 06:59:38 +00:00
memCh := make(chan interface{})
2017-10-24 07:09:17 +00:00
cr.MemStat(memCh, memkeys)
2017-10-23 06:59:38 +00:00
fmt.Println(<-memCh)
2017-10-24 07:09:17 +00:00
//memCh := make(chan interface{})
//cr.MemStat(memCh, keys)
//fmt.Println(<-memCh)
////Memory
//memCh := make(chan interface{})
//cr.MemStat(memCh)
//fmt.Println(<-memCh)
//
////Disk IO
//diskioCh := make(chan interface{})
//cr.DiskIOStat(diskioCh)
//fmt.Println(<-diskioCh)
//
////Disk Free
//diskFreeCh := make(chan interface{})
//cr.DiskFreeStat(diskFreeCh)
//fmt.Println(<-diskFreeCh)
//
////Network
//netCh := make(chan interface{})
//cr.NetworkStat(netCh)
//fmt.Println(<-netCh)
//
////Load Avg.
//loadCh := make(chan interface{})
//cr.LoadAvgStat(loadCh)
//fmt.Println(<-loadCh)
//
////Process
//psCh := make(chan interface{})
//cr.ProcessStat(psCh)
//fmt.Println(<-psCh)
2017-10-23 09:08:19 +00:00
}