fix up for internal use
This commit is contained in:
parent
ecfc3abae8
commit
5fd222e165
@ -1,28 +1,18 @@
|
|||||||
from django.conf.urls.defaults import patterns, include, url
|
from django.conf.urls.defaults import patterns, include, url
|
||||||
|
|
||||||
# Uncomment the next two lines to enable the admin:
|
|
||||||
# from django.contrib import admin
|
|
||||||
# admin.autodiscover()
|
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^$', 'dss.stackmon.views.welcome', name='welcome'),
|
url(r'^$', 'stacktach.views.welcome', name='welcome'),
|
||||||
url(r'new_tenant', 'dss.stackmon.views.new_tenant', name='new_tenant'),
|
url(r'new_tenant', 'stacktach.views.new_tenant', name='new_tenant'),
|
||||||
url(r'logout', 'dss.stackmon.views.logout', name='logout'),
|
url(r'logout', 'stacktach.views.logout', name='logout'),
|
||||||
url(r'^(?P<tenant_id>\d+)/$', 'dss.stackmon.views.home', name='home'),
|
url(r'^(?P<tenant_id>\d+)/$', 'stacktach.views.home', name='home'),
|
||||||
url(r'^(?P<tenant_id>\d+)/data/$', 'dss.stackmon.views.data',
|
url(r'^(?P<tenant_id>\d+)/data/$', 'stacktach.views.data',
|
||||||
name='data'),
|
name='data'),
|
||||||
url(r'^(?P<tenant_id>\d+)/details/(?P<column>\w+)/(?P<row_id>\d+)/$',
|
url(r'^(?P<tenant_id>\d+)/details/(?P<column>\w+)/(?P<row_id>\d+)/$',
|
||||||
'dss.stackmon.views.details', name='details'),
|
'stacktach.views.details', name='details'),
|
||||||
url(r'^(?P<tenant_id>\d+)/expand/(?P<row_id>\d+)/$',
|
url(r'^(?P<tenant_id>\d+)/expand/(?P<row_id>\d+)/$',
|
||||||
'dss.stackmon.views.expand', name='expand'),
|
'stacktach.views.expand', name='expand'),
|
||||||
url(r'^(?P<tenant_id>\d+)/host_status/$',
|
url(r'^(?P<tenant_id>\d+)/host_status/$',
|
||||||
'dss.stackmon.views.host_status', name='host_status'),
|
'stacktach.views.host_status', name='host_status'),
|
||||||
url(r'^(?P<tenant_id>\d+)/instance_status/$',
|
url(r'^(?P<tenant_id>\d+)/instance_status/$',
|
||||||
'dss.stackmon.views.instance_status', name='instance_status'),
|
'stacktach.views.instance_status', name='instance_status'),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below to enable admin documentation:
|
|
||||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
|
||||||
|
|
||||||
# Uncomment the next line to enable the admin:
|
|
||||||
# url(r'^admin/', include(admin.site.urls)),
|
|
||||||
)
|
)
|
||||||
|
@ -4,8 +4,9 @@ from django.shortcuts import render_to_response
|
|||||||
from django import http
|
from django import http
|
||||||
from django import template
|
from django import template
|
||||||
from django.utils.functional import wraps
|
from django.utils.functional import wraps
|
||||||
|
from django.views.decorators.csrf import csrf_protect
|
||||||
|
|
||||||
from dss.stackmon import models
|
from stacktach import models
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
@ -148,22 +149,22 @@ def _default_context(state):
|
|||||||
|
|
||||||
|
|
||||||
def welcome(request):
|
def welcome(request):
|
||||||
state = _reset_state(request, None)
|
state = _reset_state(request)
|
||||||
return render_to_response('stackmon/welcome.html', _default_context(state))
|
return render_to_response('welcome.html', _default_context(state))
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
def home(request, tenant_id):
|
def home(request, tenant_id):
|
||||||
state = _get_state(request, tenant_id)
|
state = _get_state(request, tenant_id)
|
||||||
return render_to_response('stackmon/index.html', _default_context(state))
|
return render_to_response('index.html', _default_context(state))
|
||||||
|
|
||||||
|
|
||||||
def logout(request):
|
def logout(request):
|
||||||
del request.session['state']
|
del request.session['state']
|
||||||
return render_to_response('stackmon/welcome.html', _default_context(None))
|
return render_to_response('welcome.html', _default_context(None))
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@csrf_protect
|
||||||
def new_tenant(request):
|
def new_tenant(request):
|
||||||
state = _get_state(request)
|
state = _get_state(request)
|
||||||
context = _default_context(state)
|
context = _default_context(state)
|
||||||
@ -172,12 +173,13 @@ def new_tenant(request):
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
rec = models.Tenant(**form.cleaned_data)
|
rec = models.Tenant(**form.cleaned_data)
|
||||||
rec.save()
|
rec.save()
|
||||||
_reset_state(request, rec.tenant_id)
|
_reset_state(request)
|
||||||
return http.HttpResponseRedirect('/stacktach/%d' % rec.tenant_id)
|
return http.HttpResponseRedirect('/%d' % rec.tenant_id)
|
||||||
else:
|
else:
|
||||||
form = models.TenantForm()
|
form = models.TenantForm()
|
||||||
context['form'] = form
|
context['form'] = form
|
||||||
return render_to_response('stackmon/new_tenant.html', context)
|
return render_to_response('new_tenant.html', context,
|
||||||
|
context_instance=template.RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
@ -188,7 +190,7 @@ def data(request, tenant_id):
|
|||||||
c = _default_context(state)
|
c = _default_context(state)
|
||||||
fields = _parse(state.tenant, args, raw_args)
|
fields = _parse(state.tenant, args, raw_args)
|
||||||
c['cooked_args'] = fields
|
c['cooked_args'] = fields
|
||||||
return render_to_response('stackmon/data.html', c)
|
return render_to_response('data.html', c)
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
@ -197,7 +199,7 @@ def details(request, tenant_id, column, row_id):
|
|||||||
c = _default_context(state)
|
c = _default_context(state)
|
||||||
row = models.RawData.objects.get(pk=row_id)
|
row = models.RawData.objects.get(pk=row_id)
|
||||||
value = getattr(row, column)
|
value = getattr(row, column)
|
||||||
rows = models.RawData.objects.filter(tenant_id=tenant_id)
|
rows = models.RawData.objects.filter(tenant=tenant_id)
|
||||||
if column != 'when':
|
if column != 'when':
|
||||||
rows = rows.filter(**{column:value})
|
rows = rows.filter(**{column:value})
|
||||||
else:
|
else:
|
||||||
@ -210,7 +212,7 @@ def details(request, tenant_id, column, row_id):
|
|||||||
c['rows'] = rows
|
c['rows'] = rows
|
||||||
c['allow_expansion'] = True
|
c['allow_expansion'] = True
|
||||||
c['show_absolute_time'] = True
|
c['show_absolute_time'] = True
|
||||||
return render_to_response('stackmon/rows.html', c)
|
return render_to_response('rows.html', c)
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
@ -221,29 +223,29 @@ def expand(request, tenant_id, row_id):
|
|||||||
payload = json.loads(row.json)
|
payload = json.loads(row.json)
|
||||||
pp = pprint.PrettyPrinter()
|
pp = pprint.PrettyPrinter()
|
||||||
c['payload'] = pp.pformat(payload)
|
c['payload'] = pp.pformat(payload)
|
||||||
return render_to_response('stackmon/expand.html', c)
|
return render_to_response('expand.html', c)
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
def host_status(request, tenant_id):
|
def host_status(request, tenant_id):
|
||||||
state = _get_state(request, tenant_id)
|
state = _get_state(request, tenant_id)
|
||||||
c = _default_context(state)
|
c = _default_context(state)
|
||||||
hosts = models.RawData.objects.filter(tenant_id=tenant_id).\
|
hosts = models.RawData.objects.filter(tenant=tenant_id).\
|
||||||
filter(host__gt='').\
|
filter(host__gt='').\
|
||||||
order_by('-when', '-microseconds')[:20]
|
order_by('-when', '-microseconds')[:20]
|
||||||
_post_process_raw_data(hosts)
|
_post_process_raw_data(hosts)
|
||||||
c['rows'] = hosts
|
c['rows'] = hosts
|
||||||
return render_to_response('stackmon/host_status.html', c)
|
return render_to_response('host_status.html', c)
|
||||||
|
|
||||||
|
|
||||||
@tenant_check
|
@tenant_check
|
||||||
def instance_status(request, tenant_id):
|
def instance_status(request, tenant_id):
|
||||||
state = _get_state(request, tenant_id)
|
state = _get_state(request, tenant_id)
|
||||||
c = _default_context(state)
|
c = _default_context(state)
|
||||||
instances = models.RawData.objects.filter(tenant_id=tenant_id).\
|
instances = models.RawData.objects.filter(tenant=tenant_id).\
|
||||||
exclude(instance='n/a').\
|
exclude(instance='n/a').\
|
||||||
exclude(instance__isnull=True).\
|
exclude(instance__isnull=True).\
|
||||||
order_by('-when', '-microseconds')[:20]
|
order_by('-when', '-microseconds')[:20]
|
||||||
_post_process_raw_data(instances)
|
_post_process_raw_data(instances)
|
||||||
c['rows'] = instances
|
c['rows'] = instances
|
||||||
return render_to_response('stackmon/instance_status.html', c)
|
return render_to_response('instance_status.html', c)
|
||||||
|
@ -21,7 +21,8 @@ under the License.
|
|||||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
|
||||||
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/jquery.timers.js"></script>
|
<script type="text/javascript" src="/static/jquery.timers.js"></script>
|
||||||
|
|
||||||
<link href='http://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'>
|
||||||
<link href='http://fonts.googleapis.com/css?family=PT+Sans&subset=latin' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=PT+Sans&subset=latin' rel='stylesheet' type='text/css'>
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Get a <a href='/new_tenant'>StackTach Tenant ID</a>
|
<li>Get a <a href='/new_tenant'>StackTach Tenant ID</a>
|
||||||
<li>Add <pre>--notification_driver=nova.notifier.rabbit_notifier</pre> and
|
<li>Add <pre>--notification_driver=nova.notifier.rabbit_notifier</pre> and
|
||||||
<li><pre>--notification_topics=monitor</pre> to your nova.conf file.
|
<li><pre>--notification_topics=info,monitor</pre> to your nova.conf file.
|
||||||
<li>Configure and run the <a target='_blank' href='https://github.com/SandyWalsh/StackTach'>StackTach Worker</a> somewhere in your Nova development environment.
|
<li>Configure and run the <a target='_blank' href='https://github.com/Rackspace/StackTach'>StackTach Worker</a> somewhere in your Nova development environment.
|
||||||
<li>Restart Nova and visit http://darksecretsoftware.com/stacktach/[your_tenant_id]/ to see your Nova installation in action!
|
<li>Restart Nova and visit http://[your server]/[your_tenant_id]/ to see your Nova installation in action!
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
8
urls.py
8
urls.py
@ -5,11 +5,5 @@ from django.conf.urls.defaults import patterns, include, url
|
|||||||
# admin.autodiscover()
|
# admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
url(r'^', include('stacktach.urls')),
|
url(r'^', include('stacktach.url')),
|
||||||
|
|
||||||
# Uncomment the admin/doc line below to enable admin documentation:
|
|
||||||
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
|
||||||
|
|
||||||
# Uncomment the next line to enable the admin:
|
|
||||||
# url(r'^admin/', include(admin.site.urls)),
|
|
||||||
)
|
)
|
||||||
|
24
worker.py
24
worker.py
@ -28,6 +28,16 @@ import urllib2
|
|||||||
# CHANGE THESE FOR YOUR INSTALLATION ...
|
# CHANGE THESE FOR YOUR INSTALLATION ...
|
||||||
TENANT_ID = 1
|
TENANT_ID = 1
|
||||||
URL = 'http://darksecretsoftware.com/stacktach/%d/data/' % TENANT_ID
|
URL = 'http://darksecretsoftware.com/stacktach/%d/data/' % TENANT_ID
|
||||||
|
RABBIT_HOST = "localhost"
|
||||||
|
RABBIT_PORT = 5672
|
||||||
|
RABBIT_USERID = "guest"
|
||||||
|
RABBIT_PASSWORD = "guest"
|
||||||
|
RABBIT_VIRTUAL_HOST = "/"
|
||||||
|
|
||||||
|
try:
|
||||||
|
from worker_conf import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
# For now we'll just grab all the fanout messages from compute to scheduler ...
|
# For now we'll just grab all the fanout messages from compute to scheduler ...
|
||||||
scheduler_exchange = kombu.entity.Exchange("scheduler_fanout", type="fanout",
|
scheduler_exchange = kombu.entity.Exchange("scheduler_fanout", type="fanout",
|
||||||
@ -43,7 +53,7 @@ scheduler_queues = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
nova_exchange = kombu.entity.Exchange("nova", type="topic",
|
nova_exchange = kombu.entity.Exchange("nova", type="topic",
|
||||||
durable=False, auto_delete=False,
|
durable=True, auto_delete=False,
|
||||||
exclusive=False)
|
exclusive=False)
|
||||||
|
|
||||||
nova_queues = [
|
nova_queues = [
|
||||||
@ -51,12 +61,6 @@ nova_queues = [
|
|||||||
exclusive=False, routing_key='monitor.*'),
|
exclusive=False, routing_key='monitor.*'),
|
||||||
]
|
]
|
||||||
|
|
||||||
RABBIT_HOST = "localhost"
|
|
||||||
RABBIT_PORT = 5672
|
|
||||||
RABBIT_USERID = "guest"
|
|
||||||
RABBIT_PASSWORD = "guest"
|
|
||||||
RABBIT_VIRTUAL_HOST = "/"
|
|
||||||
|
|
||||||
|
|
||||||
class SchedulerFanoutConsumer(kombu.mixins.ConsumerMixin):
|
class SchedulerFanoutConsumer(kombu.mixins.ConsumerMixin):
|
||||||
def __init__(self, connection):
|
def __init__(self, connection):
|
||||||
@ -89,7 +93,7 @@ class SchedulerFanoutConsumer(kombu.mixins.ConsumerMixin):
|
|||||||
|
|
||||||
def on_scheduler(self, body, message):
|
def on_scheduler(self, body, message):
|
||||||
# Uncomment if you want periodic compute node status updates.
|
# Uncomment if you want periodic compute node status updates.
|
||||||
# self._process(body, message)
|
#self._process(body, message)
|
||||||
message.ack()
|
message.ack()
|
||||||
|
|
||||||
def on_nova(self, body, message):
|
def on_nova(self, body, message):
|
||||||
@ -98,6 +102,9 @@ class SchedulerFanoutConsumer(kombu.mixins.ConsumerMixin):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
print "StackTach", URL
|
||||||
|
print "Rabbit", RABBIT_HOST, RABBIT_PORT, RABBIT_USERID, RABBIT_VIRTUAL_HOST
|
||||||
|
|
||||||
params = dict(hostname=RABBIT_HOST,
|
params = dict(hostname=RABBIT_HOST,
|
||||||
port=RABBIT_PORT,
|
port=RABBIT_PORT,
|
||||||
userid=RABBIT_USERID,
|
userid=RABBIT_USERID,
|
||||||
@ -107,6 +114,7 @@ if __name__ == "__main__":
|
|||||||
with kombu.connection.BrokerConnection(**params) as conn:
|
with kombu.connection.BrokerConnection(**params) as conn:
|
||||||
consumer = SchedulerFanoutConsumer(conn)
|
consumer = SchedulerFanoutConsumer(conn)
|
||||||
try:
|
try:
|
||||||
|
print "Listening"
|
||||||
consumer.run()
|
consumer.run()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("bye bye")
|
print("bye bye")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user