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

+ +
+ +
+

Database Status

+ +
+ +
+

CPU Usage

+ +
+ +
+

Memory Usage

+ +
+ +
+

Network Latency

+ +
+
+ \ No newline at end of file diff --git a/Sean/views/style.css b/Sean/views/style.css index 24a92d6..ed60bbf 100644 --- a/Sean/views/style.css +++ b/Sean/views/style.css @@ -635,4 +635,41 @@ footer { /* Add any other specific styles for this form */ .custom-location-form h3 { color: #333; /* Customize the heading color */ + } + section { + margin-top: 20px; + display: flex; /* Use flexbox to arrange items in a row */ + justify-content: space-between; /* Distribute items evenly along the main axis */ + } + + .health-container { + width: 200px; /* Set a fixed width for square shape */ + height: 200px; /* Set a fixed height for square shape */ + background-color: #f0f0f0; /* Background color */ + border: 1px solid #ddd; + padding: 10px; + border-radius: 10px; /* Rounded corners */ + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Box shadow for depth */ + transition: transform 0.3s ease-in-out; /* Add a subtle transition effect */ + } + + .health-container:hover { + transform: scale(1.05); /* Scale up on hover */ + } + + .health-container h4 { + text-align: center; + color: #333; /* Heading color */ + } + + .health-container ul { + list-style: none; + margin: 0; + padding: 0; + text-align: center; + } + + .health-container li { + margin: 5px 0; + color: #555; /* Text color */ } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a9262a9..c16397c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2100,6 +2100,11 @@ "wrappy": "1" } }, + "os": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz", + "integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ==" + }, "otp-generator": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/otp-generator/-/otp-generator-4.0.1.tgz", @@ -2203,6 +2208,14 @@ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", "dev": true }, + "pidusage": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/pidusage/-/pidusage-3.0.2.tgz", + "integrity": "sha512-g0VU+y08pKw5M8EZ2rIGiEBaB8wrQMjYGFfW2QVIfyT8V+fq8YFLkvlz4bz5ljvFDJYNFCWT3PWqcRr2FKO81w==", + "requires": { + "safe-buffer": "^5.2.1" + } + }, "pngjs": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", diff --git a/package.json b/package.json index 08a7029..d263301 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,10 @@ "mysql2": "^3.7.1", "node-fetch": "^3.3.2", "nodemailer": "^6.9.8", + "os": "^0.1.2", "otp-generator": "^4.0.1", "otplib": "^12.0.1", + "pidusage": "^3.0.2", "qrcode": "^1.5.3", "sanitize-html": "^2.11.0", "sequelize": "^6.35.2",