// GetInterfaceStats retrieves VPP per interface stats.
335776
func (c *StatsConnection) GetInterfaceStats() (*api.InterfaceStats, error) {
	stats, err := c.statsClient.DumpStats(InterfaceStatsPrefix)
	if err != nil {
		return nil, err
	}

	ifStats := &api.InterfaceStats{}

	var setPerIf = func(perIf []uint64, fn func(c *api.InterfaceCounters, v uint64)) {
		if ifStats.Interfaces == nil {
			ifStats.Interfaces = make([]api.InterfaceCounters, len(perIf))
			for i := range perIf {
				ifStats.Interfaces[i].InterfaceIndex = uint32(i)
			}
		}
		for i, v := range perIf {
			if len(ifStats.Interfaces) <= i {
				break
			}
			ifCounters := ifStats.Interfaces[i]
			fn(&ifCounters, v)
			ifStats.Interfaces[i] = ifCounters
		}
	}

	for _, stat := range stats {
		switch stat.Name {
		case InterfaceStats_Names:
			if names, ok := stat.Data.(adapter.NameStat); !ok {
				return nil, fmt.Errorf("invalid stat type for %s", stat.Name)
			} else {
				if ifStats.Interfaces == nil {
					ifStats.Interfaces = make([]api.InterfaceCounters, len(names))
					for i := range names {
						ifStats.Interfaces[i].InterfaceIndex = uint32(i)
					}
				}
				for i, name := range names {
					ifStats.Interfaces[i].InterfaceName = string(name)
				}
			}
		case InterfaceStats_Drops:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.Drops = v
			})
		case InterfaceStats_Punt:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.Punts = v
			})
		case InterfaceStats_IP4:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.IP4 = v
			})
		case InterfaceStats_IP6:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.IP6 = v
			})
		case InterfaceStats_RxNoBuf:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxNoBuf = v
			})
		case InterfaceStats_RxMiss:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxMiss = v
			})
		case InterfaceStats_RxError:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxErrors = v
			})
		case InterfaceStats_TxError:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.TxErrors = v
			})
		case InterfaceStats_Rx:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxPackets = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxBytes = v
			})
		case InterfaceStats_RxUnicast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxUnicast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxUnicast[1] = v
			})
		case InterfaceStats_RxMulticast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxMulticast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxMulticast[1] = v
			})
		case InterfaceStats_RxBroadcast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxBroadcast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxBroadcast[1] = v
			})
		case InterfaceStats_Tx:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxPackets = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxBytes = v
			})
		case InterfaceStats_TxUnicastMiss:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxUnicastMiss[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxUnicastMiss[1] = v
			})
		case InterfaceStats_TxMulticast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxMulticast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxMulticast[1] = v
			})
		case InterfaceStats_TxBroadcast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxBroadcast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxBroadcast[1] = v
			})
		}
	}

	return ifStats, nil
}
544566
func GetInterfaceIP(linkName string) (string, error) {
	var addrs []netlink.Addr
	localIPAddr := ""

	link, err := netlink.LinkByName(linkName)
	if err != nil {
		return "", err
	}
	addrs, err = netlink.AddrList(link, netlink.FAMILY_V4)
	if err != nil {
		return "", err
	}
	if len(addrs) > 0 {
		localIPAddr = addrs[0].IP.String()
	}

	err = core.Errorf("local ip not found")
	if localIPAddr != "" {
		err = nil
	}

	return localIPAddr, err
}
307077
func GetStats() (stats Stats, err error) {
	var memInfo memoryStatusEx
	memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
	if mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo))); mem == 0 {
		err = syscall.GetLastError()
	} else {
		stats.TotalRAM = memInfo.ullTotalPhys
	}

	return stats, err
}
683479
func (o *Domain) ContainerInterfaces(info *bambou.FetchingInfo) (ContainerInterfacesList, *bambou.Error) {

	var list ContainerInterfacesList
	err := bambou.CurrentSession().FetchChildren(o, ContainerInterfaceIdentity, &list, info)
	return list, err
}
731340
func InterfaceStats() (map[string]InterfaceStat, error) {
	ret := make(map[string]InterfaceStat, 0)
	var current InterfaceStat
	lastline := -1
	lastindex := -1

	lf := func(index int, line string) error {
		if lastline == index && lastindex == 16 {
			ret[current.Device] = current
		}
		current = InterfaceStat{}
		return nil
	}
	el := func(line int, index int, elm string) (err error) {
		switch index {
		case 0:
			current.Device = strings.Split(elm, ":")[0]
		case 1:
			current.RxBytes, err = strconv.ParseUint(elm, 10, 64)
		case 2:
			current.RxPackets, err = strconv.ParseUint(elm, 10, 64)
		case 3:
			current.RxErrors, err = strconv.ParseUint(elm, 10, 64)
		case 4:
			current.RxDrop, err = strconv.ParseUint(elm, 10, 64)
		case 5:
			current.RxFifo, err = strconv.ParseUint(elm, 10, 64)
		case 6:
			current.RxFrame, err = strconv.ParseUint(elm, 10, 64)
		case 7:
			current.RxCompressed, err = strconv.ParseUint(elm, 10, 64)
		case 8:
			current.RxMulticast, err = strconv.ParseUint(elm, 10, 64)
		case 9:
			current.TxBytes, err = strconv.ParseUint(elm, 10, 64)
		case 10:
			current.TxPackets, err = strconv.ParseUint(elm, 10, 64)
		case 11:
			current.TxErrors, err = strconv.ParseUint(elm, 10, 64)
		case 12:
			current.TxDrop, err = strconv.ParseUint(elm, 10, 64)
		case 13:
			current.TxFifo, err = strconv.ParseUint(elm, 10, 64)
		case 14:
			current.TxFrame, err = strconv.ParseUint(elm, 10, 64)
		case 15:
			current.TxCompressed, err = strconv.ParseUint(elm, 10, 64)
		case 16:
			current.TxMulticast, err = strconv.ParseUint(elm, 10, 64)
		}
		lastline = line
		lastindex = index
		return
	}

	// Now actually attempt to parse the config
	if err := ParseSimpleProcFile(DeviceStatsFile, lf, el); err != nil {
		return nil, err
	}

	return ret, nil
}
1230266
func sortInterfaceSlice(in []interface{}) []interface{} {
	a := []string{}
	b := []interface{}{}
	for _, v := range in {
		a = append(a, v.(string))
	}

	sort.Strings(a)

	for _, v := range a {
		b = append(b, v)
	}

	return b
}
598333
func (c *StatsConnection) GetSystemStats() (*api.SystemStats, error) {
	stats, err := c.statsClient.DumpStats(SystemStatsPrefix)
	if err != nil {
		return nil, err
	}

	sysStats := &api.SystemStats{}

	for _, stat := range stats {
		switch stat.Name {
		case SystemStats_VectorRate:
			sysStats.VectorRate = scalarStatToFloat64(stat.Data)
		case SystemStats_InputRate:
			sysStats.InputRate = scalarStatToFloat64(stat.Data)
		case SystemStats_LastUpdate:
			sysStats.LastUpdate = scalarStatToFloat64(stat.Data)
		case SystemStats_LastStatsClear:
			sysStats.LastStatsClear = scalarStatToFloat64(stat.Data)
		case SystemStats_Heartbeat:
			sysStats.Heartbeat = scalarStatToFloat64(stat.Data)
		}
	}

	return sysStats, nil
}
338745
func (_m *ClientInterface) GetHosts() ([]host.Host, error) {
	ret := _m.Called()

	var r0 []host.Host
	if rf, ok := ret.Get(0).(func() []host.Host); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]host.Host)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1100262
