Spaces:
Paused
Paused
Update app.js
Browse files
app.js
CHANGED
|
@@ -1,47 +1,114 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
const index = fs.readFileSync("./index.html");
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
});
|
| 22 |
-
childs.push(child);
|
| 23 |
}
|
| 24 |
-
|
| 25 |
-
setInterval(() => {
|
| 26 |
-
for (let child of childs) {
|
| 27 |
-
child.send(requests);
|
| 28 |
-
}
|
| 29 |
-
requests = 0;
|
| 30 |
-
}, 1000);
|
| 31 |
-
} else {
|
| 32 |
-
console.log(`Worker ${process.pid} started`);
|
| 33 |
-
|
| 34 |
-
const handler = function (req, res) {
|
| 35 |
-
if (req.url == "/dstat") {
|
| 36 |
-
process.send(0);
|
| 37 |
-
res.end();
|
| 38 |
-
} else {
|
| 39 |
-
res.end(index);
|
| 40 |
-
}
|
| 41 |
-
};
|
| 42 |
-
|
| 43 |
-
// Create the HTTP server
|
| 44 |
-
http.createServer(handler).listen(port, () => {
|
| 45 |
-
console.log(`Worker ${process.pid} listening on port ${port}`);
|
| 46 |
-
});
|
| 47 |
-
}
|
|
|
|
| 1 |
+
$(function () {
|
| 2 |
+
var mychart;
|
| 3 |
+
var previous = null;
|
| 4 |
+
var count = 0;
|
| 5 |
+
$(window).load(function () {
|
| 6 |
+
initiateChart("container");
|
| 7 |
+
parseFile();
|
| 8 |
+
});
|
|
|
|
| 9 |
|
| 10 |
+
function parseFile() {
|
| 11 |
+
// actually skidded from vshield, gonna recode it
|
| 12 |
+
$.ajax({
|
| 13 |
+
url: "/nginx_status",
|
| 14 |
+
dataType: "text",
|
| 15 |
+
cache: false,
|
| 16 |
+
})
|
| 17 |
+
.done(function (data) {
|
| 18 |
+
var current = 0;
|
| 19 |
+
var part = data.split(" ")[9];
|
| 20 |
+
var series = mychart.series[0],
|
| 21 |
+
current = parseInt(part);
|
| 22 |
+
shift = series.data.length > 40;
|
| 23 |
+
if (previous !== null) {
|
| 24 |
+
series.addPoint(
|
| 25 |
+
[Math.floor($.now()), current - previous],
|
| 26 |
+
true,
|
| 27 |
+
shift
|
| 28 |
+
);
|
| 29 |
+
}
|
| 30 |
+
previous = current;
|
| 31 |
+
count++;
|
| 32 |
+
// call it again after one second
|
| 33 |
+
setTimeout(parseFile, 1000);
|
| 34 |
+
})
|
| 35 |
+
.fail(function (jqXHR, textStatus, errorThrown) {
|
| 36 |
+
console.log(errorThrown);
|
| 37 |
+
});
|
| 38 |
+
}
|
| 39 |
|
| 40 |
+
function initiateChart(divid) {
|
| 41 |
+
mychart = Highcharts.chart("container", {
|
| 42 |
+
chart: {
|
| 43 |
+
type: "area",
|
| 44 |
+
backgroundColor: "#242222",
|
| 45 |
+
},
|
| 46 |
+
title: {
|
| 47 |
+
text: "@renzalwaysnt",
|
| 48 |
+
},
|
| 49 |
+
xAxis: {
|
| 50 |
+
type: "datetime",
|
| 51 |
+
dateTimeLabelFormats: {
|
| 52 |
+
day: "%a",
|
| 53 |
+
},
|
| 54 |
+
gridLineColor: "#7851a9",
|
| 55 |
+
labels: {
|
| 56 |
+
style: {
|
| 57 |
+
color: "#7851a9",
|
| 58 |
+
},
|
| 59 |
+
},
|
| 60 |
+
},
|
| 61 |
+
yAxis: {
|
| 62 |
+
allowDecimals: false,
|
| 63 |
+
labels: {
|
| 64 |
+
formatter: function () {
|
| 65 |
+
if (this.value > 1000) {
|
| 66 |
+
return this.value / 1000 + "k r/s";
|
| 67 |
+
} else {
|
| 68 |
+
return this.value + " r/s";
|
| 69 |
+
}
|
| 70 |
+
},
|
| 71 |
+
},
|
| 72 |
+
},
|
| 73 |
+
tooltip: {
|
| 74 |
+
pointFormat: "Requests: {point.y:,.0f}",
|
| 75 |
+
},
|
| 76 |
+
colors: [
|
| 77 |
+
{ linearGradient: [0, 0, 0, 0], stops: [[0, "rgba(120,81,169,1)"]] },
|
| 78 |
+
],
|
| 79 |
+
plotOptions: {
|
| 80 |
+
area: {
|
| 81 |
+
fillColor: {
|
| 82 |
+
linearGradient: {
|
| 83 |
+
x1: 0,
|
| 84 |
+
y1: 0,
|
| 85 |
+
x2: 0,
|
| 86 |
+
y2: 1,
|
| 87 |
+
},
|
| 88 |
+
stops: [
|
| 89 |
+
[0, "#7851a9"],
|
| 90 |
+
[1, new Highcharts.Color("#7851a9").setOpacity(0).get("rgba")],
|
| 91 |
+
],
|
| 92 |
+
},
|
| 93 |
+
pointStart: 1940,
|
| 94 |
+
marker: {
|
| 95 |
+
enabled: true,
|
| 96 |
+
symbol: "circle",
|
| 97 |
+
radius: 2,
|
| 98 |
+
states: {
|
| 99 |
+
hover: {
|
| 100 |
+
enabled: true,
|
| 101 |
+
},
|
| 102 |
+
},
|
| 103 |
+
},
|
| 104 |
+
},
|
| 105 |
+
},
|
| 106 |
+
series: [
|
| 107 |
+
{
|
| 108 |
+
name: "Requests",
|
| 109 |
+
data: [],
|
| 110 |
+
},
|
| 111 |
+
],
|
| 112 |
});
|
|
|
|
| 113 |
}
|
| 114 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|