-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
73 lines (68 loc) · 3 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
<!DOCTYPE html>
<head>
<title>System Information</title>
</head>
<body>
<h1>System Information</h1>
<div id="table"></div>
</body>
<script>
async function fetchMessages() { //async so we can make it repeat
console.log("Fetching file")
const response = await fetch('usage.json'); // fetch the data
const message = await response.json(); // convert it to javascript json
//console.log(message);
Object.values(message).forEach(messages => { // must be parsed as an object otherwise javascript cries
const tableHTML = `
<table>
<tr>
<td>Timetstamp:</td>
<td>${message.timestamp.Timestamp}</td>
</tr>
<tr>
<td>Hostname:</td>
<td>${message.hostname.Hostname}</td>
</tr>
<tr>
<td>Architecture:</td>
<td>${message.architecture.Architecture}</td>
</tr>
<tr>
<td>Total Memory:</td>
<td>${message.RAM.Total}</td>
</tr>
<tr>
<td>Memory Available:</td>
<td>${message.RAM.Available}</td>
</tr>
<tr>
<td>Percentage of Memory Being Used:</td>
<td>${message.RAM.Percent}%</td>
</tr>
<tr>
<td>Total Disk Space:</td>
<td>${message.disk.Total}</td>
</tr>
<tr>
<td>Percentage of Disk Being Used:</td>
<td>${message.disk.Percent}%</td>
</tr>
<tr>
<td>Bytes Sent:</td>
<td>${message.network.traffic_sent}</td>
</tr>
<tr>
<td>Bytes Received:</td>
<td>${message.network.traffic_recv}</td>
</tr>
</table>
`;
console.log ("File fetched")
document.getElementById('table').innerHTML = tableHTML;
});
};
setInterval(fetchMessages, 1000); // wait a second before updaitng the file
window.onload = fetchMessages(); // when we load the page, do this
</script>
</body>
</html>