示例#1
0
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
}
示例#2
0
func memMetrics(ip string, ch chan SwMem) {
	var swMem SwMem

	memUtili, err := sw.MemUtilization(ip, g.Config().Switch.Community, g.Config().Switch.SnmpTimeout, g.Config().Switch.SnmpRetry)
	if err != nil {
		log.Println(err)
	}

	swMem.Ip = ip
	swMem.MemUtili = memUtili
	ch <- swMem

	return
}