This commit is contained in:
usmannasir
2025-06-02 16:27:07 +05:00
parent 43439996e1
commit 2f771f2b7e
3 changed files with 114 additions and 113 deletions

View File

@@ -612,16 +612,16 @@ def getRecentSSHLogs(request):
lines = output.split('\n')
logs = []
for line in lines:
if 'sshd' in line:
# Try to split into timestamp and message
parts = line.split()
if len(parts) > 4:
timestamp = ' '.join(parts[:3])
message = ' '.join(parts[4:])
else:
timestamp = ''
message = line
logs.append({'timestamp': timestamp, 'message': message, 'raw': line})
if not line.strip():
continue
parts = line.split()
if len(parts) > 4:
timestamp = ' '.join(parts[:3])
message = ' '.join(parts[4:])
else:
timestamp = ''
message = line
logs.append({'timestamp': timestamp, 'message': message, 'raw': line})
return HttpResponse(json.dumps({'logs': logs}), content_type='application/json')
except Exception as e:
return HttpResponse(json.dumps({'error': str(e)}), content_type='application/json', status=500)