示例#1
0
    def run(self):
        """
    Starts the data collection, calls collect_metrics() for data and then inserts into InfluxDB and
    monitors it for abnormalities using the provided Watchdog
    """
        LOG.info('Collecting %s...', self)
        try:
            while not self._exit_flag_event.is_set():

                # call the derived methor for data, or a NotImplementedError is raised
                json_body = self.collect_metrics()

                # write metrics to InfluxDB
                self._influxdb_client.write_points(json_body)

                # monitor the data for any abnormalities in the AMD GPUs
                self._watchdog.monitor(json_body)

                time.sleep(_EPOCH_SLEEP_SECONDS)

            LOG.info('Exiting %s data collection...', self)

        except Exception as e:
            LOG.exception(
                'Suffered a critical error! Switching off miner for {} seconds\n{}'
                .format(_WAKEUP_SLEEP_SECONDS, e))
            self._watchdog.switch_off_miner(_WAKEUP_SLEEP_SECONDS)