Updated lint errors
Some checks failed
CI/CD Pipeline - Build, Test, and Deploy / 🧪 Test & Lint (push) Failing after 4m51s
CI/CD Pipeline - Build, Test, and Deploy / 🔒 Security Scan (push) Successful in 9m31s
CI/CD Pipeline - Build, Test, and Deploy / 🏗️ Build & Push Image (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🛡️ Image Security Scan (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🚀 Deploy to Development (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🏭 Deploy to Production (push) Has been skipped
CI/CD Pipeline - Build, Test, and Deploy / 🧹 Cleanup (push) Successful in 1s

This commit is contained in:
2025-07-02 16:01:38 -06:00
parent daf3dbe0ef
commit 9a23c1c05b
10 changed files with 731 additions and 672 deletions

View File

@ -13,22 +13,56 @@
"ecmaVersion": "latest"
},
"rules": {
"indent": ["error", 2],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "always"],
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_"
}
],
"no-console": "off",
"no-trailing-spaces": "error",
"eol-last": "error",
"comma-dangle": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"array-bracket-spacing": ["error", "never"],
"space-before-function-paren": ["error", "never"],
"comma-dangle": [
"error",
"never"
],
"object-curly-spacing": [
"error",
"always"
],
"array-bracket-spacing": [
"error",
"never"
],
"space-before-function-paren": [
"error",
"never"
],
"keyword-spacing": "error",
"space-infix-ops": "error",
"no-multiple-empty-lines": ["error", { "max": 2 }],
"no-multiple-empty-lines": [
"error",
{
"max": 2
}
],
"prefer-const": "error",
"no-var": "error"
}
}
}

View File

@ -12,7 +12,13 @@
"lint": "eslint src/ tests/",
"lint:fix": "eslint src/ tests/ --fix"
},
"keywords": ["monitoring", "dashboard", "nodejs", "cicd", "harbor"],
"keywords": [
"monitoring",
"dashboard",
"nodejs",
"cicd",
"harbor"
],
"author": "Your Name",
"license": "MIT",
"dependencies": {
@ -44,4 +50,4 @@
}
}
}
}
}

View File

@ -15,7 +15,7 @@ function logger(req, res, next) {
// Override res.end to capture response time and status
const originalEnd = res.end;
res.end = function(chunk, encoding) {
res.end = function (chunk, encoding) {
const responseTime = Date.now() - startTime;
// Record response time histogram

View File

@ -399,7 +399,7 @@ async function downloadMetrics() {
if (result.success) {
const dataStr = JSON.stringify(result.data, null, 2);
const dataBlob = new Blob([dataStr], {type: 'application/json'});
const dataBlob = new Blob([dataStr], { type: 'application/json' });
const url = URL.createObjectURL(dataBlob);
const link = document.createElement('a');

View File

@ -1,11 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>System Monitoring Dashboard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>🖥️ System Monitoring Dashboard</h1>
@ -78,4 +80,5 @@
<script src="app.js"></script>
</body>
</html>

View File

@ -70,8 +70,15 @@ header p {
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
main {
@ -109,12 +116,17 @@ main {
padding-bottom: 0.5rem;
}
.metric-grid, .health-grid, .process-grid, .metrics-grid {
.metric-grid,
.health-grid,
.process-grid,
.metrics-grid {
display: grid;
gap: 1rem;
}
.metric-item, .health-item, .process-item {
.metric-item,
.health-item,
.process-item {
display: flex;
justify-content: space-between;
align-items: center;
@ -124,12 +136,16 @@ main {
border-left: 4px solid #3b82f6;
}
.metric-item strong, .health-item strong, .process-item strong {
.metric-item strong,
.health-item strong,
.process-item strong {
color: #374151;
font-weight: 600;
}
.metric-value, .health-value, .process-value {
.metric-value,
.health-value,
.process-value {
color: #6b7280;
font-family: 'Courier New', monospace;
font-weight: 500;

View File

@ -6,10 +6,10 @@ const metrics = {
gauges: {},
histograms: {},
startTime: Date.now()
};
};
// Increment a counter
function incrementCounter(name, labels = {}) {
// Increment a counter
function incrementCounter(name, labels = {}) {
const key = `${name}_${JSON.stringify(labels)}`;
if (!metrics.counters[key]) {
metrics.counters[key] = {
@ -19,10 +19,10 @@ const metrics = {
};
}
metrics.counters[key].value++;
}
}
// Set a gauge value
function setGauge(name, value, labels = {}) {
// Set a gauge value
function setGauge(name, value, labels = {}) {
const key = `${name}_${JSON.stringify(labels)}`;
metrics.gauges[key] = {
name,
@ -30,10 +30,10 @@ const metrics = {
value,
timestamp: Date.now()
};
}
}
// Record histogram value (simplified)
function recordHistogram(name, value, labels = {}) {
// Record histogram value (simplified)
function recordHistogram(name, value, labels = {}) {
const key = `${name}_${JSON.stringify(labels)}`;
if (!metrics.histograms[key]) {
metrics.histograms[key] = {
@ -54,10 +54,10 @@ const metrics = {
if (histogram.values.length > 1000) {
histogram.values = histogram.values.slice(-1000);
}
}
}
// Get all metrics
function getMetrics() {
// Get all metrics
function getMetrics() {
const runtime = {
uptime_seconds: Math.round((Date.now() - metrics.startTime) / 1000),
memory_usage_bytes: process.memoryUsage(),
@ -76,20 +76,20 @@ const metrics = {
runtime,
timestamp: new Date().toISOString()
};
}
}
// Reset all metrics
function resetMetrics() {
// Reset all metrics
function resetMetrics() {
metrics.counters = {};
metrics.gauges = {};
metrics.histograms = {};
metrics.startTime = Date.now();
}
}
module.exports = {
module.exports = {
incrementCounter,
setGauge,
recordHistogram,
getMetrics,
resetMetrics
};
};