Merge branch 'master' of https://e.coding.net/ctcdevteam/ehs/ehs_server
This commit is contained in:
commit
8a388928f0
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.2.12 on 2024-03-12 08:34
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('enp', '0007_auto_20240228_1618'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vehicleaccess',
|
||||||
|
name='is_new_energy',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='是否新能源'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -124,6 +124,7 @@ class VehicleAccess(BaseModel):
|
||||||
access_time = models.DateTimeField('出入时间', null=True, blank=True)
|
access_time = models.DateTimeField('出入时间', null=True, blank=True)
|
||||||
emission_standard = models.CharField(
|
emission_standard = models.CharField(
|
||||||
'排放标准', max_length=10, null=True, blank=True)
|
'排放标准', max_length=10, null=True, blank=True)
|
||||||
|
is_new_energy = models.BooleanField('是否新能源', default=False)
|
||||||
door_name = models.CharField('门禁名称', max_length=10, null=True, blank=True)
|
door_name = models.CharField('门禁名称', max_length=10, null=True, blank=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ class VehicleAccessViewSet(ListModelMixin, CustomGenericViewSet):
|
||||||
"vehicle_number": ['icontains'],
|
"vehicle_number": ['icontains'],
|
||||||
"emission_standard": ['exact', 'in'],
|
"emission_standard": ['exact', 'in'],
|
||||||
"type": ['exact', 'in'],
|
"type": ['exact', 'in'],
|
||||||
|
"is_new_energy": ["exact"],
|
||||||
"access_time": ['gte', 'lte', 'year', 'month', 'day', 'quarter', 'week']
|
"access_time": ['gte', 'lte', 'year', 'month', 'day', 'quarter', 'week']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import psutil
|
import psutil
|
||||||
|
import redis
|
||||||
from apps.monitor.models import AuditLog
|
from apps.monitor.models import AuditLog
|
||||||
from apps.system.models import User
|
from apps.system.models import User
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from apps.utils.tools import compare_values
|
from apps.utils.tools import compare_values
|
||||||
from apps.utils.models import get_model_info
|
from apps.utils.models import get_model_info
|
||||||
|
from server.celery import celery_control, celery_inspect
|
||||||
|
|
||||||
|
|
||||||
def delete_auditlog(model, instance_id):
|
def delete_auditlog(model, instance_id):
|
||||||
|
@ -98,3 +100,11 @@ class ServerService:
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_full(cls):
|
def get_full(cls):
|
||||||
return {'cpu': cls.get_cpu_dict(), 'memory': cls.get_memory_dict(), 'disk': cls.get_disk_dict()}
|
return {'cpu': cls.get_cpu_dict(), 'memory': cls.get_memory_dict(), 'disk': cls.get_disk_dict()}
|
||||||
|
|
||||||
|
|
||||||
|
class CeleryMonitor:
|
||||||
|
@classmethod
|
||||||
|
def get_stats(cls):
|
||||||
|
return {
|
||||||
|
'stat': celery_inspect.stats(),
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from .views import DrfRequestLogViewSet, ServerInfoView, LogView, LogDetailView, index, room, video, DbBackupView, AuditlogViewSet
|
from .views import DrfRequestLogViewSet, ServerInfoView, LogView, LogDetailView, index, room, video, DbBackupView, AuditlogViewSet, CeleryInfoView
|
||||||
|
|
||||||
API_BASE_URL = 'api/monitor/'
|
API_BASE_URL = 'api/monitor/'
|
||||||
HTML_BASE_URL = 'monitor/'
|
HTML_BASE_URL = 'monitor/'
|
||||||
|
@ -13,6 +13,7 @@ urlpatterns = [
|
||||||
path(API_BASE_URL + 'log/<str:name>/', LogDetailView.as_view()),
|
path(API_BASE_URL + 'log/<str:name>/', LogDetailView.as_view()),
|
||||||
path(API_BASE_URL + 'dbbackup/', DbBackupView.as_view()),
|
path(API_BASE_URL + 'dbbackup/', DbBackupView.as_view()),
|
||||||
path(API_BASE_URL + 'server/', ServerInfoView.as_view()),
|
path(API_BASE_URL + 'server/', ServerInfoView.as_view()),
|
||||||
|
path(API_BASE_URL + 'celery/', CeleryInfoView.as_view()),
|
||||||
path(API_BASE_URL + 'request_log/',
|
path(API_BASE_URL + 'request_log/',
|
||||||
DrfRequestLogViewSet.as_view({'get': 'list'}), name='requestlog_view'),
|
DrfRequestLogViewSet.as_view({'get': 'list'}), name='requestlog_view'),
|
||||||
path(API_BASE_URL + 'auditlog/',
|
path(API_BASE_URL + 'auditlog/',
|
||||||
|
|
|
@ -16,8 +16,9 @@ from apps.monitor.filters import DrfLogFilterSet
|
||||||
from apps.monitor.models import DrfRequestLog, AuditLog
|
from apps.monitor.models import DrfRequestLog, AuditLog
|
||||||
|
|
||||||
from apps.monitor.errors import LOG_NOT_FONED
|
from apps.monitor.errors import LOG_NOT_FONED
|
||||||
from apps.monitor.services import ServerService
|
from apps.monitor.services import ServerService, CeleryMonitor
|
||||||
from apps.utils.viewsets import CustomGenericViewSet
|
from apps.utils.viewsets import CustomGenericViewSet
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +36,18 @@ def video(request):
|
||||||
return render(request, 'monitor/video.html')
|
return render(request, 'monitor/video.html')
|
||||||
|
|
||||||
|
|
||||||
|
class CeleryInfoView(APIView):
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
获取celery状态信息
|
||||||
|
|
||||||
|
获取celery状态信息
|
||||||
|
"""
|
||||||
|
return Response(CeleryMonitor.get_stats())
|
||||||
|
|
||||||
|
|
||||||
class ServerInfoView(APIView):
|
class ServerInfoView(APIView):
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
from . import conf
|
from . import conf
|
||||||
from celery import Celery
|
from celery import Celery
|
||||||
|
from celery.app.control import Control, Inspect
|
||||||
|
|
||||||
# set the default Django settings module for the 'celery' program.
|
# set the default Django settings module for the 'celery' program.
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
|
||||||
|
@ -16,6 +17,9 @@ app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||||
# Load task modules from all registered Django app configs.
|
# Load task modules from all registered Django app configs.
|
||||||
app.autodiscover_tasks()
|
app.autodiscover_tasks()
|
||||||
|
|
||||||
|
celery_control: Control = Control(app=app)
|
||||||
|
celery_inspect: Inspect = celery_control.inspect()
|
||||||
|
|
||||||
|
|
||||||
@app.task(bind=True)
|
@app.task(bind=True)
|
||||||
def debug_task(self):
|
def debug_task(self):
|
||||||
|
|
Loading…
Reference in New Issue