%% -*- mode: erlang; erlang-indent-level: 2 -*- %%% Created : 23 Aug 2016 by masse %% @doc %% @end -module('mtop'). -author('masse'). -export([start/0, stop/0]). start() -> case [Vsn || {mnesia,_,Vsn} <- application:which_applications()] of [] -> mnesia_not_started; [_] -> spawn(fun init/0) end. stop() -> case whereis(mtop) of undefined -> ok; Pid -> Pid ! quit end. init() -> register(mtop,self()), {State,_} = prfMnesia:collect(init), Opts = [{collectors, [held_locks,lock_queue,current_transactions,failed_transactions, committed_transactions,restarted_transactions, current_transactions_change,failed_transactions_change, committed_transactions_change,restarted_transactions_change]}], loop(prfMnesia:config(State,Opts)). loop(State0) -> {State,{prfMnesia,Data}} = prfMnesia:collect(State0), {info,Participants,Coordinators} = mnesia_tm:get_info(1000), Trans = [{participants,length(Participants)}, {coordinators,length(Coordinators)}], io:fwrite("~p~n",[Data++Trans]), receive quit -> exit(done) after 2000 -> ok end, loop(State).