func swSystemInfo(ip string, ch chan SwSystem) { var swSystem SwSystem swSystem.Ip = ip //ping timeout.Millisecond timeout := 1000 pingCount := 1 ping, err := sw.PingStatSummary(ip, pingCount, timeout) if err != nil { log.Println(err) ch <- swSystem return } else { swSystem.Ping = ping["max"] uptime, err := sw.SysUpTime(ip, g.Config().Switch.Community, timeout) if err != nil { log.Println(err) ch <- swSystem return } else { swSystem.Uptime = uptime cpuUtili, err := sw.CpuUtilization(ip, g.Config().Switch.Community, timeout, 1) if err != nil { log.Println(err) } else { swSystem.Cpu = cpuUtili } memUtili, err := sw.MemUtilization(ip, g.Config().Switch.Community, timeout, 1) if err != nil { log.Println(err) } else { swSystem.Mem = memUtili } swModel, err := sw.SysModel(ip, g.Config().Switch.Community, timeout) if err != nil { log.Println(err) } else { swSystem.Model = swModel } swName, err := sw.SysName(ip, g.Config().Switch.Community, timeout) if err != nil { log.Println(err) } else { swSystem.Hostname = swName } } } ch <- swSystem return }
func cpuMetrics(ip string, ch chan SwCpu) { var swCpu SwCpu cpuUtili, err := sw.CpuUtilization(ip, g.Config().Switch.Community, g.Config().Switch.SnmpTimeout, g.Config().Switch.SnmpRetry) if err != nil { log.Println(err) } swCpu.Ip = ip swCpu.CpuUtil = cpuUtili ch <- swCpu return }