bug fix: topProcessesStatus

This commit is contained in:
Usman Nasir
2020-05-02 17:51:01 +05:00
parent 874720fbfe
commit c1f5600018
9 changed files with 181 additions and 53 deletions

View File

@@ -812,6 +812,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
if (response.data.status === 1) { if (response.data.status === 1) {
$scope.allPackages = JSON.parse(response.data.packages); $scope.allPackages = JSON.parse(response.data.packages);
$scope.pagination = response.data.pagination; $scope.pagination = response.data.pagination;
$scope.fetchedPackages = response.data.fetchedPackages;
$scope.totalPackages = response.data.totalPackages;
} else { } else {
new PNotify({ new PNotify({
title: 'Error!', title: 'Error!',

View File

@@ -33,6 +33,12 @@
<p>Howdy, I'm in Section 4.</p> <p>Howdy, I'm in Section 4.</p>
</div> </div>
<div class="tab-pane" id="tab6"> <div class="tab-pane" id="tab6">
<a style="float: left ; margin-bottom: 2%"
class="btn btn-border btn-alt border-azure btn-link font-azure" href="#"
title=""><span>Total Packages: {$ totalPackages $}</span></a>
<a style="float: left; margin-bottom: 2%; margin-left: 2%"
class="btn btn-border btn-alt border-blue-alt btn-link font-blue-alt" href="#"
title=""><span>Fetched Packages: {$ fetchedPackages $}</span></a>
<div class="col-sm-10" <div class="col-sm-10"
style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%"> style="padding: 0px; box-shadow: 0px 0px 1px 0px #888888; margin-bottom: 2%">
<input placeholder="Search..." <input placeholder="Search..."
@@ -46,6 +52,7 @@
<option>10</option> <option>10</option>
<option>50</option> <option>50</option>
<option>100</option> <option>100</option>
<option>500</option>
</select> </select>
</div> </div>
</div> </div>

View File

@@ -579,17 +579,45 @@ def topProcessesStatus(request):
data['Softirqs'] = loadNow[13] + '%' data['Softirqs'] = loadNow[13] + '%'
## Memory ## Memory
data['totalMemory'] = str(int(float(memory[3]) / 1024)) + 'MB'
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB' if memory[3].find('+') > -1:
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB' memoryFinal = memory[3].split('+')[0]
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB' else:
memoryFinal = memory[3]
data['totalMemory'] = str(int(float(memoryFinal) / 1024)) + 'MB'
##
if memory[5].find('free') > -1:
data['freeMemory'] = str(int(float(memory[4]) / 1024)) + 'MB'
else:
data['freeMemory'] = str(int(float(memory[5]) / 1024)) + 'MB'
##
if memory[7].find('used') > -1:
data['usedMemory'] = str(int(float(memory[6]) / 1024)) + 'MB'
else:
data['usedMemory'] = str(int(float(memory[7]) / 1024)) + 'MB'
if memory[9].find('buff') > -1:
data['buffCache'] = str(int(float(memory[8]) / 1024)) + 'MB'
else:
data['buffCache'] = str(int(float(memory[9]) / 1024)) + 'MB'
## Swap ## Swap
data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB' data['swapTotalMemory'] = str(int(float(swap[2]) / 1024)) + 'MB'
data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB' data['swapFreeMemory'] = str(int(float(swap[4]) / 1024)) + 'MB'
data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB' data['swapUsedMemory'] = str(int(float(swap[6]) / 1024)) + 'MB'
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
if swap[8].find('+') > -1:
finalBuffCache = swap[8].split('+')[0]
data['swapBuffCache'] = str(int(float(finalBuffCache) / 1024)) + 'MB'
else:
data['swapBuffCache'] = str(int(float(swap[8]) / 1024)) + 'MB'
## Processes ## Processes
@@ -686,7 +714,7 @@ def fetchPackages(request):
return ACLManager.loadError() return ACLManager.loadError()
data = json.loads(request.body) data = json.loads(request.body)
page = int(data['page'].rstrip('\n')) page = int(str(data['page']).rstrip('\n'))
recordsToShow = int(data['recordsToShow']) recordsToShow = int(data['recordsToShow'])
packageInformation = '/home/cyberpanel/OSPackages' packageInformation = '/home/cyberpanel/OSPackages'
@@ -704,12 +732,12 @@ def fetchPackages(request):
from s3Backups.s3Backups import S3Backups from s3Backups.s3Backups import S3Backups
pagination = S3Backups.getPagination(len(packages), recordsToShow) pagination = S3Backups.getPagination(len(packages), recordsToShow)
logging.CyberCPLogFileWriter.writeToFile(str(pagination))
endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow) endPageNumber, finalPageNumber = S3Backups.recordsPointer(page, recordsToShow)
finalPackages = packages[finalPageNumber:endPageNumber] finalPackages = packages[finalPageNumber:endPageNumber]
json_data = "[" json_data = "["
checker = 0 checker = 0
counter = 0
# if os.path.exists(ProcessUtilities.debugPath): # if os.path.exists(ProcessUtilities.debugPath):
# logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages))) # logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
@@ -717,6 +745,7 @@ def fetchPackages(request):
for items in finalPackages: for items in finalPackages:
items = re.sub(r'("[\s\w]*)"([\s\w])*"([\s\w]*)',r"\1\2\3", items) items = re.sub(r'("[\s\w]*)"([\s\w])*"([\s\w]*)',r"\1\2\3", items)
try: try:
counter = counter + 1
if checker == 0: if checker == 0:
json_data = json_data + items json_data = json_data + items
checker = 1 checker = 1
@@ -727,7 +756,7 @@ def fetchPackages(request):
json_data = json_data + ']' json_data = json_data + ']'
data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination} data_ret = {'status': 1, 'packages': json_data, 'pagination': pagination, 'fetchedPackages': counter, 'totalPackages': len(packages)}
json_data = json.dumps(data_ret) json_data = json.dumps(data_ret)
return HttpResponse(json_data) return HttpResponse(json_data)

4
static/databases/databases.js Executable file → Normal file
View File

@@ -106,7 +106,7 @@ app.controller('createDatabase', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.dbPassword = randomPassword(12); $scope.dbPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {
@@ -447,7 +447,7 @@ app.controller('listDBs', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.dbPassword = randomPassword(12); $scope.dbPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {

View File

@@ -113,7 +113,7 @@ app.controller('createFTPAccount', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.ftpPassword = randomPassword(12); $scope.ftpPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {
@@ -451,7 +451,7 @@ app.controller('listFTPAccounts', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.ftpPassword = randomPassword(12); $scope.ftpPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {

View File

@@ -110,7 +110,7 @@ app.controller('createEmailAccount', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.emailPassword = randomPassword(12); $scope.emailPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {
@@ -465,7 +465,7 @@ app.controller('changeEmailPassword', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.emailPassword = randomPassword(12); $scope.emailPassword = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {

View File

@@ -3,7 +3,6 @@
*/ */
/* Java script code to start/stop litespeed */ /* Java script code to start/stop litespeed */
app.controller('litespeedStatus', function ($scope, $http) { app.controller('litespeedStatus', function ($scope, $http) {
@@ -49,8 +48,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
$scope.actionResultBad = true; $scope.actionResultBad = true;
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} } else {
else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -109,8 +107,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
$scope.actionResultBad = true; $scope.actionResultBad = true;
$scope.serverStatusCouldNotConnect = true; $scope.serverStatusCouldNotConnect = true;
} } else {
else {
$scope.restartorStopLoading = true; $scope.restartorStopLoading = true;
$scope.actionResult = true; $scope.actionResult = true;
@@ -174,8 +171,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
}); });
$scope.lsSerial = response.data.lsSerial; $scope.lsSerial = response.data.lsSerial;
$scope.lsexpiration = response.data.lsexpiration; $scope.lsexpiration = response.data.lsexpiration;
} } else {
else {
$scope.cpLoading = true; $scope.cpLoading = true;
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',
@@ -229,8 +225,7 @@ app.controller('litespeedStatus', function ($scope, $http) {
text: 'License successfully Updated', text: 'License successfully Updated',
type: 'success' type: 'success'
}); });
} } else {
else {
$scope.cpLoading = true; $scope.cpLoading = true;
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',
@@ -292,8 +287,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} } else {
else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -347,8 +341,7 @@ app.controller('readCyberCPLogFile', function ($scope, $http) {
$scope.logsData = response.data.logsdata; $scope.logsData = response.data.logsdata;
} } else {
else {
$scope.logFileLoading = true; $scope.logFileLoading = true;
$scope.logsFeteched = true; $scope.logsFeteched = true;
@@ -409,8 +402,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.olsStart = false; $scope.olsStart = false;
$scope.olsStop = true; $scope.olsStop = true;
$scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB"; $scope.olsMem = Math.round(parseInt(response.data.memUsage.litespeed) / 1048576) + " MB";
} } else {
else {
$scope.olsStatus = "Stopped"; $scope.olsStatus = "Stopped";
$scope.olsStats = false; $scope.olsStats = false;
$scope.olsStart = true; $scope.olsStart = true;
@@ -421,8 +413,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.dockerStatus = "Running"; $scope.dockerStatus = "Running";
$scope.dockerStart = false; $scope.dockerStart = false;
$scope.dockerStop = true; $scope.dockerStop = true;
} } else {
else {
$scope.dockerStatus = "Stopped"; $scope.dockerStatus = "Stopped";
$scope.dockerStart = true; $scope.dockerStart = true;
$scope.dockerStop = false; $scope.dockerStop = false;
@@ -435,8 +426,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.sqlStart = false; $scope.sqlStart = false;
$scope.sqlStop = true; $scope.sqlStop = true;
$scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB"; $scope.sqlMem = Math.round(parseInt(response.data.memUsage.mysql) / 1048576) + " MB";
} } else {
else {
$scope.sqlStatus = "Stopped"; $scope.sqlStatus = "Stopped";
$scope.sqlStats = false; $scope.sqlStats = false;
$scope.sqlStart = true; $scope.sqlStart = true;
@@ -451,8 +441,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.dnsStart = false; $scope.dnsStart = false;
$scope.dnsStop = true; $scope.dnsStop = true;
$scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB"; $scope.dnsMem = Math.round(parseInt(response.data.memUsage.powerdns) / 1048576) + " MB";
} } else {
else {
$scope.dnsStatus = "Stopped"; $scope.dnsStatus = "Stopped";
$scope.dnsStats = false; $scope.dnsStats = false;
$scope.dnsStart = true; $scope.dnsStart = true;
@@ -467,8 +456,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.ftpStart = false; $scope.ftpStart = false;
$scope.ftpStop = true; $scope.ftpStop = true;
$scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB"; $scope.ftpMem = Math.round(parseInt(response.data.memUsage.pureftp) / 1048576) + " MB";
} } else {
else {
$scope.ftpStatus = "Stopped"; $scope.ftpStatus = "Stopped";
$scope.ftpStats = false; $scope.ftpStats = false;
$scope.ftpStart = true; $scope.ftpStart = true;
@@ -487,6 +475,7 @@ app.controller('servicesManager', function ($scope, $http) {
} }
} }
getServiceStatus(); getServiceStatus();
$scope.serviceAction = function (serviceName, action) { $scope.serviceAction = function (serviceName, action) {
@@ -524,8 +513,7 @@ app.controller('servicesManager', function ($scope, $http) {
$scope.actionLoader = false; $scope.actionLoader = false;
$scope.btnDisable = false; $scope.btnDisable = false;
}, 3000); }, 3000);
} } else {
else {
setTimeout(function () { setTimeout(function () {
getServiceStatus(); getServiceStatus();
$scope.ActionSuccessfull = false; $scope.ActionSuccessfull = false;
@@ -583,8 +571,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
if (response.data.status === 1) { if (response.data.status === 1) {
$scope.installBoxGen = false; $scope.installBoxGen = false;
getRequestStatus(); getRequestStatus();
} } else {
else {
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',
text: response.data.error_message, text: response.data.error_message,
@@ -626,8 +613,7 @@ app.controller('lswsSwitch', function ($scope, $http, $timeout, $window) {
if (response.data.abort === 0) { if (response.data.abort === 0) {
$scope.requestData = response.data.requestStatus; $scope.requestData = response.data.requestStatus;
$timeout(getRequestStatus, 1000); $timeout(getRequestStatus, 1000);
} } else {
else {
// Notifications // Notifications
$scope.cyberPanelLoading = true; $scope.cyberPanelLoading = true;
$timeout.cancel(); $timeout.cancel();
@@ -720,8 +706,7 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
$scope.zombieProcesses = response.data.zombieProcesses; $scope.zombieProcesses = response.data.zombieProcesses;
$timeout($scope.topProcessesStatus, 3000); $timeout($scope.topProcessesStatus, 3000);
} } else {
else {
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',
text: response.data.error_message, text: response.data.error_message,
@@ -771,8 +756,113 @@ app.controller('topProcesses', function ($scope, $http, $timeout) {
text: 'Process successfully killed.', text: 'Process successfully killed.',
type: 'success' type: 'success'
}); });
} } else {
else { new PNotify({
title: 'Operation Failed!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialDatas(response) {
$scope.cyberPanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
});
///
app.controller('listOSPackages', function ($scope, $http, $timeout) {
$scope.cyberpanelLoading = true;
$scope.currentPage = 1;
$scope.recordsToShow = 10;
$scope.fetchPackages = function () {
$scope.cyberpanelLoading = false;
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
var data = {
page: $scope.currentPage,
recordsToShow: $scope.recordsToShow
};
dataurl = "/serverstatus/fetchPackages";
$http.post(dataurl, data, config).then(ListInitialData, cantLoadInitialData);
function ListInitialData(response) {
$scope.cyberpanelLoading = true;
if (response.data.status === 1) {
$scope.allPackages = JSON.parse(response.data.packages);
$scope.pagination = response.data.pagination;
$scope.fetchedPackages = response.data.fetchedPackages;
$scope.totalPackages = response.data.totalPackages;
} else {
new PNotify({
title: 'Error!',
text: response.data.error_message,
type: 'error'
});
}
}
function cantLoadInitialData(response) {
$scope.cyberpanelLoading = true;
new PNotify({
title: 'Operation Failed!',
text: 'Could not connect to server, please refresh this page',
type: 'error'
});
}
};
$scope.killProcess = function (pid) {
$scope.cyberPanelLoading = false;
url = "/serverstatus/killProcess";
var data = {
pid: pid
};
var config = {
headers: {
'X-CSRFToken': getCookie('csrftoken')
}
};
$http.post(url, data, config).then(ListInitialDatas, cantLoadInitialDatas);
function ListInitialDatas(response) {
$scope.cyberPanelLoading = true;
if (response.data.status === 1) {
new PNotify({
title: 'Success',
text: 'Process successfully killed.',
type: 'success'
});
} else {
new PNotify({ new PNotify({
title: 'Operation Failed!', title: 'Operation Failed!',
text: response.data.error_message, text: response.data.error_message,

View File

@@ -113,7 +113,7 @@ app.controller('createUserCtr', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.password = randomPassword(12); $scope.password = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {
@@ -342,7 +342,7 @@ app.controller('modifyUser', function ($scope, $http) {
$scope.generatePassword = function () { $scope.generatePassword = function () {
$scope.generatedPasswordView = false; $scope.generatedPasswordView = false;
$scope.password = randomPassword(12); $scope.password = randomPassword(16);
}; };
$scope.usePassword = function () { $scope.usePassword = function () {

View File

@@ -1 +1 @@
{"version":"2.0","build":0} {"version":"2.0","build":1}