Exemplo n.º 1
0
 def collect_ntp_date(self, priority=1):
     if ntp_server is not None:
         ts = str(int(time.time()))
         if priority == CONS_COLLECT_FOR["CONTINUOUS"] or priority == CONS_COLLECT_FOR["BOOTH"]:
             try:
                 self.write_key("os.time_ntp_server", get_unixtime_ntp_server(), ts)
                 self.write_key("os.time_ntp_server_unixtime", convert_now2unixtime(get_unixtime_ntp_server()), ts)
             except:
                 pass
Exemplo n.º 2
0
    def collect_time(self, priority=1):
        ts = str(int(time.time()))
        if bool(self.mysqldb.get_mysql_ping()):
            status = self.mysqldb.get_now()
            if priority == CONS_COLLECT_FOR["CONTINUOUS"] or priority == CONS_COLLECT_FOR["BOOTH"]:
                try:
                    self.write_key("db.mysql.time_now", fix_time_now(status.now), ts)
                    self.write_key("db.mysql.timezone", status.timezone, ts)
                    self.write_key("db.mysql.time_unixtime", convert_now2unixtime(status.now), ts)
                    mysql_time = int(convert_now2unixtime(status.now))
                except:
                    mysql_time = 0
                try:
                    if mysql_time is not None and mysql_time > 0:
                        ntp_time = get_unixtime_ntp_server(ntp_server)
                        time_error = ntp_time - (mysql_time + 3)

                        if time_error > int(ntp_grace_time * -1) and time_error < int(
                                        ntp_grace_time * 1): # Time grace - Delay between get now() and get ntp date
                            time_error = 0
                        if time_error is not None:
                            self.write_key("db.mysql.time_unixtime_ntp_time", time_error, ts)
                except:
                    pass