diff --git a/Sean/server.js b/Sean/server.js
index f8a6047..5c091d4 100644
--- a/Sean/server.js
+++ b/Sean/server.js
@@ -6,6 +6,7 @@ const bcrypt = require("bcrypt");
const crypto = require("crypto");
const validator = require('validator');
const axios = require('axios');
+const pidusage = require('pidusage');
const { validationResult } = require('express-validator');
const { locationValidation, locationValidationUpdate, locationdeleteValidation
@@ -197,17 +198,28 @@ app.post("/verify-otp", otpValidation ,async (req, res) => {
}
// Redirect to the login page after logout
- res.redirect("/login");
+ res.redirect("/index");
});
} catch (error) {
console.error("Error in logout route:", error);
res.status(500).send("Internal Server Error");
}
});
-
+ const getSystemHealth = async () => {
+ const cpuInfo = await pidusage(process.pid);
+ return {
+ serverStatus: { uptime: process.uptime() },
+ databaseStatus: { connected: true }, // Replace with actual logic
+ resourceUtilization: {
+ cpuUsage: cpuInfo.cpu,
+ memoryUsage: process.memoryUsage(),
+ },
+ networkHealth: { latency: 10 }, // Replace with actual logic
+ };
+ };
app.get("/home", isAuthenticated, async (req, res) => {
-
- res.render("home", { username: req.session.username});
+ const systemHealth = await getSystemHealth();
+ res.render("home", { username: req.session.username, systemHealth});
});
app.get("/inusers", isAuthenticated, async (req, res) => {
diff --git a/Sean/views/home.ejs b/Sean/views/home.ejs
index 4d3222d..65ed9e8 100644
--- a/Sean/views/home.ejs
+++ b/Sean/views/home.ejs
@@ -28,9 +28,46 @@
Welcome to the Home Page, <%= username %>!
+
+
+
Server Uptime
+
+ - Uptime: <%= systemHealth && systemHealth.serverStatus ? (systemHealth.serverStatus.uptime / 60).toFixed(2) : 'N/A' %> minutes
+
+
+
+
+
Database Status
+
+ - Status: <%= systemHealth && systemHealth.databaseStatus ? (systemHealth.databaseStatus.connected ? 'Connected' : 'Disconnected') : 'N/A' %>
+
+
+
+
+
CPU Usage
+
+ - Usage: <%= systemHealth && systemHealth.resourceUtilization ? systemHealth.resourceUtilization.cpuUsage.toFixed(2) : 'N/A' %> %
+
+
+
+
+
Memory Usage
+
+ - Usage: <%= systemHealth && systemHealth.resourceUtilization ? (systemHealth.resourceUtilization.memoryUsage.rss / (1024 * 1024)).toFixed(2) : 'N/A' %> MB
+
+
+
+
+
Network Latency
+
+ - Latency: <%= systemHealth && systemHealth.networkHealth ? systemHealth.networkHealth.latency : 'N/A' %> ms
+
+
+
+