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)
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
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()
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)