mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 13:06:01 +00:00
39 lines
989 B
JavaScript
39 lines
989 B
JavaScript
const os = require('os');
|
|
|
|
const databaseConnections = require('../controllers/databaseConnections');
|
|
const serverConnections = require('../controllers/serverConnections');
|
|
const sessions = require('../controllers/sessions');
|
|
const runners = require('../controllers/runners');
|
|
|
|
async function getHealthStatus() {
|
|
const memory = process.memoryUsage();
|
|
const cpuUsage = process.cpuUsage();
|
|
|
|
return {
|
|
status: 'ok',
|
|
databaseConnectionCount: databaseConnections.opened.length,
|
|
serverConnectionCount: serverConnections.opened.length,
|
|
sessionCount: sessions.opened.length,
|
|
runProcessCount: runners.opened.length,
|
|
memory,
|
|
cpuUsage,
|
|
systemMemory: {
|
|
total: os.totalmem(),
|
|
free: os.freemem(),
|
|
},
|
|
};
|
|
}
|
|
|
|
async function getHealthStatusSprinx() {
|
|
return {
|
|
overallStatus: 'OK',
|
|
timeStamp: new Date().toISOString(),
|
|
timeStampUnix: Math.floor(Date.now() / 1000),
|
|
};
|
|
}
|
|
|
|
module.exports = {
|
|
getHealthStatus,
|
|
getHealthStatusSprinx,
|
|
};
|