func (r Network_Message_Delivery_Email_Sendgrid) GetStatistics(options *datatypes.Container_Network_Message_Delivery_Email_Sendgrid_Statistics_Options) (resp []datatypes.Container_Network_Message_Delivery_Email_Sendgrid_Statistics, err error) {
	params := []interface{}{
		options,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Message_Delivery_Email_Sendgrid", "getStatistics", params, &r.Options, &resp)
	return
}
249927
func (daemon *Daemon) GetContainerStats(container *container.Container) (*types.StatsJSON, error) {
	stats, err := daemon.stats(container)
	if err != nil {
		return nil, err
	}

	// We already have the network stats on Windows directly from HCS.
	if !container.Config.NetworkDisabled && runtime.GOOS != "windows" {
		if stats.Networks, err = daemon.getNetworkStats(container); err != nil {
			return nil, err
		}
	}

	return stats, nil
}
1187037
func netInterfaces() ([]net.Interface, error) {
	validIfaces := []net.Interface{}
	ifaces, err := net.Interfaces()
	if err != nil {
		return nil, err
	}

	for _, iface := range ifaces {
		if !vethRegex.MatchString(iface.Name) && stringSlice(invalidIfaces).pos(iface.Name) == -1 {
			validIfaces = append(validIfaces, iface)
		}
	}

	return validIfaces, nil
}
1150777
func (v *VPCRouter) HasInterfaces() bool {
	return v.HasSetting() && v.Settings.Router.HasInterfaces()
}
393711
func (p pointer) getInterfacePointer() pointer {
	// Super-tricky - read pointer out of data word of interface value.
	return pointer{p: (*(*[2]unsafe.Pointer)(p.p))[1]}
}
30449
func (daemon *Daemon) getNetworkStats(c *container.Container) (map[string]types.NetworkStats, error) {
	return make(map[string]types.NetworkStats), nil
}
1259757
func (ri routeInfo) GetDefaultInterfaceName() (string, error) {
	out, err := exec.Command(ri.cmds["ip"][0], ri.cmds["ip"][1:]...).Output()
	if err != nil {
		return "", err
	}

	var ifName string
	if ifName, err = parseDefaultIfNameFromIPCmd(string(out)); err != nil {
		return "", errors.New("No default interface found")
	}
	return ifName, nil
}
132949
func (f *SockaddrFuncs) GetInterfaceIP(namedIfRE string) (string, error) {
	return sockaddr.GetInterfaceIP(namedIfRE)
}
901438
func GetInterfaces() map[string]struct{} {
	ipmap := map[string]struct{}{}

	ifaces, _ := net.Interfaces()
	for _, intf := range ifaces {
		addrs, _ := intf.Addrs()
		for _, addr := range addrs {
			ip, _, _ := net.ParseCIDR(addr.String())
			if ip.To4() != nil {
				ipmap[ip.String()] = struct{}{}
			}
		}
	}
	return ipmap
}