|
22 | 22 | -behaviour(gen_server). |
23 | 23 | -define(SERVER, ?MODULE). |
24 | 24 | -export([init/1, handle_call/3, handle_cast/2, handle_info/2, |
25 | | - terminate/2, code_change/3]). |
| 25 | + terminate/2, code_change/3, handle_settings_alerts_limits_post/1, |
| 26 | + handle_settings_alerts_limits_get/1]). |
26 | 27 |
|
27 | 28 | -export([alert_keys/0, config_upgrade_to_70/1, config_upgrade_to_MORPHEUS/1]). |
28 | 29 |
|
@@ -871,6 +872,38 @@ upgrade_alerts(EmailAlerts, Mutations) -> |
871 | 872 | [{set, email_alerts, Result}] |
872 | 873 | end. |
873 | 874 |
|
| 875 | +type_spec(undefined) -> |
| 876 | + undefined. |
| 877 | + |
| 878 | +params() -> |
| 879 | + [{"maxOverheadPerc", #{type => {int, 0, 100}, |
| 880 | + cfg_key => max_overhead_perc}}, |
| 881 | + {"maxDiskUsedPerc", #{type => {int, 0, 100}, |
| 882 | + cfg_key => max_disk_used}}, |
| 883 | + {"maxIndexerRamPerc", #{type => {int, 0, 100}, |
| 884 | + cfg_key => max_indexer_ram}}]. |
| 885 | + |
| 886 | +build_alert_limits() -> |
| 887 | + case ns_config:search(alert_limits) of |
| 888 | + false -> |
| 889 | + []; |
| 890 | + {value, Values} -> |
| 891 | + Values |
| 892 | + end. |
| 893 | + |
| 894 | +handle_settings_alerts_limits_get(Req) -> |
| 895 | + menelaus_web_settings2:handle_get([], params(), fun type_spec/1, |
| 896 | + build_alert_limits(), Req). |
| 897 | + |
| 898 | +handle_settings_alerts_limits_post(Req) -> |
| 899 | + menelaus_web_settings2:handle_post( |
| 900 | + fun (Params, Req2) -> |
| 901 | + NewParams = [{Key, Val} || {[Key], Val} <- Params], |
| 902 | + NewLimits = misc:update_proplist(build_alert_limits(), NewParams), |
| 903 | + ns_config:set(alert_limits, NewLimits), |
| 904 | + handle_settings_alerts_limits_get(Req2) |
| 905 | + end, [], params(), fun type_spec/1, Req). |
| 906 | + |
874 | 907 | -ifdef(TEST). |
875 | 908 | %% Cant currently test the alert timeouts as would need to mock |
876 | 909 | %% calls to the archiver |
|
0 commit comments