|
@@ -5,6 +5,7 @@ import h5py
|
|
from os import path
|
|
from os import path
|
|
import re
|
|
import re
|
|
from datetime import timedelta
|
|
from datetime import timedelta
|
|
|
|
+from datetime import datetime
|
|
import numpy as np
|
|
import numpy as np
|
|
from matplotlib.figure import Figure
|
|
from matplotlib.figure import Figure
|
|
from matplotlib import ticker
|
|
from matplotlib import ticker
|
|
@@ -12,7 +13,7 @@ from io import BytesIO
|
|
import logging
|
|
import logging
|
|
|
|
|
|
class MchDataCenter(object):
|
|
class MchDataCenter(object):
|
|
- latest_delta = 2
|
|
|
|
|
|
+ latest_delta = 10
|
|
pos_map = {
|
|
pos_map = {
|
|
'commit': 0, 'success': 1, 'fail': 2
|
|
'commit': 0, 'success': 1, 'fail': 2
|
|
}
|
|
}
|
|
@@ -43,6 +44,10 @@ class MchDataCenter(object):
|
|
hfive = h5py.File(self._file_name, 'w')
|
|
hfive = h5py.File(self._file_name, 'w')
|
|
|
|
|
|
latest_time = int(stime.time()) - self.latest_delta
|
|
latest_time = int(stime.time()) - self.latest_delta
|
|
|
|
+ lt = stime.localtime(latest_time)
|
|
|
|
+ now_str = stime.strftime('%Y-%m-%d %H:%M:%S', lt)
|
|
|
|
+
|
|
|
|
+ print('start read',now_str)
|
|
self.read_redis(hfive, r, 'nc_user_monitor_commit', 'commit')
|
|
self.read_redis(hfive, r, 'nc_user_monitor_commit', 'commit')
|
|
self.read_redis(hfive, r, 'nc_user_monitor_success', 'success')
|
|
self.read_redis(hfive, r, 'nc_user_monitor_success', 'success')
|
|
self.read_redis(hfive, r, 'nc_user_monitor_fail', 'fail')
|
|
self.read_redis(hfive, r, 'nc_user_monitor_fail', 'fail')
|
|
@@ -54,9 +59,9 @@ class MchDataCenter(object):
|
|
except Exception as ex:
|
|
except Exception as ex:
|
|
print(ex)
|
|
print(ex)
|
|
finally:
|
|
finally:
|
|
- stime.sleep(0.1)
|
|
|
|
|
|
+ stime.sleep(1)
|
|
|
|
|
|
- def del_redis(self, redis, name,latest_time):
|
|
|
|
|
|
+ def del_redis(self, redis, name, latest_time):
|
|
for item in redis.hscan_iter(name):
|
|
for item in redis.hscan_iter(name):
|
|
key = str(item[0], encoding="utf-8")
|
|
key = str(item[0], encoding="utf-8")
|
|
items = re.split(r'-', key)
|
|
items = re.split(r'-', key)
|
|
@@ -96,7 +101,7 @@ class MchDataCenter(object):
|
|
if diff < 0:
|
|
if diff < 0:
|
|
print(diff)
|
|
print(diff)
|
|
hfive[path][pos, diff] = val
|
|
hfive[path][pos, diff] = val
|
|
- print(path, pos, diff, val, hfive[path][pos, diff])
|
|
|
|
|
|
+ print(path, pos, diff, time, val, hfive[path][pos, diff])
|
|
pass
|
|
pass
|
|
|
|
|
|
def day_stamp(self, stamp):
|
|
def day_stamp(self, stamp):
|