-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
122 lines (105 loc) · 3.58 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<head>
<title>Nety</title>
</head>
<body>
<div class='row'>
<div class='realtime'>
<div id='up'>
<p class='name'>Up:</p>
<p id='up-value'>Loading…</p>
</div>
<div id='down'>
<p class='name'>Down:</p>
<p id='down-value'>Loading…</p>
</div>
</div>
<div id="chartDiv" class='chart'></div>
</div>
</body>
<script src="https://code.jscharting.com/latest/jscharting.js"></script>
<script>
const { networkStats } = require('systeminformation');
var upList = [];
var downList = [];
start();
async function start() {
setInterval(function () {
networkStats()
.then(response => {
if (response[0].tx_sec != -1) {
let up;
if (response[0].tx_sec >= 1000000000)
up = (response[0].tx_sec / 1000000000).toFixed(2) + 'Gb';
else if (response[0].tx_sec >= 1000000)
up = (response[0].tx_sec / 1000000).toFixed(2) + 'Mb';
else if (response[0].tx_sec >= 1000)
up = (response[0].tx_sec / 1000).toFixed(2) + 'Kb';
else
up = response[0].tx_sec.toFixed(2) + 'B';
if (!up.startsWith('NaN')) {
document.getElementById('up-value').innerHTML = up + '/s';
upList.push({ x: new Date(), y: response[0].tx_sec.toFixed(2) });
}
let down;
if (response[0].rx_sec >= 1000000000)
down = (response[0].rx_sec / 1000000000).toFixed(2) + 'Gb';
else if (response[0].rx_sec >= 1000000)
down = (response[0].rx_sec / 1000000).toFixed(2) + 'Mb';
else if (response[0].rx_sec >= 1000)
down = (response[0].rx_sec / 1000).toFixed(2) + 'Kb';
else
down = response[0].rx_sec.toFixed(2) + 'B';
if (!down.startsWith('NaN')) {
document.getElementById('down-value').innerHTML = down + '/s';
downList.push({ x: new Date(), y: response[0].rx_sec.toFixed(2) });
}
if (upList.length > 20) {
upList.splice(0, 1);
downList.splice(0, 1);
}
}
})
.catch(e => console.error(e))
}, 1000);
/*JSC.Chart('chartDiv', {
legend_visible: false,
xAxis_crosshair_enabled: true,
xAxis_scale_type: "time",
series: [
{ name: 'Up', points: upList },
{ name: 'Down', points: downList },
],
});*/
}
</script>
<style>
body {
background-color: black;
}
p {
font-family: Arial, Helvetica, sans-serif;
color: white;
margin: 8px
}
.name {
font-size: 32px;
}
div {
padding-top: 6px;
padding-left: 6px;
}
.row {
display: grid;
grid-auto-columns: max-content;
}
.realtime {
grid-row: 1/100;
}
.chart {
grid-row: 99/100;
width: auto;
height: 156px;
margin: 0 0;
}
</style>