OS X os_mon broken

Sean Hinde sean.hinde@REDACTED
Mon Mar 7 22:55:36 CET 2005


Hi,

os_mon-1.6.2 is still broken under OS X darwin.

The following patch restores what was in my original patch. This makes 
the solution much less susceptible to changes in the output of uptime.

Regards,
Sean

--- cpu_sup.erl.orig    Fri Jun 25 14:25:58 2004
+++ cpu_sup.erl Mon Mar  7 21:50:04 2005
@@ -274,11 +274,11 @@
      end;
  get_int_measurement(Request, #state{os_type = {unix, darwin}}) ->
      D = os:cmd("uptime") -- "\n",
-    {ok, [L1, L5, L15], _} = 
io_lib:fread("~*s~*s~*s~*s~*s~*s~*s~f,~f,~f", D),
+    [L15, L5, L1|_] = lists:reverse(string:tokens(D, ", ")),
      case Request of
-       ?avg1  -> sunify(L1);
-       ?avg5  -> sunify(L5);
-       ?avg15 -> sunify(L15);
+       ?avg1  -> sunify(list_to_float(L1));
+       ?avg5  -> sunify(list_to_float(L5));
+       ?avg15 -> sunify(list_to_float(L15));
         ?ping -> 4711;
         ?nprocs ->
             Ps = os:cmd("/bin/ps -ax | /usr/bin/wc -l"),




More information about the erlang-patches mailing list