Created
March 18, 2015 03:01
-
-
Save zqfan/ffe23de6ff1ef7e2332d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ceilometer.publisher import utils | |
import datetime | |
msg = { | |
'source': 'openstack', | |
'counter_name': 'cpu_util', | |
'counter_type': 'gauge', | |
'counter_unit': '%', | |
'counter_volume': '99', | |
'user_id': 'adf08413e7ee4926b3b2496be649c8b1', | |
'project_id': '6e8f5b1d05fe4cc39ed8b65b31548c21', | |
'resource_id': 'cc5402a6-82c1-4c30-93ce-59a861db697', | |
'timestamp': str(datetime.datetime.utcnow()), | |
'resource_metadata': { | |
"OS-EXT-AZ.availability_zone": "nova", | |
"disk_gb": "1", | |
"display_name": "hyp-vm", | |
"ephemeral_gb": "0", | |
"flavor.disk": "1", | |
"flavor.ephemeral": "0", | |
"flavor.id": "1", | |
"flavor.links": [{u"href": u"http://10.67.148.27:8774/2dbab0c41e494419929c040ec7e915d8/flavors/1", u"rel": u"bookmark"}], | |
"flavor.name": "m1.tiny", | |
"flavor.ram": "512", | |
"flavor.vcpus": "1", | |
"host": "a92db3938a9b08b558d122bd6be230535f5f84d1970439d21b95c758", | |
"image.id": "e3dfc897-2966-46b9-a028-9fbed95cbee6", | |
"image.links": [{u"href": u"http://10.67.148.27:8774/2dbab0c41e494419929c040ec7e915d8/images/e3dfc897-2966-46b9-a028-9fbed95cbee6", u"rel": u"bookmark"}], | |
"image.name": "cirros-0.3.2-x86_64", | |
"image_ref": "e3dfc897-2966-46b9-a028-9fbed95cbee6", | |
"image_ref_url": "http://10.67.148.27:8774/2dbab0c41e494419929c040ec7e915d8/images/e3dfc897-2966-46b9-a028-9fbed95cbee6", | |
"instance_type": "1", | |
"kernel_id": "None", | |
"memory_mb": "512", | |
"name": "instance-00000030", | |
"ramdisk_id": "None", | |
"root_gb": "1", | |
"status": "shutoff", | |
"vcpus": "1" | |
}, | |
'message_id': 'b960e423-511e-4f87-b95b-4ef75896ba3f', | |
} | |
count = 5000*13 | |
secret = "metering" | |
start = datetime.datetime.utcnow() | |
for i in range(count): | |
msg['message_signature'] = utils.compute_signature(msg, secret) | |
# utils.verify_signature(msg, secret) | |
end = datetime.datetime.utcnow() | |
print 'data count:', count | |
print 'start time:', start | |
print 'finish time:', end | |
delta = (end - start).total_seconds() | |
print 'delta seconds:', delta | |
print 'average seconds:', delta / float(count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment