diff options
author | Lukas Larsson <[email protected]> | 2018-10-29 09:19:31 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2018-10-29 09:19:31 +0100 |
commit | 949c0c810ae575e9e35998c72189b1d90e3ea075 (patch) | |
tree | 3b106e3344e126d30bf1e40c02b825128d758d59 /lib/os_mon/src | |
parent | c37f7a2215646c85c1ae12303f07bc9bc27b75ae (diff) | |
parent | f2ca9d9cb14527fb5dd3016cbccd45355cc2a6c7 (diff) | |
download | otp-949c0c810ae575e9e35998c72189b1d90e3ea075.tar.gz otp-949c0c810ae575e9e35998c72189b1d90e3ea075.tar.bz2 otp-949c0c810ae575e9e35998c72189b1d90e3ea075.zip |
Merge branch 'jimdigriz/os_mon/fix_cpu_sup_android/OTP-15387' into maint
* jimdigriz/os_mon/fix_cpu_sup_android/OTP-15387:
Make Erlang's cpu_sup function better on Android
SELinux is another cause of MSG_CTRUNC
Diffstat (limited to 'lib/os_mon/src')
-rw-r--r-- | lib/os_mon/src/cpu_sup.erl | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/os_mon/src/cpu_sup.erl b/lib/os_mon/src/cpu_sup.erl index 81e049ef22..ba2d89313e 100644 --- a/lib/os_mon/src/cpu_sup.erl +++ b/lib/os_mon/src/cpu_sup.erl @@ -220,17 +220,21 @@ code_change(_OldVsn, State, _Extra) -> %% internal functions %%---------------------------------------------------------------------- -get_uint32_measurement(Request, #internal{os_type = {unix, linux}}) -> - {ok,F} = file:open("/proc/loadavg",[read,raw]), - {ok,D} = file:read_line(F), - ok = file:close(F), - {ok,[Load1,Load5,Load15,_PRun,PTotal],_} = io_lib:fread("~f ~f ~f ~d/~d", D), - case Request of - ?avg1 -> sunify(Load1); - ?avg5 -> sunify(Load5); - ?avg15 -> sunify(Load15); - ?ping -> 4711; - ?nprocs -> PTotal +get_uint32_measurement(Request, #internal{port = P, os_type = {unix, linux}}) -> + case file:open("/proc/loadavg",[read,raw]) of + {ok,F} -> + {ok,D} = file:read_line(F), + ok = file:close(F), + {ok,[Load1,Load5,Load15,_PRun,PTotal],_} = io_lib:fread("~f ~f ~f ~d/~d", D), + case Request of + ?avg1 -> sunify(Load1); + ?avg5 -> sunify(Load5); + ?avg15 -> sunify(Load15); + ?ping -> 4711; + ?nprocs -> PTotal + end; + {error,_} -> + port_server_call(P, Request) end; get_uint32_measurement(Request, #internal{port = P, os_type = {unix, Sys}}) when Sys == sunos; |