(
        self,
        name,  # type: str
        index,  # type: Tuple[str, ...]
        results,  # type: Dict[str, Dict[Tuple[str, ...], Any]]
        tags,  # type: List[str]
    )
Evaluate and report input/output bandwidth usage. If any of `ifHCInOctets`, `ifHCOutOctets`  or `ifHighSpeed`
        is missing then bandwidth will not be reported.

        Bandwidth usage is:

        interface[In|Out]Octets(t+dt) - interface[In|Out]Octets(t)
        ----------------------------------------------------------
                        dt*interfaceSpeed

        Given:
        * ifHCInOctets: the total number of octets received on the interface.
        * ifHCOutOctets: The total number of octets transmitted out of the interface.
        * ifHighSpeed: An estimate of the interface's current bandwidth in Mb/s (10^6 bits
                       per second). It is constant in time, can be overwritten by the system admin.
                       It is the total available bandwidth.
        Bandwidth usage is evaluated as: ifHC[In|Out]Octets/ifHighSpeed and reported as *rate*
Evaluate and report input/output bandwidth usage. If any of `ifHCInOctets`, `ifHCOutOctets`  or `ifHighSpeed`
        is missing then bandwidth will not be reported.
Evaluate and report input / output bandwidth usage . If any of ifHCInOctets ifHCOutOctets or ifHighSpeed is missing then bandwidth will not be reported .
def submit_bandwidth_usage_metric_if_bandwidth_metric(
        self,
        name,  # type: str
        index,  # type: Tuple[str, ...]
        results,  # type: Dict[str, Dict[Tuple[str, ...], Any]]
        tags,  # type: List[str]
    ):
        # type: (...) -> None
        """
        Evaluate and report input/output bandwidth usage. If any of `ifHCInOctets`, `ifHCOutOctets`  or `ifHighSpeed`
        is missing then bandwidth will not be reported.

        Bandwidth usage is:

        interface[In|Out]Octets(t+dt) - interface[In|Out]Octets(t)
        ----------------------------------------------------------
                        dt*interfaceSpeed

        Given:
        * ifHCInOctets: the total number of octets received on the interface.
        * ifHCOutOctets: The total number of octets transmitted out of the interface.
        * ifHighSpeed: An estimate of the interface's current bandwidth in Mb/s (10^6 bits
                       per second). It is constant in time, can be overwritten by the system admin.
                       It is the total available bandwidth.
        Bandwidth usage is evaluated as: ifHC[In|Out]Octets/ifHighSpeed and reported as *rate*
        """
        if not self.is_bandwidth_metric(name):
            return

        if 'ifHighSpeed' not in results:
            self.log.debug('[SNMP Bandwidth usage] missing `ifHighSpeed` metric, skipping metric %s', name)
            return

        if name not in results:
            self.log.debug('[SNMP Bandwidth usage] missing `%s` metric, skipping this row. index=%s', name, index)
            return

        octets_value = results[name][index]
        try:
            if_high_speed_val = results['ifHighSpeed'][index]
        except KeyError:
            self.log.debug('[SNMP Bandwidth usage] missing `ifHighSpeed` metric, skipping this row. ' 'index=%s', index)
            return

        if_high_speed = try_varbind_value_to_float(if_high_speed_val)
        if if_high_speed is None:
            err_msg = 'Metric: {} has non float value: {}. Only float values can be submitted as metrics.'.format(
                repr(name), repr(if_high_speed_val)
            )
            self.log.debug(err_msg, exc_info=True)
            return

        bits_value = try_varbind_value_to_float(octets_value) * 8
        if bits_value is None:
            err_msg = 'Metric: {} has non float value: {}. Only float values can be submitted as metrics.'.format(
                repr(name), repr(octets_value)
            )
            self.log.debug(err_msg, exc_info=True)
            return

        try:
            bandwidth_usage_value = (bits_value / (if_high_speed * (10 ** 6))) * 100
        except ZeroDivisionError:
            self.log.debug('Zero value at ifHighSpeed, skipping this row. index=%s', index)
            return

        self.rate(
            "snmp.{}.rate".format(SnmpCheck.BANDWIDTH_METRIC_NAME_TO_BANDWIDTH_USAGE_METRIC_NAME_MAPPING[name]),
            bandwidth_usage_value,
            tags,
        )
        self._submitted_metrics += 1
def submit_bandwidth_usage_metric_if_bandwidth_metric ( self , name , # type: str index , # type: Tuple[str, ...] results , # type: Dict[str, Dict[Tuple[str, ...], Any]] tags , # type: List[str] ) : # type: (...) -> None if not self . is_bandwidth_metric ( name ) : return if 'ifHighSpeed' not in results : self . log . debug ( '[SNMP Bandwidth usage] missing `ifHighSpeed` metric, skipping metric %s' , name ) return if name not in results : self . log . debug ( '[SNMP Bandwidth usage] missing `%s` metric, skipping this row. index=%s' , name , index ) return octets_value = results [ name ] [ index ] try : if_high_speed_val = results [ 'ifHighSpeed' ] [ index ] except KeyError : self . log . debug ( '[SNMP Bandwidth usage] missing `ifHighSpeed` metric, skipping this row. ' 'index=%s' , index ) return if_high_speed = try_varbind_value_to_float ( if_high_speed_val ) if if_high_speed is None : err_msg = 'Metric: {} has non float value: {}. Only float values can be submitted as metrics.' . format ( repr ( name ) , repr ( if_high_speed_val ) ) self . log . debug ( err_msg , exc_info = True ) return bits_value = try_varbind_value_to_float ( octets_value ) * 8 if bits_value is None : err_msg = 'Metric: {} has non float value: {}. Only float values can be submitted as metrics.' . format ( repr ( name ) , repr ( octets_value ) ) self . log . debug ( err_msg , exc_info = True ) return try : bandwidth_usage_value = ( bits_value / ( if_high_speed * ( 10 ** 6 ) ) ) * 100 except ZeroDivisionError : self . log . debug ( 'Zero value at ifHighSpeed, skipping this row. index=%s' , index ) return self . rate ( "snmp.{}.rate" . format ( SnmpCheck . BANDWIDTH_METRIC_NAME_TO_BANDWIDTH_USAGE_METRIC_NAME_MAPPING [ name ] ) , bandwidth_usage_value , tags , ) self . _submitted_metrics += 1