update with server info
This commit is contained in:
@ -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) => {
|
||||
|
@ -28,9 +28,46 @@
|
||||
<main>
|
||||
<h2>Welcome to the Home Page, <%= username %>!</h2>
|
||||
</main>
|
||||
<section>
|
||||
<div class="health-container">
|
||||
<h4>Server Uptime</h4>
|
||||
<ul>
|
||||
<li><strong>Uptime:</strong> <span id="serverUptime"><%= systemHealth && systemHealth.serverStatus ? (systemHealth.serverStatus.uptime / 60).toFixed(2) : 'N/A' %> minutes</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="health-container">
|
||||
<h4>Database Status</h4>
|
||||
<ul>
|
||||
<li><strong>Status:</strong> <%= systemHealth && systemHealth.databaseStatus ? (systemHealth.databaseStatus.connected ? 'Connected' : 'Disconnected') : 'N/A' %></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="health-container">
|
||||
<h4>CPU Usage</h4>
|
||||
<ul>
|
||||
<li><strong>Usage:</strong> <span id="cpuUsage"><%= systemHealth && systemHealth.resourceUtilization ? systemHealth.resourceUtilization.cpuUsage.toFixed(2) : 'N/A' %> %</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="health-container">
|
||||
<h4>Memory Usage</h4>
|
||||
<ul>
|
||||
<li><strong>Usage:</strong> <%= systemHealth && systemHealth.resourceUtilization ? (systemHealth.resourceUtilization.memoryUsage.rss / (1024 * 1024)).toFixed(2) : 'N/A' %> MB</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="health-container">
|
||||
<h4>Network Latency</h4>
|
||||
<ul>
|
||||
<li><strong>Latency:</strong> <%= systemHealth && systemHealth.networkHealth ? systemHealth.networkHealth.latency : 'N/A' %> ms</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
<footer>
|
||||
Any Issue faced, Please contact the administrator at 11111111 or ecosaverAdmin@gmail.com
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -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 */
|
||||
}
|
Reference in New Issue
Block a user