suggested by German Todorov
suggested by archaelus
spawn(fun() -> erlang:group_leader(whereis(smemail), self()), App = application:get_application(), erlang:group_leader(whereis(user), self()), io:format(“~p”, [App]) end).
to put on pages with the mention “battle tested with chaos_monkey!”
2012-07-25 09:47 <MononcQc> I had an idea in the back of my mind to make an app simulating a node going to the shitter. Playing with priorities, causing trouble with scheduling and CPU use, as if the node was overloaded 2012-07-25 09:47 <MononcQc> random failures, etc. — … — 2012-07-25 11:13 <dluna> essen: Let me know what features could be added to the chaos monkey and I’ll see what I can do. 2012-07-25 11:19 <essen> what MononcQc said, play with priorities, cause trouble with scheduling, CPU use, as if the node was overloaded 2012-07-25 11:21 <MononcQc> call manual GCs and whatnot 2012-07-25 11:21 <essen> mock gen_tcp and friends to disallow opening connections 2012-07-25 11:21 <MononcQc> yeah, pretending file descriptors are all used up 2012-07-25 11:21 <essen> mess with distribution 2012-07-25 11:22 <MononcQc> call net_kernel:disconnect a few times at random 2012-07-25 11:22 <MononcQc> and for the tool I had in mind, the ‘hellhole’ mode would have been to unleash everything at once. Random deaths, slow IO (be a slow group_leader), disconnections, high CPU, etc.
%% Counters to be reported to the user: %% #dead already %% sups %% children %% neither sups nor children %% disconnected sups %% total killable with no dead sups %% kill and check status %% total killable with no dead top level sups %% kill and check status %% #Killed %% total number of processes before killing anything %% total number of processes after killing things
The following can be used to print info about processes and should somehow be brough into line with what chaos_monkey:kill/0 returns. And the other way around obviously, probably adding a pp_procdata or whatnot.
%% p_pidinfo(Killable, Pid, App, IsSystemProcess, IsSystemApp, IsSupervisor) ->
%% FKillable = case Killable of
%% true -> “About to”;
%% false -> “Cannot”
%% end,
%% FName = case erlang:process_info(Pid, registered_name) of
%% {registered_name, Name} ->
%% io_lib:format(” (~s)”, [Name]);
%% “” -> “”
%% end,
%% FApp = case App of
%% undefined -> “”;
%% {ok, A} -> io_lib:format(” in app ~s”, [A])
%% end,
%% Immunities =
%% [case IsSystemProcess of
%% true -> ” is a system process”;
%% false -> no
%% end,
%% case IsSystemApp of
%% true -> ” belongs to a system app”;
%% false -> no
%% end,
%% case IsSupervisor of
%% true -> ” is a supervisor”;
%% false -> no
%% end],
%% FImmunities =
%% case lists:filter(fun(X) -> X / no end, Immunities) of
%% [] -> “”;
%% Imms ->
%% [” because it”, string:join(Imms, ” and”)]
%% end,
%% case (App : undefined) orelse (Killable : true) of
%% true ->
%% p(“~s kill ~p~s~s~s.”, [FKillable, Pid, FName, FApp, FImmunities]);
%% false ->
%% ok
%% end.
More dead code that ties in whith things to do later. See the comment about multiple trees in the same app.
%% with_ancestors(Pids) -> %% [case erlang:process_info(Pid, dictionary) of %% {dictionary, PDict} -> %% case lists:keyfind(‘$ancestors’, 1, PDict) of %% {‘$ancestors’, [Ancestor | _Ancestors]} -> %% {Pid, Ancestor}; %% _ -> %% {Pid, unknown} %% end; %% _ -> %% {Pid, unknown} %% end || Pid <- Pids].