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?
The built-in Sys
module contains functions dedicated to retrieving system information.
julia> VERSION
v"1.0.0"
julia> Sys.total_memory() / 2^20
8071.77734375
julia> Sys.free_memory() / 2^20
5437.46484375
julia> Sys.CPU_NAME
"haswell"
julia> Sys.
ARCH KERNEL WORD_SIZE eval isexecutable set_process_title
BINDIR MACHINE __init__ free_memory islinux total_memory
CPU_NAME SC_CLK_TCK _cpu_summary get_process_title isunix uptime
CPU_THREADS STDLIB _show_cpuinfo include iswindows which
CPUinfo UV_cpu_info_t cpu_info isapple loadavg windows_version
JIT WINDOWS_VISTA_VER cpu_summary isbsd maxrss
julia> # Above after pressing Tab key twice
While it does not support all of the information provided by top
, it will hopefully provide the information you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With