aboutsummaryrefslogtreecommitdiffstats
path: root/lib/observer
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2011-12-05 16:02:54 +0100
committerDan Gudmundsson <[email protected]>2011-12-05 16:02:54 +0100
commitb0121557d6a97c22f147db665788132c2b2096d1 (patch)
treeb85d682e3ca02b59201fa92154e12cf2fd1ab6cc /lib/observer
parent6bbe0512b1686f06489893479ae1d14ef15d004a (diff)
downloadotp-b0121557d6a97c22f147db665788132c2b2096d1.tar.gz
otp-b0121557d6a97c22f147db665788132c2b2096d1.tar.bz2
otp-b0121557d6a97c22f147db665788132c2b2096d1.zip
[observer] Move rpc calls to runtime tools
Diffstat (limited to 'lib/observer')
-rw-r--r--lib/observer/src/observer_app_wx.erl14
-rw-r--r--lib/observer/src/observer_sys_wx.erl37
-rw-r--r--lib/observer/src/observer_tv_table.erl47
-rw-r--r--lib/observer/src/observer_tv_wx.erl160
4 files changed, 37 insertions, 221 deletions
diff --git a/lib/observer/src/observer_app_wx.erl b/lib/observer/src/observer_app_wx.erl
index 4f35a93004..62046577ad 100644
--- a/lib/observer/src/observer_app_wx.erl
+++ b/lib/observer/src/observer_app_wx.erl
@@ -255,6 +255,11 @@ handle_info({delivery, Pid, app_ctrl, _, Apps0},
wxListBox:appendStrings(LBox, [App || App <- lists:sort(Apps)]),
{noreply, State};
+handle_info({delivery, _Pid, app, _Curr, {[], [], [], []}},
+ State = #state{panel=Panel}) ->
+ wxWindow:refresh(Panel),
+ {noreply, State#state{app=undefined, sel=undefined}};
+
handle_info({delivery, Pid, app, Curr, AppData},
State = #state{panel=Panel, appmon=Pid, current=Curr,
app_w=AppWin, paint=#paint{font=Font}}) ->
@@ -356,11 +361,10 @@ build_tree({Root, P2Name, Links, XLinks0}, Font) ->
{_, Tree0} = build_tree2(Root, Lookup, Name2P, Font),
{Tree, Dim} = calc_tree_size(Tree0),
Fetch = fun({From, To}, Acc) ->
- case gb_trees:lookup(To, Name2P) of
- {value, ToPid} ->
- FromPid = gb_trees:get(From, Name2P),
- [{locate_box(FromPid, [Tree]),locate_box(ToPid, [Tree])}|Acc];
- none ->
+ try {value, ToPid} = gb_trees:lookup(To, Name2P),
+ FromPid = gb_trees:get(From, Name2P),
+ [{locate_box(FromPid, [Tree]),locate_box(ToPid, [Tree])}|Acc]
+ catch _:_ ->
Acc
end
end,
diff --git a/lib/observer/src/observer_sys_wx.erl b/lib/observer/src/observer_sys_wx.erl
index 2535b50876..09602bbd9e 100644
--- a/lib/observer/src/observer_sys_wx.erl
+++ b/lib/observer/src/observer_sys_wx.erl
@@ -24,8 +24,6 @@
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_event/2, handle_cast/2]).
--export([sys_info/0]).
-
-include_lib("wx/include/wx.hrl").
-include("observer_defs.hrl").
@@ -48,7 +46,7 @@ start_link(Notebook, Parent) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
init([Notebook, Parent]) ->
- SysInfo = sys_info(),
+ SysInfo = observer_backend:sys_info(),
{Info, Stat} = info_fields(),
Panel = wxPanel:new(Notebook),
Sizer = wxBoxSizer:new(?wxHORIZONTAL),
@@ -73,7 +71,7 @@ create_sys_menu(Parent) ->
observer_wx:create_menus(Parent, [View]).
update_syspage(#sys_wx_state{node = Node, fields=Fields, sizer=Sizer}) ->
- SysInfo = observer_wx:try_rpc(Node, ?MODULE, sys_info, []),
+ SysInfo = observer_wx:try_rpc(Node, observer_backend, sys_info, []),
{Info, Stat} = info_fields(),
observer_lib:update_info(Fields, observer_lib:fill_info(Info, SysInfo) ++
observer_lib:fill_info(Stat, SysInfo)),
@@ -105,12 +103,12 @@ info_fields() ->
{"Ets", {bytes, ets}}
]},
{"Statistics", right,
- [{"Up time", uptime},
+ [{"Up time", {time_ms, uptime}},
{"Max Processes", process_limit},
{"Processes", process_count},
{"Run Queue", run_queue},
- {"IO Input", io_input},
- {"IO Output", io_output}
+ {"IO Input", {bytes, io_input}},
+ {"IO Output", {bytes, io_output}}
]}
],
{Info, Stat}.
@@ -177,28 +175,3 @@ handle_event(#wx{id = ?ID_REFRESH_INTERVAL,
handle_event(Event, State) ->
io:format("~p:~p: Unhandled event ~p\n", [?MODULE,?LINE,Event]),
{noreply, State}.
-
-
-sys_info() ->
- {{_,Input},{_,Output}} = erlang:statistics(io),
- [{process_count, erlang:system_info(process_count)},
- {process_limit, erlang:system_info(process_limit)},
- {uptime, {time_ms, element(1, erlang:statistics(wall_clock))}},
- {run_queue, erlang:statistics(run_queue)},
- {io_input, {bytes, Input}},
- {io_output, {bytes, Output}},
- {logical_processors, erlang:system_info(logical_processors)},
- {logical_processors_available, erlang:system_info(logical_processors_available)},
- {logical_processors_online, erlang:system_info(logical_processors_online)},
-
- {otp_release, erlang:system_info(otp_release)},
- {version, erlang:system_info(version)},
- {system_architecture, erlang:system_info(system_architecture)},
- {kernel_poll, erlang:system_info(kernel_poll)},
- {smp_support, erlang:system_info(smp_support)},
- {threads, erlang:system_info(threads)},
- {thread_pool_size, erlang:system_info(thread_pool_size)},
- {wordsize_internal, erlang:system_info({wordsize, internal})},
- {wordsize_external, erlang:system_info({wordsize, external})} |
- erlang:memory()
- ].
diff --git a/lib/observer/src/observer_tv_table.erl b/lib/observer/src/observer_tv_table.erl
index dd11ba5470..31d5f3d632 100644
--- a/lib/observer/src/observer_tv_table.erl
+++ b/lib/observer/src/observer_tv_table.erl
@@ -24,8 +24,6 @@
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_event/2, handle_sync_event/3, handle_cast/2]).
--export([get_table/3]).
-
-include("observer_defs.hrl").
-import(observer_lib, [to_str/1]).
@@ -507,7 +505,7 @@ table_holder(S0 = #holder{parent=Parent, pid=Pid, table=Table}) ->
%% io:format("ignoring refresh", []),
table_holder(S0);
refresh ->
- GetTab = rpc:call(S0#holder.node, ?MODULE, get_table,
+ GetTab = rpc:call(S0#holder.node, observer_backend, get_table,
[self(), S0#holder.tabid, S0#holder.source]),
table_holder(S0#holder{pid=GetTab});
{delete, Row} ->
@@ -708,49 +706,6 @@ insert(Object, #holder{tabid=Id, source=Source, node=Node}) ->
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-get_table(Parent, Table, Module) ->
- spawn(fun() ->
- link(Parent),
- get_table2(Parent, Table, Module)
- end).
-
-get_table2(Parent, Table, Type) ->
- Size = case Type of
- ets -> ets:info(Table, size);
- mnesia -> mnesia:table_info(Table, size)
- end,
- case Size > 0 of
- false ->
- Parent ! {self(), '$end_of_table'},
- normal;
- true when Type =:= ets ->
- Mem = ets:info(Table, memory),
- Average = Mem div Size,
- NoElements = max(10, 20000 div Average),
- get_ets_loop(Parent, ets:match(Table, '$1', NoElements));
- true ->
- Mem = mnesia:table_info(Table, memory),
- Average = Mem div Size,
- NoElements = max(10, 20000 div Average),
- Ms = [{'$1', [], ['$1']}],
- Get = fun() ->
- get_mnesia_loop(Parent, mnesia:select(Table, Ms, NoElements, read))
- end,
- %% Not a transaction, we don't want to grab locks when inspecting the table
- mnesia:async_dirty(Get)
- end.
-
-get_ets_loop(Parent, '$end_of_table') ->
- Parent ! {self(), '$end_of_table'};
-get_ets_loop(Parent, {Match, Cont}) ->
- Parent ! {self(), Match},
- get_ets_loop(Parent, ets:match(Cont)).
-
-get_mnesia_loop(Parent, '$end_of_table') ->
- Parent ! {self(), '$end_of_table'};
-get_mnesia_loop(Parent, {Match, Cont}) ->
- Parent ! {self(), Match},
- get_ets_loop(Parent, mnesia:select(Cont)).
column_names(Node, Type, Table) ->
case Type of
diff --git a/lib/observer/src/observer_tv_wx.erl b/lib/observer/src/observer_tv_wx.erl
index bf66b7178c..a473fe83b9 100644
--- a/lib/observer/src/observer_tv_wx.erl
+++ b/lib/observer/src/observer_tv_wx.erl
@@ -23,8 +23,6 @@
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_event/2, handle_sync_event/3, handle_cast/2]).
--export([get_table_list/1]). %% RPC called move to runtime tools?
-
-behaviour(wx_object).
-include_lib("wx/include/wx.hrl").
-include("observer_defs.hrl").
@@ -239,91 +237,33 @@ get_tables(Node, Opts) ->
Res ->
Res
end.
-get_tables2(Node, Opt) ->
- case rpc:call(Node, ?MODULE, get_table_list, [Opt]) of
+get_tables2(Node, #opt{type=Type, sys_hidden=Sys, unread_hidden=Unread}) ->
+ Args = [Type, [{sys_hidden,Sys}, {unread_hidden,Unread}]],
+ case rpc:call(Node, observer_backend, get_table_list, Args) of
{badrpc, Error} ->
{error, Error};
+ Error = {error, _} ->
+ Error;
Result ->
- Result
+ [list_to_tabrec(Tab) || Tab <- Result]
end.
-get_table_list(#opt{type=ets, unread_hidden=HideUnread, sys_hidden=HideSys}) ->
- Info = fun(Id, Acc) ->
- try
- TabId = case ets:info(Id, named_table) of
- true -> ignore;
- false -> Id
- end,
- Name = ets:info(Id, name),
- Protection = ets:info(Id, protection),
- ignore(HideUnread andalso Protection == private, unreadable),
- Owner = ets:info(Id, owner),
- RegName = case catch process_info(Owner, registered_name) of
- [] -> ignore;
- {registered_name, ProcName} -> ProcName
- end,
- ignore(HideSys andalso ordsets:is_element(RegName, sys_processes()), system_tab),
- ignore(HideSys andalso ordsets:is_element(Name, sys_tables()), system_tab),
- ignore((RegName == mnesia_monitor)
- andalso Name /= schema
- andalso is_atom((catch mnesia:table_info(Name, where_to_read))), mnesia_tab),
- Memory = ets:info(Id, memory) * erlang:system_info(wordsize),
- Tab = #tab{name = Name,
- id = TabId,
- protection = Protection,
- owner = Owner,
- size = ets:info(Id, size),
- reg_name = RegName,
- type = ets:info(Id, type),
- keypos = ets:info(Id, keypos),
- heir = ets:info(Id, heir),
- memory = Memory,
- compressed = ets:info(Id, compressed),
- fixed = ets:info(Id, fixed)
- },
- [Tab|Acc]
- catch _:_What ->
- %% io:format("Skipped ~p: ~p ~n",[Id, _What]),
- Acc
- end
- end,
- lists:foldl(Info, [], ets:all());
-get_table_list(#opt{type=mnesia, sys_hidden=HideSys}) ->
- Owner = ets:info(schema, owner),
- Owner /= undefined orelse
- throw({error, "Mnesia is not running on: " ++ atom_to_list(node())}),
- {registered_name, RegName} = process_info(Owner, registered_name),
- Info = fun(Id, Acc) ->
- try
- Name = Id,
- ignore(HideSys andalso ordsets:is_element(Name, mnesia_tables()), system_tab),
- ignore(Name =:= schema, mnesia_tab),
- Storage = mnesia:table_info(Id, storage_type),
- Tab0 = #tab{name = Name,
- owner = Owner,
- size = mnesia:table_info(Id, size),
- reg_name = RegName,
- type = mnesia:table_info(Id, type),
- keypos = 2,
- memory = mnesia:table_info(Id, memory) * erlang:system_info(wordsize),
- storage = Storage,
- index = mnesia:table_info(Id, index)
- },
- Tab = if Storage == disc_only_copies ->
- Tab0#tab{fixed = element(2, dets:info(Id, safe_fixed)) /= []};
- (Storage == ram_copies) orelse
- (Storage == disc_copies) ->
- Tab0#tab{fixed = ets:info(Id, fixed),
- compressed = ets:info(Id, compressed)};
- true -> Tab0
- end,
- [Tab|Acc]
- catch _:_What ->
- %% io:format("Skipped ~p: ~p ~n",[Id, _What]),
- Acc
- end
- end,
- lists:foldl(Info, [], mnesia:system_info(tables)).
+list_to_tabrec(PL) ->
+ #tab{name = proplists:get_value(name, PL),
+ id = proplists:get_value(id, PL, ignore),
+ size = proplists:get_value(size, PL, 0),
+ memory= proplists:get_value(memory, PL, 0), %% In bytes
+ owner=proplists:get_value(owner, PL),
+ reg_name=proplists:get_value(reg_name, PL),
+ protection = proplists:get_value(protection, PL, public),
+ type=proplists:get_value(type, PL, set),
+ keypos=proplists:get_value(keypos, PL, 1),
+ heir=proplists:get_value(heir, PL, none),
+ compressed=proplists:get_value(compressed, PL, false),
+ fixed=proplists:get_value(fixed, PL, false),
+ %% Mnesia Info
+ storage =proplists:get_value(storage, PL),
+ index = proplists:get_value(index, PL)}.
display_table_info(Parent0, Node, Source, Table) ->
Parent = observer_lib:get_wx_parent(Parent0),
@@ -377,59 +317,6 @@ list_to_strings([A]) -> integer_to_list(A);
list_to_strings([A,B]) ->
integer_to_list(A) ++ " ," ++ list_to_strings(B).
-sys_tables() ->
- [ac_tab, asn1,
- cdv_dump_index_table, cdv_menu_table, cdv_decode_heap_table,
- cell_id, cell_pos, clist,
- cover_internal_data_table, cover_collected_remote_data_table, cover_binary_code_table,
- code, code_names, cookies,
- corba_policy, corba_policy_associations,
- dets, dets_owners, dets_registry,
- disk_log_names, disk_log_pids,
- eprof, erl_atom_cache, erl_epmd_nodes,
- etop_accum_tab, etop_tr,
- ets_coverage_data,
- file_io_servers,
- gs_mapping, gs_names, gstk_db,
- gstk_grid_cellid, gstk_grid_cellpos, gstk_grid_id,
- httpd,
- id,
- ign_req_index, ign_requests,
- index,
- inet_cache, inet_db, inet_hosts,
- 'InitialReferences',
- int_db,
- interpreter_includedirs_macros,
- ir_WstringDef,
- lmcounter, locks,
-% mnesia_decision,
- mnesia_gvar, mnesia_stats,
-% mnesia_transient_decision,
- pg2_table,
- queue,
- schema,
- shell_records,
- snmp_agent_table, snmp_local_db2, snmp_mib_data, snmp_note_store, snmp_symbolic_ets,
- tkFun, tkLink, tkPriv,
- ttb, ttb_history_table,
- udp_fds, udp_pids
- ].
-
-sys_processes() ->
- [auth, code_server, global_name_server, inet_db,
- mnesia_recover, net_kernel, timer_server, wxe_master].
-
-mnesia_tables() ->
- [ir_AliasDef, ir_ArrayDef, ir_AttributeDef, ir_ConstantDef,
- ir_Contained, ir_Container, ir_EnumDef, ir_ExceptionDef,
- ir_IDLType, ir_IRObject, ir_InterfaceDef, ir_ModuleDef,
- ir_ORB, ir_OperationDef, ir_PrimitiveDef, ir_Repository,
- ir_SequenceDef, ir_StringDef, ir_StructDef, ir_TypedefDef,
- ir_UnionDef, logTable, logTransferTable, mesh_meas,
- mesh_type, mnesia_clist, orber_CosNaming,
- orber_objkeys, user
- ].
-
handle_error(Foo) ->
Str = io_lib:format("ERROR: ~s~n",[Foo]),
observer_lib:display_info_dialog(Str).
@@ -465,6 +352,3 @@ update_grid2(Grid, #opt{sort_key=Sort,sort_incr=Dir}, Tables) ->
end,
lists:foldl(Update, 0, ProcInfo),
ProcInfo.
-
-ignore(true, Reason) -> throw(Reason);
-ignore(_,_ ) -> ok.