adding elastic search to /monitor
This commit is contained in:
Родитель
92c53bc839
Коммит
6f44fb1085
|
@ -133,4 +133,22 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
{% if settings.USE_ELASTIC %}
|
||||
<div class="notification-box {{ status(status_summary.elastic) }}">
|
||||
<h2>[Elastic Search] Health Check</h2>
|
||||
<ul>
|
||||
<li>
|
||||
{{ settings.ES_HOSTS }}/{{ settings.ES_INDEX }}
|
||||
{% if status_summary.elastic %}
|
||||
{% for k, v in elastic_results|dictsort %}
|
||||
<li><code>{{ k }}: {{ v }}</code></li>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<strong>Failed</strong><br><pre>{{ elastic_results }}</pre>
|
||||
{% endif %}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock main_content %}
|
||||
|
|
|
@ -5,6 +5,7 @@ from PIL import Image
|
|||
import socket
|
||||
import StringIO
|
||||
import time
|
||||
import traceback
|
||||
import urllib2
|
||||
from urlparse import urlparse
|
||||
|
||||
|
@ -19,6 +20,7 @@ from django.views.decorators.http import require_POST
|
|||
from django_arecibo.tasks import post
|
||||
import caching.invalidation
|
||||
import commonware.log
|
||||
import elasticutils
|
||||
import jingo
|
||||
import phpserialize as php
|
||||
import waffle
|
||||
|
@ -122,6 +124,16 @@ def monitor(request, format=None):
|
|||
msg = "Please set SPIDERMONKEY in your settings file."
|
||||
libraries_results.append(("Spidermonkey isn't set up.", False, msg))
|
||||
|
||||
elastic_results = None
|
||||
if settings.USE_ELASTIC:
|
||||
status_summary['elastic'] = False
|
||||
try:
|
||||
health = elasticutils.get_es().cluster_health()
|
||||
status_summary['elastic'] = health['status'] != 'red'
|
||||
elastic_results = health
|
||||
except Exception:
|
||||
elastic_results = traceback.format_exc()
|
||||
|
||||
# Check file paths / permissions
|
||||
rw = (settings.TMP_PATH,
|
||||
settings.NETAPP_STORAGE,
|
||||
|
@ -196,6 +208,7 @@ def monitor(request, format=None):
|
|||
'hera_results': hera_results,
|
||||
'mongo_results': mongo_results,
|
||||
'rabbit_results': rabbit_results,
|
||||
'elastic_results': elastic_results,
|
||||
'status_summary': status_summary},
|
||||
status=status)
|
||||
|
||||
|
|
|
@ -952,3 +952,9 @@ VALID_LOGIN_REDIRECTS = {
|
|||
|
||||
# Secret key we send to builder so we can trust responses from the builder.
|
||||
BUILDER_SECRET_KEY = 'love will tear us apart'
|
||||
|
||||
|
||||
## Elastic Search
|
||||
ES_HOSTS = ['127.0.0.1:9200']
|
||||
ES_INDEX = 'amo'
|
||||
USE_ELASTIC = True
|
||||
|
|
Загрузка…
Ссылка в новой задаче