Added a page for memory stats
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-05-26 22:28:59 -04:00
parent 90d8191e54
commit f88eeafafa
5 changed files with 82 additions and 1 deletions

View 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)

View File

@ -1,2 +1,21 @@
@loadPage = (pagePath) ->
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]