system: monitoring: Add a procedure to get the total available ram in the current system in bytes
parent
57c0fc0644
commit
ae7793bd65
|
@ -4,6 +4,7 @@
|
|||
#:export (current-memory-info
|
||||
current-ram-usage
|
||||
current-swap-usage
|
||||
ram-total
|
||||
|
||||
current-battery-capacity))
|
||||
|
||||
|
@ -29,6 +30,13 @@
|
|||
(cut string-split <> #\:))
|
||||
lines)))
|
||||
|
||||
(define (ram-total)
|
||||
(let* ((port (open "/proc/meminfo" O_RDONLY))
|
||||
(_ (read port))
|
||||
(mem-in-b (* (read port) 1024)))
|
||||
(close-input-port port)
|
||||
mem-in-b))
|
||||
|
||||
(define (current-ram-usage)
|
||||
(apply - (map (cut assoc-ref (current-memory-info) <>)
|
||||
'("MemTotal" "MemFree" "Buffers" "Cached" "SReclaimable"))))
|
||||
|
|
Loading…
Reference in New Issue