summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Majkowski <majek@lshift.net>2009-10-27 15:42:31 +0000
committerMarek Majkowski <majek@lshift.net>2009-10-27 15:42:31 +0000
commitfa25558b74164117632c17fd721cc9fb25fab5b7 (patch)
tree5cdb6457f50ab63a9648a6baf67fefac1f285253
parent4c7ff1763db49fd6964cd0abd540fccd07e6884f (diff)
downloadrabbitmq-server-fa25558b74164117632c17fd721cc9fb25fab5b7.tar.gz
Added support for solaris
-rw-r--r--src/vm_memory_monitor.erl23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl
index b9320f5b..bf7b44ca 100644
--- a/src/vm_memory_monitor.erl
+++ b/src/vm_memory_monitor.erl
@@ -121,6 +121,14 @@ get_total_memory({unix, linux}) ->
MemTotal = dict:fetch('MemTotal', Dict),
MemTotal;
+get_total_memory({unix, sunos}) ->
+ File = os:cmd("/usr/sbin/prtconf"),
+ Lines = string:tokens(File, "\n"),
+ Dict = dict:from_list(lists:map(fun parse_line_sunos/1, Lines)),
+ MemTotal = dict:fetch('Memory size', Dict),
+ MemTotal;
+
+
get_total_memory(_OsType) ->
unknown.
@@ -167,6 +175,21 @@ parse_line_linux(Line) ->
end,
{list_to_atom(Name), Value1}.
+%% A line looks like "Memory size: 1024 Megabytes"
+parse_line_sunos(Line) ->
+ case string:tokens(Line, ":") of
+ [Name, RHS | _Rest] ->
+ [Value1 | UnitsRest] = string:tokens(RHS, " "),
+ Value2 = case UnitsRest of
+ ["Gigabytes"] -> list_to_integer(Value1) * 1024 * 1024 * 1024;
+ ["Megabytes"] -> list_to_integer(Value1) * 1024 * 1024;
+ ["Kilobytes"] -> list_to_integer(Value1) * 1024;
+ _ -> Value1 ++ UnitsRest %% no known units
+ end,
+ {list_to_atom(Name), Value2};
+ [Name] -> {list_to_atom(Name), none}
+ end.
+
%%----------------------------------------------------------------------------