Esempio n. 1
0
func (daemon *Daemon) CmdSystemInfo() (*engine.Env, error) {
	sys, err := daemon.Daemon.SystemInfo()
	if err != nil {
		return nil, err
	}

	var num = daemon.PodList.CountContainers()
	v := &engine.Env{}
	v.Set("ID", daemon.ID)
	v.SetInt("Containers", int(num))
	v.SetInt("Images", sys.Images)
	v.Set("Driver", sys.Driver)
	v.SetJson("DriverStatus", sys.DriverStatus)
	v.Set("DockerRootDir", sys.DockerRootDir)
	v.Set("IndexServerAddress", sys.IndexServerAddress)
	v.Set("ExecutionDriver", daemon.Hypervisor)

	// Get system infomation
	meminfo, err := sysinfo.GetMemInfo()
	if err != nil {
		return nil, err
	}
	osinfo, err := sysinfo.GetOSInfo()
	if err != nil {
		return nil, err
	}
	v.SetInt64("MemTotal", int64(meminfo.MemTotal))
	v.SetInt64("Pods", daemon.GetPodNum())
	v.Set("Operating System", osinfo.PrettyName)
	if hostname, err := os.Hostname(); err == nil {
		v.SetJson("Name", hostname)
	}

	return v, nil
}
Esempio n. 2
0
func (daemon *Daemon) CmdInfo(job *engine.Job) error {
	cli := daemon.DockerCli
	sys, err := cli.SendCmdInfo("")
	if err != nil {
		return err
	}

	var num = 0
	daemon.PodsMutex.RLock()
	glog.V(2).Infof("lock read of PodList")
	for _, p := range daemon.PodList {
		num += len(p.Containers)
	}
	daemon.PodsMutex.RUnlock()
	glog.V(2).Infof("unlock read of PodList")
	v := &engine.Env{}
	v.Set("ID", daemon.ID)
	v.SetInt("Containers", num)
	v.SetInt("Images", sys.Images)
	v.Set("Driver", sys.Driver)
	v.SetJson("DriverStatus", sys.DriverStatus)
	v.Set("DockerRootDir", sys.DockerRootDir)
	v.Set("IndexServerAddress", sys.IndexServerAddress)
	v.Set("ExecutionDriver", daemon.Hypervisor)

	// Get system infomation
	meminfo, err := sysinfo.GetMemInfo()
	if err != nil {
		return err
	}
	osinfo, err := sysinfo.GetOSInfo()
	if err != nil {
		return err
	}
	v.SetInt64("MemTotal", int64(meminfo.MemTotal))
	v.SetInt64("Pods", daemon.GetPodNum())
	v.Set("Operating System", osinfo.PrettyName)
	if hostname, err := os.Hostname(); err == nil {
		v.SetJson("Name", hostname)
	}
	if _, err := v.WriteTo(job.Stdout); err != nil {
		return err
	}
	return nil
}