Commit fa34f7cb by Kálmán Viktor

vm: measure boot time

parent f06fe9b9
......@@ -24,7 +24,9 @@ from base64 import encodestring
from StringIO import StringIO
from tarfile import TarFile, TarInfo
from django.conf import settings
from django.utils import timezone
from celery.result import TimeoutError
from monitor.client import Client
def send_init_commands(instance, act, vm):
......@@ -86,12 +88,33 @@ def agent_started(vm, version=None):
pass
if not initialized:
measure_boot_time(instance)
send_init_commands(instance, act, vm)
with act.sub_activity('start_access_server'):
start_access_server.apply_async(queue=queue, args=(vm, ))
def measure_boot_time(instance):
if not instance.template:
return
from vm.models import InstanceActivity
deploy_time = InstanceActivity.objects.filter(
instance=instance, activity_code="vm.Instance.deploy"
).latest("finished").finished
total_boot_time = (timezone.now() - deploy_time).total_seconds()
Client().send([
"template.%(pk)d.boot_time %(val)f %(time)s" % {
'pk': instance.template.pk,
'val': total_boot_time,
'time': time.time(),
}
])
@celery.task
def agent_stopped(vm):
from vm.models import Instance, InstanceActivity
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment