Merge branch 'master' of git://github.com/rackspace/stacktach
This commit is contained in:
commit
6ba0458fbb
@ -38,7 +38,8 @@ class RawData(models.Model):
|
||||
blank=True, db_index=True)
|
||||
old_task = models.CharField(max_length=30, null=True,
|
||||
blank=True, db_index=True)
|
||||
when = models.DecimalField(max_digits=20, decimal_places=6)
|
||||
when = models.DecimalField(max_digits=20, decimal_places=6,
|
||||
db_index=True)
|
||||
publisher = models.CharField(max_length=100, null=True,
|
||||
blank=True, db_index=True)
|
||||
event = models.CharField(max_length=50, null=True,
|
||||
@ -81,10 +82,12 @@ class Timing(models.Model):
|
||||
start_raw = models.ForeignKey(RawData, related_name='+', null=True)
|
||||
end_raw = models.ForeignKey(RawData, related_name='+', null=True)
|
||||
|
||||
start_when = models.DecimalField(null=True, max_digits=20, decimal_places=6)
|
||||
start_when = models.DecimalField(null=True, max_digits=20,
|
||||
decimal_places=6)
|
||||
end_when = models.DecimalField(null=True, max_digits=20, decimal_places=6)
|
||||
|
||||
diff = models.DecimalField(null=True, max_digits=20, decimal_places=6)
|
||||
diff = models.DecimalField(null=True, max_digits=20, decimal_places=6,
|
||||
db_index=True)
|
||||
|
||||
|
||||
class RequestTracker(models.Model):
|
||||
@ -93,9 +96,10 @@ class RequestTracker(models.Model):
|
||||
final .end event (with the same Request ID)."""
|
||||
request_id = models.CharField(max_length=50, db_index=True)
|
||||
lifecycle = models.ForeignKey(Lifecycle)
|
||||
last_timing = models.ForeignKey(Timing, null=true)
|
||||
start = models.DecimalField(max_digits=20, decimal_places=6)
|
||||
duration = models.DecimalField(max_digits=20, decimal_places=6)
|
||||
last_timing = models.ForeignKey(Timing, null=True, db_index=True)
|
||||
start = models.DecimalField(max_digits=20, decimal_places=6, db_index=True)
|
||||
duration = models.DecimalField(max_digits=20, decimal_places=6,
|
||||
db_index=True)
|
||||
|
||||
# Not used ... but soon hopefully.
|
||||
completed = models.BooleanField(default=False)
|
||||
completed = models.BooleanField(default=False, db_index=True)
|
||||
|
@ -67,7 +67,7 @@ def sec_to_time(diff):
|
||||
seconds -= (hours * SECS_PER_HOUR)
|
||||
minutes = seconds / 60
|
||||
seconds -= (minutes * 60)
|
||||
usec = ('%.2f' % usec).lstrip('0')
|
||||
usec = str(usec)[1:4]
|
||||
return "%dd %02d:%02d:%02d%s" % (days, hours, minutes, seconds, usec)
|
||||
|
||||
|
||||
@ -279,8 +279,9 @@ def do_watch(request, deployment_id):
|
||||
return rsp([c, results, str(dec_now)])
|
||||
|
||||
|
||||
def do_kpi(request):
|
||||
def do_kpi(request, tenant_id=None):
|
||||
yesterday = datetime.datetime.utcnow() - datetime.timedelta(days=1)
|
||||
yesterday = dt.dt_to_decimal(yesterday)
|
||||
trackers = models.RequestTracker.objects.select_related() \
|
||||
.exclude(last_timing=None) \
|
||||
.exclude(start__lt=yesterday) \
|
||||
@ -292,6 +293,7 @@ def do_kpi(request):
|
||||
end_event = track.last_timing.end_raw
|
||||
event = end_event.event[:-len(".end")]
|
||||
uuid = track.lifecycle.instance
|
||||
if tenant_id == None or (tenant_id == end_event.tenant):
|
||||
results.append([event, sec_to_time(track.duration),
|
||||
uuid, end_event.deployment.name])
|
||||
return rsp(results)
|
||||
|
@ -17,6 +17,7 @@ urlpatterns = patterns('',
|
||||
url(r'stacky/watch/(?P<deployment_id>\d+)/$',
|
||||
'stacktach.stacky_server.do_watch'),
|
||||
url(r'stacky/kpi/$', 'stacktach.stacky_server.do_kpi'),
|
||||
url(r'stacky/kpi/(?P<tenant_id>\d+)/$', 'stacktach.stacky_server.do_kpi'),
|
||||
|
||||
url(r'^(?P<deployment_id>\d+)/$', 'stacktach.views.home', name='home'),
|
||||
url(r'^(?P<deployment_id>\d+)/details/(?P<column>\w+)/(?P<row_id>\d+)/$',
|
||||
|
@ -87,7 +87,7 @@ def start_kpi_tracking(lifecycle, raw):
|
||||
start=raw.when,
|
||||
lifecycle=lifecycle,
|
||||
last_timing=None,
|
||||
duration=0.0)
|
||||
duration=str(0.0))
|
||||
tracker.save()
|
||||
|
||||
|
||||
@ -102,7 +102,8 @@ def update_kpi(lifecycle, timing, raw):
|
||||
|
||||
Until then, we'll take the lazy route and be aware of these
|
||||
potential fence-post issues."""
|
||||
trackers = models.RequestTracker.objects.filter(request_id=raw.request.id)
|
||||
trackers = models.RequestTracker.objects.\
|
||||
filter(request_id=raw.request_id)
|
||||
if len(trackers) == 0:
|
||||
return
|
||||
|
||||
@ -146,7 +147,7 @@ def aggregate(raw):
|
||||
|
||||
if not step in ['start', 'end']:
|
||||
# Perhaps it's an operation initiated in the API?
|
||||
start_kpi_tracking(lifecyle, raw)
|
||||
start_kpi_tracking(lifecycle, raw)
|
||||
return
|
||||
|
||||
# We are going to try to track every event pair that comes
|
||||
@ -313,7 +314,9 @@ def latest_raw(request, deployment_id):
|
||||
"""This is the 2sec ticker that updates the Recent Activity box."""
|
||||
deployment_id = int(deployment_id)
|
||||
c = _default_context(request, deployment_id)
|
||||
query = models.RawData.objects.select_related()
|
||||
then = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
|
||||
thend = dt.dt_to_decimal(then)
|
||||
query = models.RawData.objects.select_related().filter(when__gt=thend)
|
||||
if deployment_id > 0:
|
||||
query = query.filter(deployment=deployment_id)
|
||||
rows = query.order_by('-when')[:20]
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
WORKDIR=/srv/www/stacktach/django/stproject/
|
||||
WORKDIR=/srv/www/stacktach/app
|
||||
DAEMON=/usr/bin/python
|
||||
ARGS=$WORKDIR/worker/start_workers.py
|
||||
PIDFILE=/var/run/stacktach.pid
|
||||
|
Loading…
Reference in New Issue
Block a user