[erlang-questions] os_mon in OS X

Björn-Egil Dahlberg egil@REDACTED
Fri May 9 15:36:02 CEST 2008


Ben Hood wrote:
> Björn-Egil,
> 
> On 6 May 2008, at 13:18, Ben Hood wrote:
>> The user that reported this to me (using RabbitMQ server) sent error  
>> dump via a chat session which I don't have a transcript for. So I  
>> have asked him to resend it and I will post it.
>>
> 
> This is the error trace:
> 
> =ERROR REPORT==== 6-May-2008::14:47:00 ===
> Error in process <0.52.0> on node 'rabbit@REDACTED' with exit value:  
> {{badmatch,{error,{fread,float}}},[{cpu_sup,get_uint32_measurement,2}, 
> {cpu_
> sup,measurement_server_loop,1}]}

It seems to be an error in cpu_sup for darwin and locales, it should 
probably use LC_ALL=C uptime instead of LANG=C uptime.

This should resolve it (not fully tested though). diff follows:

------------------------------------------------------------

diff -Naur otp_src_R12B-2/lib/os_mon/src/cpu_sup.erl 
otp_src_R12B-2_cpu_sup_fix/lib/os_mon/src/cpu_sup.erl
--- otp_src_R12B-2/lib/os_mon/src/cpu_sup.erl	2008-05-09 
15:08:52.228457000 +0200
+++ otp_src_R12B-2_cpu_sup_fix/lib/os_mon/src/cpu_sup.erl	2008-05-09 
15:08:43.138456000 +0200
@@ -264,7 +264,7 @@
      end;
  get_uint32_measurement(Request, #internal{os_type = {unix, darwin}}) ->
      %% Get the load average using uptime, overriding Locale setting.
-    D = os:cmd("LANG=C uptime") -- "\n",
+    D = os:cmd("LANG=C LC_ALL=C uptime") -- "\n",
      %% Here is a sample uptime string from Mac OS 10.3.8 (C Locale):
      %%    "11:17  up 12 days, 20:39, 2 users, load averages: 1.07 0.95 
0.66"
      %% The safest way to extract the load averages seems to be grab 
everything


------------------------------------------------------------

I agree, it is sad that output like this is modified by locale settings 
which makes it a little difficult to parse. A more robust way should be 
implemented then parsing human readables. No such implementation is on 
the horizon nor seriously contemplated at the moment.

Regards,
Björn-Egil
Erlang/OTP



More information about the erlang-questions mailing list