Added a page for memory stats
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
90d8191e54
commit
f88eeafafa
24
assets/coffee/memory.coffee
Normal file
24
assets/coffee/memory.coffee
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
si = require('systeminformation')
|
||||||
|
|
||||||
|
window.onload = () ->
|
||||||
|
# Grab the static CPU information
|
||||||
|
si.mem()
|
||||||
|
.then((data) ->
|
||||||
|
document.getElementById('memoryTotal').innerText = @formatBytes(data.total)
|
||||||
|
).catch((error) ->
|
||||||
|
console.error(error)
|
||||||
|
)
|
||||||
|
|
||||||
|
# Start the CPU temperature loop
|
||||||
|
getMemoryUsage()
|
||||||
|
|
||||||
|
getMemoryUsage = () ->
|
||||||
|
si.mem()
|
||||||
|
.then((data) ->
|
||||||
|
document.getElementById('memoryFree').innerText = @formatBytes(data.free)
|
||||||
|
document.getElementById('memoryActive').innerText = @formatBytes(data.active)
|
||||||
|
document.getElementById('memoryBuffCache').innerText = @formatBytes(data.buffcache)
|
||||||
|
).catch((error) ->
|
||||||
|
console.error(error)
|
||||||
|
)
|
||||||
|
setTimeout(getMemoryUsage, 2000)
|
@ -1,2 +1,21 @@
|
|||||||
@loadPage = (pagePath) ->
|
@loadPage = (pagePath) ->
|
||||||
window.location.href = pagePath + '.html'
|
window.location.href = pagePath + '.html'
|
||||||
|
|
||||||
|
@formatBytes = (bytes, decimals = 2) ->
|
||||||
|
if bytes == 0
|
||||||
|
return '0 Bytes'
|
||||||
|
k = 1024
|
||||||
|
dm = if decimals < 0 then 0 else decimals
|
||||||
|
sizes = [
|
||||||
|
'Bytes'
|
||||||
|
'KB'
|
||||||
|
'MB'
|
||||||
|
'GB'
|
||||||
|
'TB'
|
||||||
|
'PB'
|
||||||
|
'EB'
|
||||||
|
'ZB'
|
||||||
|
'YB'
|
||||||
|
]
|
||||||
|
i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||||
|
parseFloat((bytes / k ** i).toFixed(dm)) + ' ' + sizes[i]
|
||||||
|
@ -57,3 +57,7 @@ button
|
|||||||
|
|
||||||
p.no-margin
|
p.no-margin
|
||||||
margin-bottom: 0
|
margin-bottom: 0
|
||||||
|
|
||||||
|
#systemPages
|
||||||
|
> div:nth-child(2n + 3)
|
||||||
|
margin-left: 0
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section class="row">
|
<section id="systemPages" class="row">
|
||||||
<!-- CPU info page link -->
|
<!-- CPU info page link -->
|
||||||
<div class="columns six u-text-center">
|
<div class="columns six u-text-center">
|
||||||
<a class="pageLink" href="cpu.html">
|
<a class="pageLink" href="cpu.html">
|
||||||
@ -24,6 +24,14 @@
|
|||||||
<p class="u-text-center">Graphics Card</p>
|
<p class="u-text-center">Graphics Card</p>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Memory info page link -->
|
||||||
|
<div class="columns six u-text-center">
|
||||||
|
<a href="memory.html" class="pageLink">
|
||||||
|
<i class="fa-solid fa-memory"></i>
|
||||||
|
<p class="u-text-center">Memory</p>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
26
assets/twig/memory.twig
Normal file
26
assets/twig/memory.twig
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{% extends 'layout.twig' %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
<script src="./js/memory.js" charset="utf-8"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<header class="row">
|
||||||
|
<div class="columns twelve u-text-center">
|
||||||
|
<h1>Memory Info</h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section class="row">
|
||||||
|
<p><span id="memoryFree">N/a</span> free out of <span id="memoryTotal">N/a</span>.</p>
|
||||||
|
<p><span id="memoryActive">N/a</span> is actively used | <span id="memoryBuffCache">N/a</span> is used in buffers/cache.</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="row">
|
||||||
|
<div class="columns twelve">
|
||||||
|
<a href="index.html">Back</a>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Reference in New Issue
Block a user