Return dictionary of Traffic Stats for Network Interfaces.
        
        @return: Nested dictionary of statistics for each interface.
971437
def getIfStats(self):
        
        info_dict = {}
        try:
            fp = open(ifaceStatsFile, 'r')
            data = fp.read()
            fp.close()
        except:
            raise IOError('Failed reading interface stats from file: %s'
                          % ifaceStatsFile)
        for line in data.splitlines():
            mobj = re.match('^\s*([\w\d:]+):\s*(.*\S)\s*$', line)
            if mobj:
                iface = mobj.group(1)
                statline = mobj.group(2)
                info_dict[iface] = dict(zip(
                    ('rxbytes', 'rxpackets', 'rxerrs', 'rxdrop', 'rxfifo',
                     'rxframe', 'rxcompressed', 'rxmulticast',
                     'txbytes', 'txpackets', 'txerrs', 'txdrop', 'txfifo',
                     'txcolls', 'txcarrier', 'txcompressed'),
                    [int(x) for x in statline.split()]))
                    
        return info_dict
321582
def stats(self):
        
        response = self.requester.get(
            '/{endpoint}/{id}/stats',
            endpoint=self.endpoint, id=self.id
        )
        return response.json()
477411
def network_info():
    

    def extract(host, family):
        return socket.getaddrinfo(host, None, family)[0][4][0]
    host = socket.gethostname()
    response = {
        'hostname': host,
        'ipv4': None,
        'ipv6': None
    }
    with suppress(IndexError, socket.gaierror):
        response['ipv4'] = extract(host, socket.AF_INET)
    with suppress(IndexError, socket.gaierror):
        response['ipv6'] = extract(host, socket.AF_INET6)
    return response
967
def getStats(self):
        
        stats = protocol.ReadStats()
        stats.aligned_read_count = self.getNumAlignedReads()
        stats.unaligned_read_count = self.getNumUnalignedReads()
        # TODO base_count requires iterating through all reads
        return stats
530473
def stats(self):
        
        # TODO - this would be nicer if we formatted the stats
        return self._client.get('{}/stats'.format(Instance.api_endpoint), model=self)
1141047
def to_dict(self):
        
        return {
            'hostname': self.hostname,
            'port': self.port,
            'transport': self.transport,
            'virtual_host': self.virtual_host
        }
475309
def stats(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.stats(index=self._name, **kwargs)
85933
def get_ethernet_networks(self):
        
        network_uris = self.data.get('networkUris')
        networks = []
        if network_uris:
            for uri in network_uris:
                networks.append(self._ethernet_networks.get_by_uri(uri))
        return networks
273965
def get_network_params(self):
        
        ip = self.__address[0]
        mask = b''
        gate = b''
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'IPAddress\x00', 1024)
        if cmd_response.get('status'):
            ip = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'NetMask\x00', 1024)
        if cmd_response.get('status'):
            mask = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        cmd_response = self.__send_command(const.CMD_OPTIONS_RRQ, b'GATEIPAddress\x00', 1024)
        if cmd_response.get('status'):
            gate = (self.__data.split(b'=', 1)[-1].split(b'\x00')[0])
        return {'ip': ip.decode(), 'mask': mask.decode(), 'gateway': gate.decode()}
1052399
def report(self):
        
        return {
            'connections': {
                'busy': len(self.busy_connections),
                'closed': len(self.closed_connections),
                'executing': len(self.executing_connections),
                'idle': len(self.idle_connections),
                'locked': len(self.busy_connections)
            },
            'exceptions': sum([c.exceptions
                               for c in self.connections.values()]),
            'executions': sum([c.executions
                               for c in self.connections.values()]),
            'full': self.is_full,
            'idle': {
                'duration': self.idle_duration,
                'ttl': self.idle_ttl
            },
            'max_size': self.max_size
        }
