Is there a nice way to get the current system information in julia (my use case here is memory but also interested in basically anything information that I could get from running top
on linux).
This is what I have at the moment: (basically just getting the output of `free -m`)<- I can't get this to let me escape backticks and keep code highlighting...
import Base.DataFmt: readdlm_string, invalid_dlm
"""
getmeminfo()
Returns (in MB) A tuple of containing:
- Memory(total, used, buffer, available)
- Swap(total, used, free)
"""
function getmeminfo()
memstats = readdlm_string(readstring(`free -m`),invalid_dlm(Char), Int, '\n', true, Dict())
return Tuple{Array{Int,1},Array{Int,1}}((memstats[2,[2;3;6;7]], memstats[3,[2;3;4]]))
end
Is there something in Base or any better ideas?
cat /proc/meminfo
(free
is also Unix specific) – Pruritusreaddlm("/proc/meminfo")
is much more succinct... – Citrine