(self, iface, sckt)
return metrics
Get all ENA metrics specified in ENA_METRICS_NAMES list and their values from ethtool.
Get all ENA metrics specified in ENA_METRICS_NAMES list and their values from ethtool.
Get all ENA metrics specified in ENA_METRICS_NAMES list and their values from ethtool .
def _get_ena_metrics(self, iface, sckt):
        """
        Get all ENA metrics specified in ENA_METRICS_NAMES list and their values from ethtool.
        """
        stats_names = list(self._get_ethtool_gstringset(iface, sckt))
        stats_count = len(stats_names)

        stats = array.array('B', struct.pack('II', ETHTOOL_GSTATS, stats_count))
        # we need `stats_count * (length of uint64)` for the result
        stats.extend([0] * len(struct.pack('Q', 0)) * stats_count)
        self._send_ethtool_ioctl(iface, sckt, stats)

        metrics = {}
        for i, stat_name in enumerate(stats_names):
            if stat_name in ENA_METRIC_NAMES:
                offset = 8 + 8 * i
                value = struct.unpack('Q', stats[offset : offset + 8])[0]
                metrics[ENA_METRIC_PREFIX + stat_name] = value

        return metrics
def _get_ena_metrics ( self , iface , sckt ) : stats_names = list ( self . _get_ethtool_gstringset ( iface , sckt ) ) stats_count = len ( stats_names ) stats = array . array ( 'B' , struct . pack ( 'II' , ETHTOOL_GSTATS , stats_count ) ) # we need `stats_count * (length of uint64)` for the result stats . extend ( [ 0 ] * len ( struct . pack ( 'Q' , 0 ) ) * stats_count ) self . _send_ethtool_ioctl ( iface , sckt , stats ) metrics = { } for i , stat_name in enumerate ( stats_names ) : if stat_name in ENA_METRIC_NAMES : offset = 8 + 8 * i value = struct . unpack ( 'Q' , stats [ offset : offset + 8 ] ) [ 0 ] metrics [ ENA_METRIC_PREFIX + stat_name ] = value return metrics