Пример #1
0
 def send_stats(self):
     """Collect and send statistics"""
     try:
         stat_dict = return_stat_file_dict(STATS_CSV)
         if float(stat_dict['next_send']) < time.time():
             self.timer_stats = self.timer_stats + STATS_INTERVAL
             add_update_csv(STATS_CSV, 'next_send', self.timer_stats)
         else:
             self.timer_stats = float(stat_dict['next_send'])
     except Exception as msg:
         self.timer_stats = self.timer_stats + STATS_INTERVAL
         self.logger.exception(
             "Error: Could not read stats file. Regenerating. Message: "
             "{msg}".format(msg=msg))
         try:
             os.remove(STATS_CSV)
         except OSError:
             pass
         recreate_stat_file()
     try:
         send_anonymous_stats(self.start_time)
     except Exception as except_msg:
         self.logger.exception(
             "Error: Could not send statistics: {err}".format(
                 err=except_msg))
Пример #2
0
 def startup_stats(self):
     """Ensure existence of statistics file and save daemon startup time"""
     try:
         # if statistics file doesn't exist, create it
         if not os.path.isfile(STATS_CSV):
             self.logger.debug(
                 "Statistics file doesn't exist, creating {file}".format(
                     file=STATS_CSV))
             recreate_stat_file()
         add_update_csv(STATS_CSV, 'daemon_startup_seconds',
                        self.daemon_startup_time)
     except Exception as msg:
         self.logger.exception(
             "Statistics initialization Error: {err}".format(err=msg))
Пример #3
0
 def startup_stats(self):
     """Ensure existence of statistics file and save daemon startup time"""
     try:
         # if statistics file doesn't exist, create it
         if not os.path.isfile(STATS_CSV):
             self.logger.debug(
                 "Statistics file doesn't exist, creating {file}".format(
                     file=STATS_CSV))
             recreate_stat_file()
         add_update_csv(STATS_CSV, 'daemon_startup_seconds',
                        self.daemon_startup_time)
     except Exception as msg:
         self.logger.exception(
             "Statistics initialization Error: {err}".format(err=msg))