diff options
| author | Michael Klishin <michael@novemberain.com> | 2015-12-05 09:16:02 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@novemberain.com> | 2015-12-05 09:16:02 +0300 |
| commit | 9bacf06c3ade074fe4ae1149236f94ad61dc667f (patch) | |
| tree | 4bd3bd7a05258cd60e4b812258059079bb66e980 | |
| parent | e2f5701d948d17f5c3bbebfc0e4d6b748eec99e8 (diff) | |
| parent | b2ca6fdf23f49078e8ddcfab189cf1d8ac2fead7 (diff) | |
| download | rabbitmq-server-git-9bacf06c3ade074fe4ae1149236f94ad61dc667f.tar.gz | |
Merge pull request #469 from rabbitmq/rabbitmq-server-461
Add command to change disk_free_limit to rabbitmqctl
| -rw-r--r-- | docs/rabbitmqctl.1.xml | 34 | ||||
| -rw-r--r-- | src/rabbit_control_main.erl | 22 |
2 files changed, 54 insertions, 2 deletions
diff --git a/docs/rabbitmqctl.1.xml b/docs/rabbitmqctl.1.xml index b9e478cb53..fb4959b276 100644 --- a/docs/rabbitmqctl.1.xml +++ b/docs/rabbitmqctl.1.xml @@ -1966,8 +1966,8 @@ <listitem><para> The new memory limit at which flow control is triggered, expressed in bytes as an integer number - greater than or equal to 0 or as string with memory unit - (e.g. 1024MB). Available units are: + greater than or equal to 0 or as a string with memory units + (e.g. 512M or 1G). Available units are: k, kiB: kibibytes (2^10 bytes) M, MiB: mebibytes (2^20) G, GiB: gibibytes (2^30) @@ -1979,6 +1979,36 @@ </variablelist> </listitem> </varlistentry> + <varlistentry> + <term><cmdsynopsis><command>set_disk_free_limit</command> <arg choice="req"><replaceable>disk_limit</replaceable></arg></cmdsynopsis></term> + <listitem> + <variablelist> + <varlistentry> + <term>disk_limit</term> + <listitem><para> + Lower bound limit as an integer in bytes or a string with memory units (see vm_memory_high_watermark), + e.g. 512M or 1G. Once free disk space reaches the limit, a disk alarm will be set. + </para></listitem> + </varlistentry> + </variablelist> + </listitem> + </varlistentry> + <varlistentry> + <term><cmdsynopsis><command>set_disk_free_limit mem_relative</command> <arg choice="req"><replaceable>fraction</replaceable></arg></cmdsynopsis></term> + <listitem> + <variablelist> + <varlistentry> + <term>fraction</term> + <listitem><para> + Limit relative to the total amount available RAM + as a non-negative floating point number. + Values lower than 1.0 can be dangerous and + should be used carefully. + </para></listitem> + </varlistentry> + </variablelist> + </listitem> + </varlistentry> </variablelist> </refsect2> </refsect1> diff --git a/src/rabbit_control_main.erl b/src/rabbit_control_main.erl index 91a079da93..9d40801291 100644 --- a/src/rabbit_control_main.erl +++ b/src/rabbit_control_main.erl @@ -88,6 +88,7 @@ {trace_on, [?VHOST_DEF]}, {trace_off, [?VHOST_DEF]}, set_vm_memory_high_watermark, + set_disk_free_limit, help ]). @@ -426,6 +427,27 @@ action(set_vm_memory_high_watermark, Node, ["absolute", Arg], _Opts, Inform) -> {error_string, "Unable to parse absolute memory limit value ~p", [Arg]} end; +action(set_disk_free_limit, Node, [Arg], _Opts, Inform) -> + case rabbit_resource_monitor_misc:parse_information_unit(Arg) of + {ok, Limit} -> + Inform("Setting disk free limit on ~p to ~p bytes", [Node, Limit]), + rpc_call(Node, rabbit_disk_monitor, set_disk_free_limit, [Limit]); + {error, parse_error} -> + {error_string, "Unable to parse disk free limit value ~p", [Arg]} + end; + +action(set_disk_free_limit, Node, ["mem_relative", Arg], _Opts, Inform) -> + Frac = list_to_float(case string:chr(Arg, $.) of + 0 -> Arg ++ ".0"; + _ -> Arg + end), + Inform("Setting disk free limit on ~p to ~p of total RAM", [Node, Frac]), + rpc_call(Node, + rabbit_disk_monitor, + set_disk_free_limit, + [{mem_relative, Frac}]); + + action(set_permissions, Node, [Username, CPerm, WPerm, RPerm], Opts, Inform) -> VHost = proplists:get_value(?VHOST_OPT, Opts), Inform("Setting permissions for user \"~s\" in vhost \"~s\"", |
