Fix to work with ejabberd 14

This commit is contained in:
Badlop 2014-12-17 17:22:59 +01:00
parent 4f3a724927
commit 5eafb8188a
2 changed files with 21 additions and 19 deletions

View File

@ -27,18 +27,18 @@
start(_Host, Opts) -> start(_Host, Opts) ->
case whereis(?PROCNAME) of case whereis(?PROCNAME) of
undefined -> undefined ->
Interval = gen_mod:get_opt(interval, Opts, 5), Interval = gen_mod:get_opt(interval, Opts, fun(O) -> O end, 5),
I = Interval*60*1000, I = Interval*60*1000,
%I = 9000, %+++ %I = 9000, %+++
Type = gen_mod:get_opt(type, Opts, html), Type = gen_mod:get_opt(type, Opts, fun(O) -> O end, html),
Split = gen_mod:get_opt(split, Opts, false), Split = gen_mod:get_opt(split, Opts, fun(O) -> O end, false),
BaseFilename = gen_mod:get_opt(basefilename, Opts, "/tmp/ejasta"), BaseFilename = binary_to_list(gen_mod:get_opt(basefilename, Opts, fun(O) -> O end, "/tmp/ejasta")),
Hosts_all = ejabberd_config:get_global_option(hosts), Hosts_all = ejabberd_config:get_global_option(hosts, fun(O) -> O end),
Hosts = gen_mod:get_opt(hosts, Opts, Hosts_all), Hosts = gen_mod:get_opt(hosts, Opts, fun(O) -> O end, Hosts_all),
register(?PROCNAME, spawn(?MODULE, loop, [I, Hosts, BaseFilename, Type, Split])); register(?PROCNAME, spawn(?MODULE, loop, [I, Hosts, BaseFilename, Type, Split]));
_ -> _ ->
@ -215,7 +215,7 @@ write_stats(I, node, Node, F, T) ->
fwbr(F, T), fwbr(F, T),
CPUTime = element(1, rpc:call(Node, erlang, statistics, [runtime])), CPUTime = element(1, rpc:call(Node, erlang, statistics, [runtime])),
fw(F, "~s (ms): ~w",[?T("CPUtime"), CPUTime]), fw(F, "~s (ms): ~w",["CPUtime", CPUTime]),
fwbr(F, T), fwbr(F, T),
MT = trunc(erlang:memory(total)/1024), MT = trunc(erlang:memory(total)/1024),
@ -362,12 +362,12 @@ get(Node, A) ->
fw(F, S) -> file:write(F, S). fw(F, S) -> file:write(F, S).
fw(F, S, O) -> file:write(F, io_lib:format(S, O)). fw(F, S, O) -> file:write(F, io_lib:format(S, O)).
fwt(F, S, O, html) -> fw(F, "~s: ~p<br/>~n",[?T(S), O]); fwt(F, S, O, html) -> fw(F, "~s: ~p<br/>~n",[S, O]);
fwt(F, S, O, txt) -> fw(F, "~s: ~p~n",[?T(S), O]); fwt(F, S, O, txt) -> fw(F, "~s: ~p~n",[S, O]);
fwt(F, _, O, dat) -> fw(F, "~p~n",[O]). fwt(F, _, O, dat) -> fw(F, "~p~n",[O]).
fwts(F, S, O, html) -> fw(F, "~s: ~s<br/>~n",[?T(S), O]); fwts(F, S, O, html) -> fw(F, "~s: ~s<br/>~n",[S, O]);
fwts(F, S, O, txt) -> fw(F, "~s: ~s~n",[?T(S), O]); fwts(F, S, O, txt) -> fw(F, "~s: ~s~n",[S, O]);
fwts(F, _, O, dat) -> fw(F, "~s~n",[O]). fwts(F, _, O, dat) -> fw(F, "~s~n",[O]).
%fwtsn(F, S, O, html) -> fw(F, "~s: ~s<br/>",[?T(S), O]); %fwtsn(F, S, O, html) -> fw(F, "~s: ~s<br/>",[?T(S), O]);

View File

@ -221,7 +221,7 @@ remove_user(_User, Server) ->
user_send_packet(FromJID, ToJID, NewEl) -> user_send_packet(FromJID, ToJID, NewEl) ->
%% Registrarse para tramitar Host/mod_stats2file %% Registrarse para tramitar Host/mod_stats2file
case list_to_atom(ToJID#jid.lresource) of case list_to_atom(binary_to_list(ToJID#jid.lresource)) of
?MODULE -> received_response(FromJID, ToJID, NewEl); ?MODULE -> received_response(FromJID, ToJID, NewEl);
_ -> ok _ -> ok
end. end.
@ -618,7 +618,9 @@ get_s2sconnections(Host) ->
%% {Host, Res} = ets:foldl(F2, {Host, 0}, irc_connection), %% {Host, Res} = ets:foldl(F2, {Host, 0}, irc_connection),
%% Res. %% Res.
is_host(Host, Subhost) -> is_host(HostBin, SubhostBin) ->
Host = binary_to_list(HostBin),
Subhost = binary_to_list(SubhostBin),
Pos = string:len(Host)-string:len(Subhost)+1, Pos = string:len(Host)-string:len(Subhost)+1,
case string:rstr(Host, Subhost) of case string:rstr(Host, Subhost) of
Pos -> true; Pos -> true;
@ -763,15 +765,15 @@ user_logout(User, Host, Resource, _Status) ->
end. end.
request_iqversion(User, Host, Resource) -> request_iqversion(User, Host, Resource) ->
From = jlib:make_jid("", Host, atom_to_list(?MODULE)), From = jlib:make_jid(<<"">>, Host, list_to_binary(atom_to_list(?MODULE))),
FromStr = jlib:jid_to_string(From), FromStr = jlib:jid_to_string(From),
To = jlib:make_jid(User, Host, Resource), To = jlib:make_jid(User, Host, Resource),
ToStr = jlib:jid_to_string(To), ToStr = jlib:jid_to_string(To),
Packet = {xmlelement,"iq", Packet = {xmlel,<<"iq">>,
[{"from",FromStr}, {"to",ToStr}, {"type","get"}, [{<<"from">>,FromStr}, {<<"to">>,ToStr}, {<<"type">>,<<"get">>},
{"id", "statsdx" ++ randoms:get_string()}], {<<"id">>, list_to_binary("statsdx"++randoms:get_string())}],
[{xmlelement, "query", [{xmlel, <<"query">>,
[{"xmlns","jabber:iq:version"}], []}]}, [{<<"xmlns">>,<<"jabber:iq:version">>}], []}]},
ejabberd_local:route(From, To, Packet). ejabberd_local:route(From, To, Packet).
%% cuando el virtualJID recibe una respuesta iqversion, %% cuando el virtualJID recibe una respuesta iqversion,