diff options
author | Bin Yang <bin.yang@windriver.com> | 2018-05-19 10:44:21 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2018-05-19 10:44:21 +0800 |
commit | 486a3258a61028e0524a2cc871fb90cf9b0b2891 (patch) | |
tree | 637799d58db53ed2d350d7e2956a836f94f401af /windriver/titanium_cloud | |
parent | 56d40fafdea16c63892f4f9696788290f1da4ef5 (diff) |
correct the timestamp granularity
Change-Id: I6a7f4046fa2f28f4a0dc93becf28926bcbe52dbc
Issue-ID: MULTICLOUD-236
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'windriver/titanium_cloud')
-rw-r--r-- | windriver/titanium_cloud/vesagent/event_domain/fault_vm.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/windriver/titanium_cloud/vesagent/event_domain/fault_vm.py b/windriver/titanium_cloud/vesagent/event_domain/fault_vm.py index 308ef24c..00738ced 100644 --- a/windriver/titanium_cloud/vesagent/event_domain/fault_vm.py +++ b/windriver/titanium_cloud/vesagent/event_domain/fault_vm.py @@ -23,6 +23,17 @@ from django.conf import settings from titanium_cloud.vesagent.vespublish import publishAnyEventToVES from common.utils.restcall import _call_req +import datetime +import time +def get_epoch_now_usecond(): + ''' + get epoch timestamp of this moment in usecond + :return: + ''' + now_time = datetime.datetime.now() + epoch_time_sec = time.mktime(now_time.timetuple()) + return int(epoch_time_sec * 1e6 + now_time.microsecond) + logger = logging.getLogger(__name__) ### build backlog with domain:"fault", type:"vm" @@ -202,8 +213,8 @@ def data2event_fault_vm(oneBacklog, last_event, vm_data): reportingEntityName = '' sequence = 0 - startEpochMicrosec = int(time.time()) - lastEpochMicrosec = int(time.time()) + startEpochMicrosec = get_epoch_now_usecond() + lastEpochMicrosec = get_epoch_now_usecond() eventId = str(uuid.uuid4()) pass @@ -226,7 +237,7 @@ def data2event_fault_vm(oneBacklog, last_event, vm_data): sequence = 0 startEpochMicrosec = last_event['event']['commonEventHeader']['startEpochMicrosec'] - lastEpochMicrosec = int(time.time()) + lastEpochMicrosec = get_epoch_now_usecond() eventId = last_event['event']['commonEventHeader']['eventId'] pass |