Example #1
0
func HostDocker() map[string]string {
	returnDockerData := make(map[string]string)
	dock, _ := docker.GetDockerIDList()
	for _, id := range dock {
		v, _ := docker.CgroupCPUDocker(id)
		returnDockerData[id] = v.CPU
	}
	return returnDockerData
}
Example #2
0
func getData(c Config) postData {
	var p postData
	for _, check := range c.Checks {
		switch check {
		case "memory":
			mem, _ := mem.VirtualMemory()
			p.Memory = mem
		case "cpu":
			cpu, _ := cpu.CPUInfo()
			p.CPU = cpu
		case "host":
			host, _ := host.HostInfo()
			p.Host = host
		case "load":
			load, _ := load.LoadAvg()
			p.Load = load
			//dockerids, _ := docker.GetDockerIDList()
		case "disk":
			disk, _ := disk.DiskUsage("/")
			p.Disk = disk
		case "netio":
			net, _ := net.NetIOCounters(true)
			p.Netio = net
		case "netcon":
			net, _ := net.NetConnections("inet")
			p.Netcon = net
		case "docker":
			returnDockerData := make(map[string]string)
			dock, _ := docker.GetDockerIDList()
			for _, id := range dock {
				v, err := docker.CgroupCPUDocker(id)
				if err != nil {
					log.Error("error %v", err)
				}
				if v.CPU == "" {
					log.Error("could not get CgroupCPU %v", v)
				}
				returnDockerData[id] = v.CPU
			}
			p.Docker = returnDockerData
		}
	}
	return p
}