@@ -1238,6 +1238,73 @@ fun(Conf) ->
12381238 end
12391239end }.
12401240
1241+ % % Per-queue-type / per-mount disk alarms
1242+ {mapping , " disk_free_limits.$num.name" , " rabbit.disk_free_limits" , [
1243+ {datatype , [binary ]}
1244+ ]}.
1245+ {mapping , " disk_free_limits.$num.mount" , " rabbit.disk_free_limits" , [
1246+ {datatype , [string ]}
1247+ ]}.
1248+ {mapping , " disk_free_limits.$num.limit" , " rabbit.disk_free_limits" , [
1249+ {datatype , [integer , string ]},
1250+ {validators , [" is_supported_information_unit" ]}
1251+ ]}.
1252+ {mapping , " disk_free_limits.$num.queue_types" , " rabbit.disk_free_limits" , [
1253+ {datatype , [binary ]}
1254+ ]}.
1255+
1256+ {translation , " rabbit.disk_free_limits" ,
1257+ fun (Conf ) ->
1258+ case cuttlefish_variable :filter_by_prefix (" disk_free_limits" , Conf ) of
1259+ [] ->
1260+ cuttlefish :unset ();
1261+ Settings ->
1262+ Ls = lists :foldl (
1263+ fun ({[" disk_free_limits" , Num , Key0 ], Value0 }, Acc ) ->
1264+ Idx = case string :to_integer (Num ) of
1265+ {N , []} -> N ;
1266+ _ -> cuttlefish :invalid (lists :flatten (io_lib :format (" ~p could not be parsed as a number" , [Num ])))
1267+ end ,
1268+ Key = case Key0 of
1269+ " name" -> name ;
1270+ " mount" -> mount ;
1271+ " limit" -> limit ;
1272+ " queue_types" -> queue_types ;
1273+ _ -> cuttlefish :invalid (lists :flatten (io_lib :format (" ~p is invalid" , [Key0 ])))
1274+ end ,
1275+ Value = case Key of
1276+ queue_types -> string :split (Value0 , " ," );
1277+ _ -> Value0
1278+ end ,
1279+ maps :update_with (
1280+ Idx ,
1281+ fun (#{Key := ExistingValue } = Limit ) ->
1282+ cuttlefish :warn (
1283+ io_lib :format (" Disk limit ~b has duplicate setting ~ts , "
1284+ " using ~tp instead of ~tp " ,
1285+ [Idx , Key , Value , ExistingValue ])),
1286+ Limit #{Key := Value };
1287+ (Limit ) ->
1288+ Limit #{Key => Value }
1289+ end , #{Key => Value }, Acc );
1290+ (Other , _Acc ) ->
1291+ cuttlefish :invalid (
1292+ lists :flatten (io_lib :format (" ~p is invalid" , [Other ])))
1293+ end , #{}, Settings ),
1294+ maps :fold (
1295+ fun (_Idx , #{name := Name }, Names ) ->
1296+ case sets :is_element (Name , Names ) of
1297+ true ->
1298+ cuttlefish :invalid (
1299+ lists :flatten (io_lib :format (" name ~ts is used by multiple mounts" , [Name ])));
1300+ false ->
1301+ sets :add_element (Name , Names )
1302+ end
1303+ end , sets :new ([{version , 2 }]), Ls ),
1304+ Ls
1305+ end
1306+ end }.
1307+
12411308% %
12421309% % Clustering
12431310% % =====================
0 commit comments