diff --git a/baseTemplate/static/baseTemplate/custom-js/system-status.js b/baseTemplate/static/baseTemplate/custom-js/system-status.js index 88a4e5bb5..e3ef62545 100644 --- a/baseTemplate/static/baseTemplate/custom-js/system-status.js +++ b/baseTemplate/static/baseTemplate/custom-js/system-status.js @@ -868,18 +868,37 @@ app.controller('OnboardingCP', function ($scope, $http, $timeout, $window) { }); -app.controller('dashboardStatsController', function ($scope, $http, $timeout) { +app.controller('dashboardStatsController', function ($scope, $http) { // Card values $scope.totalSites = 0; $scope.totalWPSites = 0; $scope.totalDBs = 0; $scope.totalEmails = 0; + // SSH Logins + $scope.sshLogins = []; + $scope.loadingSSHLogins = true; + $scope.errorSSHLogins = ''; + $scope.refreshSSHLogins = function() { + $scope.loadingSSHLogins = true; + $http.get('/base/getRecentSSHLogins').then(function (response) { + $scope.loadingSSHLogins = false; + if (response.data && response.data.logins) { + $scope.sshLogins = response.data.logins; + } else { + $scope.sshLogins = []; + } + }, function (err) { + $scope.loadingSSHLogins = false; + $scope.errorSSHLogins = 'Failed to load SSH logins.'; + }); + }; + // SSH Logs $scope.sshLogs = []; $scope.loadingSSHLogs = true; $scope.errorSSHLogs = ''; - function fetchSSHLogs() { + $scope.refreshSSHLogs = function() { $scope.loadingSSHLogs = true; $http.get('/base/getRecentSSHLogs').then(function (response) { $scope.loadingSSHLogs = false; @@ -892,35 +911,11 @@ app.controller('dashboardStatsController', function ($scope, $http, $timeout) { $scope.loadingSSHLogs = false; $scope.errorSSHLogs = 'Failed to load SSH logs.'; }); - } - fetchSSHLogs(); - setInterval(fetchSSHLogs, 10000); - - // SSH Logins - $scope.sshLogins = []; - $scope.loadingSSHLogins = true; - $scope.errorSSHLogins = ''; - function fetchSSHLogins() { - $scope.loadingSSHLogins = true; - $http.get('/base/getRecentSSHLogins').then(function (response) { - $scope.loadingSSHLogins = false; - if (response.data && response.data.logins) { - $scope.sshLogins = response.data.logins; - } else { - $scope.sshLogins = []; - } - }, function (error) { - $scope.loadingSSHLogins = false; - $scope.sshLogins = []; - $scope.errorSSHLogins = 'Failed to load SSH logins.'; - }); - } - fetchSSHLogins(); - var sshPoller = function() { - fetchSSHLogins(); - $timeout(sshPoller, 10000); }; - $timeout(sshPoller, 10000); + + // Initial fetch + $scope.refreshSSHLogins(); + $scope.refreshSSHLogs(); // Chart.js chart objects var trafficChart, diskIOChart, cpuChart; diff --git a/baseTemplate/templates/baseTemplate/homePage.html b/baseTemplate/templates/baseTemplate/homePage.html index 1a906562b..4b4fe449a 100755 --- a/baseTemplate/templates/baseTemplate/homePage.html +++ b/baseTemplate/templates/baseTemplate/homePage.html @@ -108,7 +108,7 @@ " > {$ totalSites $} - +
Total Sites -
- - - - + + + + + {$ totalWPSites $} - +
WordPress Sites -
- - - -
+ + + + + - - - + + + - + - {% if admin %} + {% if admin %}
@@ -312,41 +312,41 @@
{$ cpuUsage $}% -
-
-
-
-
-
-
+
+
+
+
+
+ +
{% trans "Ram Usage" %}
{$ ramUsage $}% -
-
-
-
-
-
-
+
+
+
+
+ + +
{% trans "Disk Usage '/'" %}
{$ diskUsage $}% -
-
-
+
+
+
+
+
+
+
- - - - {% endif %}
- + {% if admin %}
-
Recent SSH Logins
-
Loading recent SSH logins...
-
No recent SSH logins found.
-
- +
+
Recent SSH Logins
+ +
+
Loading...
+
{$ errorSSHLogins $}
+
No recent SSH logins found.
+
+
- - - - - - + + + + + + - - - - + + + - - + +
UserIPCountryDate/TimeSession
UserIPCountryDateSession
{$ login.user $}{$ login.ip $} + {$ login.country $} {$ login.country $} - - {$ login.date $}{$ login.session $}{$ login.date $}{$ login.session $}
-
-
Recent SSH Logs
-
Loading recent SSH logs...
-
{$ errorSSHLogs $}
-
No recent SSH logs found.
-
- +
+
+
Recent SSH Logs
+ +
+
Loading...
+
{$ errorSSHLogs $}
+
No recent SSH logs found.
+
+
- - - + + + - - - + + +
TimestampMessage
TimestampMessage
{$ log.timestamp $}{$ log.message $}
{$ log.timestamp $}{$ log.message $}
- {% endif %} + {% endif %} diff --git a/baseTemplate/views.py b/baseTemplate/views.py index 39709ee57..888c89c44 100755 --- a/baseTemplate/views.py +++ b/baseTemplate/views.py @@ -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)