anchor.diff:                    pdb:set(V1, TableName)
             end
         end || {P, NewVals} <- T, is_pid(P), undefined =/= NewVals],
  -    comm:send_local_after(1, self(), {start_mon}),
  +    comm:send_local_after(1, self(), {sample_all}),
       inc_counter(State);
  -on({start_mon}, State) -> State;
  -
  -on({output_data}, State) when element(3, State) ->
  +
  +on({sample_all}, State) -> State;
  +
  +%% gather information on a single pid for periodic statistical output
  +on({sample_pid, Pid}, State) when pid =:= element(2, State) ->
       TableName = table(State),
  -    %%Now = os:timestamp(),
  -    %%Delay = timer:now_diff(Now, timestamp(State)) / 1000000,
  +    NewVals = try_process_info(
  +                Pid,
  +                [message_queue_len, status, current_function, backtrace]),
  +    TakeVals = case process_info_get(NewVals, status, dead_pid) of
  +                   running -> true;
  +                   runnable -> true;
  +                   _ -> false
  +               end,
  +    case TakeVals of
  +        true ->
  +            P = {Pid, process_info_get(NewVals, current_function, dead)},
  +            Entry = pdb:get(P, TableName),
  +            case Entry of
  +                undefined ->
  +                    V1 = pdbe_new(P, NewVals),
  +                    pdb:set(V1, TableName);
  +                _ ->
  +                    %% io:format("X:~p Y:~p~n", [X, Y]),
  +                    V1 = pdbe_add_vals(Entry, NewVals),
  +                    pdb:set(V1, TableName)
  +            end;
  +        false ->
  +            P = {Pid, not_running},
  +            Entry = pdb:get(P, TableName),
  +            TVals = lists:keyreplace(status, 1,
  +                                     NewVals, {status, runnable}),
  +            case Entry of
  +                undefined ->
  +                    V1 = pdbe_new(P, TVals),
  +                    pdb:set(V1, TableName);
  +                _ ->
  +                    %% io:format("X:~p Y:~p~n", [X, Y]),
  +                    V1 = pdbe_add_vals(Entry, TVals),
  +                    pdb:set(V1, TableName)
  +            end
  +    end,
  +    %%comm:send_local_after(1, self(), {sample_pid, Pid}),
  +    comm:send_local(self(), {sample_pid, Pid}),
  +    inc_counter(State);
  +on({sample_pid, _Pid}, State) -> State;
  +
  +on({output_all}, State) when all =:= element(3, State) ->
  +    TableName = table(State),
  +    Now = os:timestamp(),
  +    Delay = timer:now_diff(Now, timestamp(State)) / 1000000,
       Count = counter(State),
       ProcsMem = erlang:memory(processes),
       ProcsMemUsed = erlang:memory(processes_used),
  
positive.code:         Self -> setelement(7, State, no_exclude);
          _ -> setelement(7, State, self())
      end.
  
  
  
  vals_pid(Entry) -> element(1, Entry).
  vals_mqlen(Entry) -> element(2, Entry).
  
negative.code:                      Pid = element(1, X),
                       pdb:delete(Pid, TableName),
                       %% plot data is:
                       Infos = try_process_info(Pid, [status, memory, stack_size]),
                       Status = process_info_get(Infos, status, dead_pid),
                       {vals_pid(X),
                        Status,
                        vals_mqlen(X)/Count,
                        vals_cpu_usage(X, Count),
                        process_info_get(Infos, memory, 0),
                        process_info_get(Infos, stack_size, 0)}
                   end || X <- R1, is_tuple(X), is_pid(element(1, X)) ],
      SortedPlotData = lists:keysort(sort_by(State), PlotData),
      L = length(SortedPlotData),
  