'Checks if the last transmission of client stats is too long ago.'

def CheckStats(self):

    if (self.last_stats_sent_time is None):
        self.last_stats_sent_time = rdfvalue.RDFDatetime.Now()
        stats.STATS.SetGaugeValue('grr_client_last_stats_sent_time', self.last_stats_sent_time.AsSecondsFromEpoch())
    time_since_last_check = (rdfvalue.RDFDatetime.Now() - self.last_stats_sent_time)
    if (time_since_last_check < self.STATS_MIN_SEND_INTERVAL):
        return
    if ((time_since_last_check > self.STATS_MAX_SEND_INTERVAL) or self._is_active or self._send_stats_on_check):
        self._send_stats_on_check = False
        logging.info('Sending    back    client    statistics    to    the    server.')
        action_cls = actions.ActionPlugin.classes.get('GetClientStatsAuto', actions.ActionPlugin)
        action = action_cls(grr_worker=self)
        action.Run(rdf_client.GetClientStatsRequest(start_time=self.last_stats_sent_time))
        self.last_stats_sent_time = rdfvalue.RDFDatetime.Now()
        stats.STATS.SetGaugeValue('grr_client_last_stats_sent_time', self.last_stats_sent_time.AsSecondsFromEpoch())
