// SystemInfo returns information about the host server the daemon is running on.
354261
func (daemon *Daemon) SystemInfo() (*types.Info, error) {
	sysInfo := sysinfo.New(true)
	cRunning, cPaused, cStopped := stateCtr.get()

	v := &types.Info{
		ID:                 daemon.ID,
		Containers:         cRunning + cPaused + cStopped,
		ContainersRunning:  cRunning,
		ContainersPaused:   cPaused,
		ContainersStopped:  cStopped,
		Images:             daemon.imageService.CountImages(),
		IPv4Forwarding:     !sysInfo.IPv4ForwardingDisabled,
		BridgeNfIptables:   !sysInfo.BridgeNFCallIPTablesDisabled,
		BridgeNfIP6tables:  !sysInfo.BridgeNFCallIP6TablesDisabled,
		Debug:              debug.IsEnabled(),
		Name:               hostName(),
		NFd:                fileutils.GetTotalUsedFds(),
		NGoroutines:        runtime.NumGoroutine(),
		SystemTime:         time.Now().Format(time.RFC3339Nano),
		LoggingDriver:      daemon.defaultLogConfig.Type,
		CgroupDriver:       daemon.getCgroupDriver(),
		NEventsListener:    daemon.EventsService.SubscribersCount(),
		KernelVersion:      kernelVersion(),
		OperatingSystem:    operatingSystem(),
		IndexServerAddress: registry.IndexServer,
		OSType:             platform.OSType,
		Architecture:       platform.Architecture,
		RegistryConfig:     daemon.RegistryService.ServiceConfig(),
		NCPU:               sysinfo.NumCPU(),
		MemTotal:           memInfo().MemTotal,
		GenericResources:   daemon.genericResources,
		DockerRootDir:      daemon.configStore.Root,
		Labels:             daemon.configStore.Labels,
		ExperimentalBuild:  daemon.configStore.Experimental,
		ServerVersion:      dockerversion.Version,
		ClusterStore:       daemon.configStore.ClusterStore,
		ClusterAdvertise:   daemon.configStore.ClusterAdvertise,
		HTTPProxy:          maskCredentials(sockets.GetProxyEnv("http_proxy")),
		HTTPSProxy:         maskCredentials(sockets.GetProxyEnv("https_proxy")),
		NoProxy:            sockets.GetProxyEnv("no_proxy"),
		LiveRestoreEnabled: daemon.configStore.LiveRestoreEnabled,
		Isolation:          daemon.defaultIsolation,
	}

	daemon.fillAPIInfo(v)
	// Retrieve platform specific info
	daemon.fillPlatformInfo(v, sysInfo)
	daemon.fillDriverInfo(v)
	daemon.fillPluginsInfo(v)
	daemon.fillSecurityOptions(v, sysInfo)
	daemon.fillLicense(v)

	return v, nil
}
2100
func (s *ServerMethods) Info() (*Server, error) {
	r := &Server{}
	if _, err := s.ExecCmd(NewCmd("serverinfo").WithResponse(&r)); err != nil {
		return nil, err
	}

	return r, nil
}
1165879
func getNetworkInfo(ip string) (*nodeInfo, error) {
	iface, mask, err := interfaceByIP(ip)
	if err != nil {
		return nil, err
	}
	return &nodeInfo{
		iface:   iface,
		ip:      ip,
		netmask: mask,
	}, nil
}
1124143
func (fs *FSObjects) StorageInfo(ctx context.Context) StorageInfo {
	di, err := getDiskInfo(fs.fsPath)
	if err != nil {
		return StorageInfo{}
	}
	used := di.Total - di.Free
	if !fs.diskMount {
		used = atomic.LoadUint64(&fs.totalUsed)
	}
	storageInfo := StorageInfo{
		Used:      used,
		Total:     di.Total,
		Available: di.Free,
	}
	storageInfo.Backend.Type = BackendFS
	return storageInfo
}
121273
func (c *crioClientImpl) DaemonInfo() (types.CrioInfo, error) {
	info := types.CrioInfo{}
	req, err := c.getRequest("/info")
	if err != nil {
		return info, err
	}
	resp, err := c.client.Do(req)
	if err != nil {
		return info, err
	}
	defer resp.Body.Close()
	err = json.NewDecoder(resp.Body).Decode(&info)
	return info, err
}
761527
func NewProcessInfo(name, namespace string) *ProcessInfo {
	// try to concat the hostname if available
	host, _ := os.Hostname()
	if host != "" {
		name = fmt.Sprintf("%s-%s", name, host)
	}
	return &ProcessInfo{
		Name:      name,
		Namespace: namespace,
	}
}
69939
func (s *ServerMethods) InstanceInfo() (*Instance, error) {
	r := &Instance{}
	if _, err := s.ExecCmd(NewCmd("instanceinfo").WithResponse(&r)); err != nil {
		return nil, err
	}

	return r, nil
}
526937
func (s *Service) DomainInfo(ctx context.Context, appIdentity string, domainIdentity string) (*Domain, error) {
	var domain Domain
	return &domain, s.Get(ctx, &domain, fmt.Sprintf("/apps/%v/domains/%v", appIdentity, domainIdentity), nil, nil)
}
736428
func (s *Stack) NICInfo() map[tcpip.NICID]NICInfo {
	s.mu.RLock()
	defer s.mu.RUnlock()

	nics := make(map[tcpip.NICID]NICInfo)
	for id, nic := range s.nics {
		flags := NICStateFlags{
			Up:          true, // Netstack interfaces are always up.
			Running:     nic.linkEP.IsAttached(),
			Promiscuous: nic.isPromiscuousMode(),
			Loopback:    nic.linkEP.Capabilities()&CapabilityLoopback != 0,
		}
		nics[id] = NICInfo{
			Name:              nic.name,
			LinkAddress:       nic.linkEP.LinkAddress(),
			ProtocolAddresses: nic.Addresses(),
			Flags:             flags,
			MTU:               nic.linkEP.MTU(),
			Stats:             nic.stats,
		}
	}
	return nics
}
1064923
func (ctx *HookContext) NetworkInfo(bindingNames []string, relationId int) (map[string]params.NetworkInfoResult, error) {
	var relId *int
	if relationId != -1 {
		relId = &relationId
	}
	return ctx.unit.NetworkInfo(bindingNames, relId)
}
154539
func (m HostCertificateManager) CertificateInfo(ctx context.Context) (*HostCertificateInfo, error) {
	var hs mo.HostSystem
	var cm mo.HostCertificateManager

	pc := property.DefaultCollector(m.Client())

	err := pc.RetrieveOne(ctx, m.Reference(), []string{"certificateInfo"}, &cm)
	if err != nil {
		return nil, err
	}

	_ = pc.RetrieveOne(ctx, m.Host.Reference(), []string{"summary.config.sslThumbprint"}, &hs)

	return &HostCertificateInfo{
		HostCertificateManagerCertificateInfo: cm.CertificateInfo,
		ThumbprintSHA1:                        hs.Summary.Config.SslThumbprint,
	}, nil
}
400595
func (d *DeployerAPI) ConnectionInfo() (result params.DeployerConnectionValues, err error) {
	apiAddrs, err := d.APIAddresses()
	if err != nil {
		return result, err
	}
	result = params.DeployerConnectionValues{
		APIAddresses: apiAddrs.Result,
	}
	return result, err
}
1059237
func Info(deviceName string) ([]*DeviceInfo, error) {
	output, err := dmsetup(
		"info",
		"--columns",
		"--noheadings",
		"-o",
		"name,blkdevname,attr,major,minor,open,segments,events",
		"--separator",
		" ",
		deviceName)

	if err != nil {
		return nil, err
	}

	var (
		lines   = strings.Split(output, "\n")
		devices = make([]*DeviceInfo, len(lines))
	)

	for i, line := range lines {
		var (
			attr = ""
			info = &DeviceInfo{}
		)

		_, err := fmt.Sscan(line,
			&info.Name,
			&info.BlockDeviceName,
			&attr,
			&info.Major,
			&info.Minor,
			&info.OpenCount,
			&info.TargetCount,
			&info.EventNumber)

		if err != nil {
			return nil, errors.Wrapf(err, "failed to parse line %q", line)
		}

		// Parse attributes (see "man 8 dmsetup" for details)
		info.Suspended = strings.Contains(attr, "s")
		info.ReadOnly = strings.Contains(attr, "r")
		info.TableLive = strings.Contains(attr, "L")
		info.TableInactive = strings.Contains(attr, "I")

		devices[i] = info
	}

	return devices, nil
}
1036909
func (st *State) ConnectionInfo() (result params.DeployerConnectionValues, err error) {
	err = st.facade.FacadeCall("ConnectionInfo", nil, &result)
	return result, err
}
384767
func (s *systemInfo) collectPlatformInfo() error {
	var err error
	if s.platform == "" {
		s.platform, s.family, s.osVersion, err = host.PlatformInformation()
		if err != nil {
			return err
		}
	}
	if s.cpuModel == "" {
		infos, err := cpu.Info()
		if err != nil || len(infos) == 0 {
			s.cpuModel = "unknown"
			// if err is nil, but we got no infos, we don't
			// have a meaningful error to return.
			return err
		}
		s.cpuModel = infos[0].ModelName
		s.cpuMHz = computeMHz(s.cpuModel)

		// gopsutil reports core and clock speed info inconsistently
		// by OS
		switch runtime.GOOS {
		case "linux":
			// Each reported "CPU" is a logical core. Some cores may
			// have the same Core ID, which is a strictly numeric
			// value which gopsutil returned as a string, which
			// indicates that they're hyperthreading or similar things
			// on the same physical core.
			uniqueCores := make(map[string]struct{}, len(infos))
			totalCores := 0
			for _, info := range infos {
				uniqueCores[info.CoreID] = struct{}{}
				totalCores += int(info.Cores)
			}
			s.cpuPhysicalCores = len(uniqueCores)
			s.cpuLogicalCores = totalCores
		case "darwin":
			fallthrough
		default: // let's hope other systems give useful core info?
			s.cpuPhysicalCores = int(infos[0].Cores)
			// we have no way to know, let's try runtime
			s.cpuLogicalCores = runtime.NumCPU()
		}
		return nil
	}
	return nil
}
895331
func (web *webAPIHandlers) ServerInfo(r *http.Request, args *WebGenericArgs, reply *ServerInfoRep) error {
	_, owner, authErr := webRequestAuthenticate(r)
	if authErr != nil {
		return toJSONError(authErr)
	}
	host, err := os.Hostname()
	if err != nil {
		host = ""
	}
	memstats := &runtime.MemStats{}
	runtime.ReadMemStats(memstats)
	mem := fmt.Sprintf("Used: %s | Allocated: %s | Used-Heap: %s | Allocated-Heap: %s",
		humanize.Bytes(memstats.Alloc),
		humanize.Bytes(memstats.TotalAlloc),
		humanize.Bytes(memstats.HeapAlloc),
		humanize.Bytes(memstats.HeapSys))
	platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s",
		host,
		runtime.GOOS,
		runtime.GOARCH)
	goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU()))

	reply.MinioVersion = Version
	reply.MinioGlobalInfo = getGlobalInfo()
	// If ENV creds are not set and incoming user is not owner
	// disable changing credentials.
	v, ok := reply.MinioGlobalInfo["isEnvCreds"].(bool)
	if ok && !v {
		reply.MinioGlobalInfo["isEnvCreds"] = !owner
	}
	// if etcd is set disallow changing credentials through UI
	if globalEtcdClient != nil {
		reply.MinioGlobalInfo["isEnvCreds"] = true
	}

	reply.MinioMemory = mem
	reply.MinioPlatform = platform
	reply.MinioRuntime = goruntime
	reply.UIVersion = browser.UIVersion
	return nil
}
153497
func (u *UniterAPI) NetworkInfo(args params.NetworkInfoParams) (params.NetworkInfoResults, error) {
	canAccess, err := u.accessUnit()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	unitTag, err := names.ParseUnitTag(args.Unit)
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	if !canAccess(unitTag) {
		return params.NetworkInfoResults{}, common.ErrPerm
	}

	unit, err := u.getUnit(unitTag)
	if err != nil {
		return params.NetworkInfoResults{}, err
	}

	result := params.NetworkInfoResults{
		Results: make(map[string]params.NetworkInfoResult),
	}

	spaces := set.NewStrings()
	bindingsToSpace := make(map[string]string)
	bindingsToEgressSubnets := make(map[string][]string)
	bindingsToIngressAddresses := make(map[string][]string)

	model, err := u.st.Model()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}
	modelCfg, err := model.ModelConfig()
	if err != nil {
		return params.NetworkInfoResults{}, err
	}
	for _, binding := range args.Bindings {
		if boundSpace, err := unit.GetSpaceForBinding(binding); err != nil {
			result.Results[binding] = params.NetworkInfoResult{Error: common.ServerError(err)}
		} else {
			spaces.Add(boundSpace)
			bindingsToSpace[binding] = boundSpace
		}
		bindingsToEgressSubnets[binding] = modelCfg.EgressSubnets()
	}

	if args.RelationId != nil {
		// We're in a relation context.
		rel, err := u.st.Relation(*args.RelationId)
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		endpoint, err := rel.Endpoint(unit.ApplicationName())
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		boundSpace, ingress, egress, err := state.NetworksForRelation(endpoint.Name, unit, rel, modelCfg.EgressSubnets())
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		spaces.Add(boundSpace)
		if len(egress) > 0 {
			bindingsToEgressSubnets[endpoint.Name] = egress
		}
		bindingsToIngressAddresses[endpoint.Name] = ingress
	}

	var (
		networkInfos            map[string]state.MachineNetworkInfoResult
		defaultIngressAddresses []string
	)

	if unit.ShouldBeAssigned() {
		machineID, err := unit.AssignedMachineId()
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		machine, err := u.st.Machine(machineID)
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		networkInfos = machine.GetNetworkInfoForSpaces(spaces)
	} else {
		// For CAAS units, we build up a minimal result struct
		// based on the default space and unit public/private addresses,
		// ie the addresses of the CAAS service.
		addr, err := unit.AllAddresses()
		if err != nil {
			return params.NetworkInfoResults{}, err
		}
		network.SortAddresses(addr)

		// We record the interface addresses as the machine local ones - these
		// are used later as the binding addresses.
		// For CAAS models, we need to default ingress addresses to all available
		// addresses so record those in the default ingress address slice.
		var interfaceAddr []network.InterfaceAddress
		for _, a := range addr {
			if a.Scope == network.ScopeMachineLocal {
				interfaceAddr = append(interfaceAddr, network.InterfaceAddress{Address: a.Value})
			}
			defaultIngressAddresses = append(defaultIngressAddresses, a.Value)
		}
		networkInfos = make(map[string]state.MachineNetworkInfoResult)
		networkInfos[environs.DefaultSpaceName] = state.MachineNetworkInfoResult{
			NetworkInfos: []network.NetworkInfo{{Addresses: interfaceAddr}},
		}
	}

	for binding, space := range bindingsToSpace {
		// The binding address information based on link layer devices.
		info := networkingcommon.MachineNetworkInfoResultToNetworkInfoResult(networkInfos[space])

		// Set egress and ingress address information.
		info.EgressSubnets = bindingsToEgressSubnets[binding]
		info.IngressAddresses = bindingsToIngressAddresses[binding]

		// If there is no ingress address explicitly defined for a given binding,
		// set the ingress addresses to either any defaults set above, or the binding addresses.
		if len(info.IngressAddresses) == 0 {
			for _, addr := range defaultIngressAddresses {
				info.IngressAddresses = append(info.IngressAddresses, addr)
			}
		}
		if len(info.IngressAddresses) == 0 {
			for _, nwInfo := range info.Info {
				for _, addr := range nwInfo.Addresses {
					info.IngressAddresses = append(info.IngressAddresses, addr.Address)
				}
			}
		}

		// If there is no egress subnet explicitly defined for a given binding,
		// default to the first ingress address. This matches the behaviour when
		// there's a relation in place.
		if len(info.EgressSubnets) == 0 && len(info.IngressAddresses) > 0 {
			info.EgressSubnets, err = network.FormatAsCIDR([]string{info.IngressAddresses[0]})
			if err != nil {
				return result, errors.Trace(err)
			}
		}

		result.Results[binding] = info
	}

	return result, nil
}