yandextank/plugins/Telegraf/collector.py
def poll(self):
        """ Poll agents for data
        """
        start_time = time.time()
        for agent in self.agents:
            for collect in agent.reader:
                # don't crush if trash or traceback came from agent to stdout
                if not collect:
                    return 0
                for chunk in collect:
                    ts, prepared_results = chunk
                    if self.load_start_time and int(
                            ts) >= self.load_start_time:
                        ready_to_send = {
                            "timestamp": int(ts),
                            "data": {
                                self.hash_hostname(agent.host): {
                                    "comment": agent.config.comment,
                                    "metrics": prepared_results
                                }
                            }
                        }
                        self.__collected_data.append(ready_to_send)

        logger.debug(
            'Polling/decoding agents data took: %.2fms',
            (time.time() - start_time) * 1000)

        collected_data_length = len(self.__collected_data)

        if not self.first_data_received and self.__collected_data:
            self.first_data_received = True
            logger.info("Monitoring received first data.")
        else:
            self.send_collected_data()
        return collected_data_length
def poll(self):
        """ Poll agents for data
        """
        start_time = time.time()
        for agent in self.agents:
            for collect in agent.reader:
                # don't crush if trash or traceback came from agent to stdout
                if not collect:
                    return 0
                for chunk in collect:
                    ts, prepared_results = chunk
                    if self.load_start_time and int(
                            ts) >= self.load_start_time:
                        ready_to_send = {
                            "timestamp": int(ts),
                            "data": {
                                self.hash_hostname(agent.host): {
                                    "comment": agent.config.comment,
                                    "metrics": prepared_results
                                }
                            }
                        }
                        self.__collected_data.append(ready_to_send)

        logger.debug(
            'Polling/decoding agents data took: %.2fms',
            (time.time() - start_time) * 1000)

        collected_data_length = len(self.__collected_data)

        if not self.first_data_received and self.__collected_data:
            self.first_data_received = True
            logger.info("Monitoring received first data.")
        else:
            self.send_collected_data()
        return collected_data_length
Poll agents for data