예제 #1
0
파일: tasks.py 프로젝트: wangwd123/neu-jump
def check_server_performance_period():
    usages = get_disk_usage()
    uncheck_paths = ['/etc', '/boot']

    for path, usage in usages.items():
        need_check = True
        for uncheck_path in uncheck_paths:
            if path.startswith(uncheck_path):
                need_check = False
        if need_check and usage.percent > 80:
            send_server_performance_mail(path, usage, usages)
예제 #2
0
def check_server_performance_period():
    usages = get_disk_usage()
    usages = {
        path: usage
        for path, usage in usages.items() if not path.startswith('/etc')
    }

    for path, usage in usages.items():
        if usage.percent > 80:
            send_server_performance_mail(path, usage, usages)
            return
예제 #3
0
def check_server_performance_period():
    if not settings.DISK_CHECK_ENABLED:
        return
    usages = get_disk_usage()
    uncheck_paths = ['/etc', '/boot']

    for path, usage in usages.items():
        need_check = True
        for uncheck_path in uncheck_paths:
            if path.startswith(uncheck_path):
                need_check = False
        if need_check and usage.percent > 80:
            ServerPerformanceMessage(path=path, usage=usage).publish()
예제 #4
0
    def start_heartbeat(self):
        while True:
            heartbeat_data = {
                'cpu_load': get_cpu_load(),
                'memory_used': get_memory_usage(),
                'disk_used': get_disk_usage(path=settings.BASE_DIR),
                'sessions': [],
            }
            status_serializer = StatusSerializer(data=heartbeat_data)
            status_serializer.is_valid()
            status_serializer.validated_data.pop('sessions', None)
            terminal = self.get_or_register_terminal()
            status_serializer.validated_data['terminal'] = terminal
            status_serializer.save()

            time.sleep(self.interval)