del: 删除测试prometheus相关代码

pull/5231/head
Bai 4 years ago committed by Jiangjie.Bai
parent b9717eece3
commit b9cbff1a5f

@ -57,7 +57,6 @@ INSTALLED_APPS = [
'django_filters',
'bootstrap3',
'captcha',
'django_prometheus',
'django_celery_beat',
'django.contrib.auth',
'django.contrib.admin',
@ -70,7 +69,6 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django_prometheus.middleware.PrometheusBeforeMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
@ -86,7 +84,6 @@ MIDDLEWARE = [
'orgs.middleware.OrgMiddleware',
'authentication.backends.oidc.middleware.OIDCRefreshIDTokenMiddleware',
'authentication.backends.cas.middleware.CASMiddleware',
'django_prometheus.middleware.PrometheusAfterMiddleware',
]

@ -55,41 +55,7 @@ apps = [
]
def test_metric(request):
import random
data = ""
components = ['koko', 'guacamole', 'omnidb']
status = ['normal', 'high', 'critical', 'total']
data += "# JumpServer 各组件状态个数汇总\n"
for com in components:
data += f"## 组件: {com}\n"
for s in status:
key = 'jumpserver_components_status_total{component_type="%s", status="%s"}' % (com, s)
value = round(10 * random.random() * 10, 2)
data += f"{key} {value}\n"
data += "\n# JumpServer 各组件在线会话数汇总\n"
for com in components:
for item in ['session_active']:
key = 'jumpserver_components_%s_total{component_type="%s"}' % (item, com)
value = round(40 * random.random() * 10, 2)
data += f"{key} {value}\n"
data += "\n# JumpServer 各组件节点一些指标\n"
for item in ['cpu1_load', 'memory_used_percent', 'disk_used_percent', 'session_active']:
data += f"## 指标: {item}\n"
for com in components:
for instance in ['node1', 'node2', 'node3']:
key = 'jumpserver_components_%s{component_type="%s", component="%s"}' % (item, com, instance)
value = round(20 * random.random() * 10, 2)
data += f"{key} {value}\n"
return HttpResponse(data, content_type='text/plain; version=0.0.4; charset=utf-8')
urlpatterns = [
# path('prometheus/', include('django_prometheus.urls')),
path('prometheus/metrics', test_metric),
path('', views.IndexView.as_view(), name='index'),
path('api/v1/', include(api_v1)),
path('api/v2/', include(api_v2)),

Loading…
Cancel
Save