216528
def _get_plugin_stats(self, name):
        '''
        
        '''
        the_dict = {}

        keys = self.redis_conn.keys('stats:{n}:*'.format(n=name))

        for key in keys:
            # break down key
            elements = key.split(":")
            main = elements[2]
            end = elements[3]

            if main == 'total' or main == 'fail':
                if main not in the_dict:
                    the_dict[main] = {}
                the_dict[main][end] = self._get_key_value(key, end == 'lifetime')
            elif main == 'self':
                if 'nodes' not in the_dict:
                    # main is self, end is machine, true_tail is uuid
                    the_dict['nodes'] = {}
                true_tail = elements[4]
                if end not in the_dict['nodes']:
                    the_dict['nodes'][end] = []
                the_dict['nodes'][end].append(true_tail)
            else:
                if 'plugins' not in the_dict:
                    the_dict['plugins'] = {}
                if main not in the_dict['plugins']:
                    the_dict['plugins'][main] = {}
                the_dict['plugins'][main][end] = self._get_key_value(key, end == 'lifetime')

        return the_dict
969748
def get_stats(self, nid=None):
        
        r = self.request(
            api_type="main",
            method="network.get_stats",
            nid=nid,
        )
        return self._handle_error(r, "Could not retrieve stats for class.")
1305662
def getStats(self):
        
        url = "%s://%s:%d/%s" % (self._proto, self._host, self._port, 
                                 self._monpath)
        response = util.get_url(url, self._user, self._password)
        stats = {}
        for line in response.splitlines():
            mobj = re.match('([\w\s]+):\s+(\w+)$', line)
            if mobj:
                stats[mobj.group(1)] = util.parse_value(mobj.group(2))
        return stats
1062846
def getProcessStats(self):
        
        info_dict = {}
        try:
            fp = open(cpustatFile, 'r')
            data = fp.read()
            fp.close()
        except:
            raise IOError('Failed reading stats from file: %s' % cpustatFile)
        for line in data.splitlines():
            arr = line.split()
            if len(arr) > 1 and arr[0] in ('ctxt', 'intr', 'softirq',
                                           'processes', 'procs_running', 
                                           'procs_blocked'):
                info_dict[arr[0]] = arr[1]
        return info_dict
897095
def ip_interfaces():
    '''
    
    '''
    # Provides:
    #   ip_interfaces

    if salt.utils.platform.is_proxy():
        return {}

    ret = {}
    ifaces = _get_interfaces()
    for face in ifaces:
        iface_ips = []
        for inet in ifaces[face].get('inet', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for inet in ifaces[face].get('inet6', []):
            if 'address' in inet:
                iface_ips.append(inet['address'])
        for secondary in ifaces[face].get('secondary', []):
            if 'address' in secondary:
                iface_ips.append(secondary['address'])
        ret[face] = iface_ips
    return {'ip_interfaces': ret}
448959
def interfaces_info():
    
    def replace(value):
        if value == netifaces.AF_LINK:
            return 'link'
        if value == netifaces.AF_INET:
            return 'ipv4'
        if value == netifaces.AF_INET6:
            return 'ipv6'
        return value

    results = {}
    for iface in netifaces.interfaces():
        addrs = netifaces.ifaddresses(iface)
        results[iface] = {replace(k): v for k, v in addrs.items()}

    return results
662141
def get_interfaces_ip(self):
        """"""
        interfaces_ip = {}

        interface_table = junos_views.junos_ip_interfaces_table(self.device)
        interface_table.get()
        interface_table_items = interface_table.items()

        _FAMILY_VMAP_ = {
            "inet": "ipv4",
            "inet6": "ipv6"
            # can add more mappings
        }
        _FAMILY_MAX_PREFIXLEN = {"inet": 32, "inet6": 128}

        for interface_details in interface_table_items:
            ip_network = interface_details[0]
            ip_address = ip_network.split("/")[0]
            address = napalm.base.helpers.convert(
                napalm.base.helpers.ip, ip_address, ip_address
            )
            try:
                interface_details_dict = dict(interface_details[1])
                family_raw = interface_details_dict.get("family")
                interface = py23_compat.text_type(
                    interface_details_dict.get("interface")
                )
            except ValueError:
                continue
            prefix = napalm.base.helpers.convert(
                int, ip_network.split("/")[-1], _FAMILY_MAX_PREFIXLEN.get(family_raw)
            )
            family = _FAMILY_VMAP_.get(family_raw)
            if not family or not interface:
                continue
            if interface not in interfaces_ip.keys():
                interfaces_ip[interface] = {}
            if family not in interfaces_ip[interface].keys():
                interfaces_ip[interface][family] = {}
            if address not in interfaces_ip[interface][family].keys():
                interfaces_ip[interface][family][address] = {}
            interfaces_ip[interface][family][address]["prefix_length"] = prefix

        return interfaces_ip