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
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:
@ -13,22 +13,56 @@
|
|||||||
"ecmaVersion": "latest"
|
"ecmaVersion": "latest"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"indent": ["error", 2],
|
"indent": [
|
||||||
"linebreak-style": ["error", "unix"],
|
"error",
|
||||||
"quotes": ["error", "single"],
|
2
|
||||||
"semi": ["error", "always"],
|
],
|
||||||
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
"linebreak-style": [
|
||||||
|
"error",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"argsIgnorePattern": "^_"
|
||||||
|
}
|
||||||
|
],
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"eol-last": "error",
|
"eol-last": "error",
|
||||||
"comma-dangle": ["error", "never"],
|
"comma-dangle": [
|
||||||
"object-curly-spacing": ["error", "always"],
|
"error",
|
||||||
"array-bracket-spacing": ["error", "never"],
|
"never"
|
||||||
"space-before-function-paren": ["error", "never"],
|
],
|
||||||
|
"object-curly-spacing": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
],
|
||||||
|
"array-bracket-spacing": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
|
"space-before-function-paren": [
|
||||||
|
"error",
|
||||||
|
"never"
|
||||||
|
],
|
||||||
"keyword-spacing": "error",
|
"keyword-spacing": "error",
|
||||||
"space-infix-ops": "error",
|
"space-infix-ops": "error",
|
||||||
"no-multiple-empty-lines": ["error", { "max": 2 }],
|
"no-multiple-empty-lines": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"max": 2
|
||||||
|
}
|
||||||
|
],
|
||||||
"prefer-const": "error",
|
"prefer-const": "error",
|
||||||
"no-var": "error"
|
"no-var": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
10
package.json
10
package.json
@ -12,7 +12,13 @@
|
|||||||
"lint": "eslint src/ tests/",
|
"lint": "eslint src/ tests/",
|
||||||
"lint:fix": "eslint src/ tests/ --fix"
|
"lint:fix": "eslint src/ tests/ --fix"
|
||||||
},
|
},
|
||||||
"keywords": ["monitoring", "dashboard", "nodejs", "cicd", "harbor"],
|
"keywords": [
|
||||||
|
"monitoring",
|
||||||
|
"dashboard",
|
||||||
|
"nodejs",
|
||||||
|
"cicd",
|
||||||
|
"harbor"
|
||||||
|
],
|
||||||
"author": "Your Name",
|
"author": "Your Name",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -44,4 +50,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,7 +15,7 @@ function logger(req, res, next) {
|
|||||||
|
|
||||||
// Override res.end to capture response time and status
|
// Override res.end to capture response time and status
|
||||||
const originalEnd = res.end;
|
const originalEnd = res.end;
|
||||||
res.end = function(chunk, encoding) {
|
res.end = function (chunk, encoding) {
|
||||||
const responseTime = Date.now() - startTime;
|
const responseTime = Date.now() - startTime;
|
||||||
|
|
||||||
// Record response time histogram
|
// Record response time histogram
|
||||||
|
|||||||
@ -399,7 +399,7 @@ async function downloadMetrics() {
|
|||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
const dataStr = JSON.stringify(result.data, null, 2);
|
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 url = URL.createObjectURL(dataBlob);
|
||||||
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>System Monitoring Dashboard</title>
|
<title>System Monitoring Dashboard</title>
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<h1>🖥️ System Monitoring Dashboard</h1>
|
<h1>🖥️ System Monitoring Dashboard</h1>
|
||||||
@ -78,4 +80,5 @@
|
|||||||
|
|
||||||
<script src="app.js"></script>
|
<script src="app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -70,8 +70,15 @@ header p {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse {
|
@keyframes pulse {
|
||||||
0%, 100% { opacity: 1; }
|
|
||||||
50% { opacity: 0.5; }
|
0%,
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
50% {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -109,12 +116,17 @@ main {
|
|||||||
padding-bottom: 0.5rem;
|
padding-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metric-grid, .health-grid, .process-grid, .metrics-grid {
|
.metric-grid,
|
||||||
|
.health-grid,
|
||||||
|
.process-grid,
|
||||||
|
.metrics-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metric-item, .health-item, .process-item {
|
.metric-item,
|
||||||
|
.health-item,
|
||||||
|
.process-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -124,12 +136,16 @@ main {
|
|||||||
border-left: 4px solid #3b82f6;
|
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;
|
color: #374151;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metric-value, .health-value, .process-value {
|
.metric-value,
|
||||||
|
.health-value,
|
||||||
|
.process-value {
|
||||||
color: #6b7280;
|
color: #6b7280;
|
||||||
font-family: 'Courier New', monospace;
|
font-family: 'Courier New', monospace;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
|||||||
@ -6,10 +6,10 @@ const metrics = {
|
|||||||
gauges: {},
|
gauges: {},
|
||||||
histograms: {},
|
histograms: {},
|
||||||
startTime: Date.now()
|
startTime: Date.now()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Increment a counter
|
// Increment a counter
|
||||||
function incrementCounter(name, labels = {}) {
|
function incrementCounter(name, labels = {}) {
|
||||||
const key = `${name}_${JSON.stringify(labels)}`;
|
const key = `${name}_${JSON.stringify(labels)}`;
|
||||||
if (!metrics.counters[key]) {
|
if (!metrics.counters[key]) {
|
||||||
metrics.counters[key] = {
|
metrics.counters[key] = {
|
||||||
@ -19,10 +19,10 @@ const metrics = {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
metrics.counters[key].value++;
|
metrics.counters[key].value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a gauge value
|
// Set a gauge value
|
||||||
function setGauge(name, value, labels = {}) {
|
function setGauge(name, value, labels = {}) {
|
||||||
const key = `${name}_${JSON.stringify(labels)}`;
|
const key = `${name}_${JSON.stringify(labels)}`;
|
||||||
metrics.gauges[key] = {
|
metrics.gauges[key] = {
|
||||||
name,
|
name,
|
||||||
@ -30,10 +30,10 @@ const metrics = {
|
|||||||
value,
|
value,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record histogram value (simplified)
|
// Record histogram value (simplified)
|
||||||
function recordHistogram(name, value, labels = {}) {
|
function recordHistogram(name, value, labels = {}) {
|
||||||
const key = `${name}_${JSON.stringify(labels)}`;
|
const key = `${name}_${JSON.stringify(labels)}`;
|
||||||
if (!metrics.histograms[key]) {
|
if (!metrics.histograms[key]) {
|
||||||
metrics.histograms[key] = {
|
metrics.histograms[key] = {
|
||||||
@ -54,10 +54,10 @@ const metrics = {
|
|||||||
if (histogram.values.length > 1000) {
|
if (histogram.values.length > 1000) {
|
||||||
histogram.values = histogram.values.slice(-1000);
|
histogram.values = histogram.values.slice(-1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all metrics
|
// Get all metrics
|
||||||
function getMetrics() {
|
function getMetrics() {
|
||||||
const runtime = {
|
const runtime = {
|
||||||
uptime_seconds: Math.round((Date.now() - metrics.startTime) / 1000),
|
uptime_seconds: Math.round((Date.now() - metrics.startTime) / 1000),
|
||||||
memory_usage_bytes: process.memoryUsage(),
|
memory_usage_bytes: process.memoryUsage(),
|
||||||
@ -76,20 +76,20 @@ const metrics = {
|
|||||||
runtime,
|
runtime,
|
||||||
timestamp: new Date().toISOString()
|
timestamp: new Date().toISOString()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset all metrics
|
// Reset all metrics
|
||||||
function resetMetrics() {
|
function resetMetrics() {
|
||||||
metrics.counters = {};
|
metrics.counters = {};
|
||||||
metrics.gauges = {};
|
metrics.gauges = {};
|
||||||
metrics.histograms = {};
|
metrics.histograms = {};
|
||||||
metrics.startTime = Date.now();
|
metrics.startTime = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
incrementCounter,
|
incrementCounter,
|
||||||
setGauge,
|
setGauge,
|
||||||
recordHistogram,
|
recordHistogram,
|
||||||
getMetrics,
|
getMetrics,
|
||||||
resetMetrics
|
resetMetrics
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user