37 lines
1009 B
Python
37 lines
1009 B
Python
import json
|
|
|
|
from django.db import connection
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import render
|
|
|
|
# Create your views here.
|
|
def monotoring(request):
|
|
with connection.cursor() as cursor:
|
|
cursor.execute("select * from detections")
|
|
row = cursor.fetchall()
|
|
res = []
|
|
for r in row:
|
|
o = dict()
|
|
o['name'] = r[1]
|
|
if r[2] == '1':
|
|
o['type'] = '站点检测'
|
|
elif r[2] == '2':
|
|
o['type'] = '端口检测'
|
|
elif r[2] == '3':
|
|
o['type'] = '进程检测'
|
|
elif r[2] == '4':
|
|
o['type'] = '自定义脚本'
|
|
elif r[2] == '5':
|
|
o['type'] = 'Ping检测'
|
|
o['addr'] = r[3]
|
|
o['rate'] = r[7]
|
|
o['latest'] = r[13]
|
|
o['latest_run_time'] = r[14]
|
|
|
|
res.append(o)
|
|
|
|
return HttpResponse(json.dumps({
|
|
"status":"1",
|
|
"res":res
|
|
}))
|