34
34
graph(SessionID, Env, Input) ->
35
35
mod_esi:deliver(SessionID, header()),
36
case graph(Env,Input) of
37
Binaries when is_list(Binaries) ->
38
lists:foreach(fun (B) ->
39
mod_esi:deliver(SessionID, binary_to_list(B))
42
mod_esi:deliver(SessionID, binary_to_list(Binary))
36
mod_esi:deliver(SessionID, binary_to_list(graph(Env, Input))).
46
39
%% @spec activity(SessionID, Env, Input) -> term()
47
40
%% @doc An ESI callback implementation used by the httpd server.
49
42
activity(SessionID, Env, Input) ->
50
43
mod_esi:deliver(SessionID, header()),
51
case activity_bar(Env,Input) of
52
Binaries when is_list(Binaries) ->
53
lists:foreach(fun (B) ->
54
mod_esi:deliver(SessionID, binary_to_list(B))
57
mod_esi:deliver(SessionID, binary_to_list(Binary))
44
mod_esi:deliver(SessionID, binary_to_list(activity_bar(Env, Input))).
60
46
proc_lifetime(SessionID, Env, Input) ->
61
47
mod_esi:deliver(SessionID, header()),
62
case proc_lifetime(Env,Input) of
63
Binaries when is_list(Binaries) ->
64
lists:foreach(fun (B) ->
65
mod_esi:deliver(SessionID, binary_to_list(B))
68
mod_esi:deliver(SessionID, binary_to_list(Binary))
48
mod_esi:deliver(SessionID, binary_to_list(proc_lifetime(Env, Input))).
71
50
percentage(SessionID, Env, Input) ->
72
51
mod_esi:deliver(SessionID, header()),
73
case percentage(Env,Input) of
74
Binaries when is_list(Binaries) ->
75
lists:foreach(fun (B) ->
76
mod_esi:deliver(SessionID, binary_to_list(B))
79
mod_esi:deliver(SessionID, binary_to_list(Binary))
52
mod_esi:deliver(SessionID, binary_to_list(percentage(Env,Input))).
82
54
scheduler_graph(SessionID, Env, Input) ->
83
55
mod_esi:deliver(SessionID, header()),
84
case scheduler_graph(Env,Input) of
85
Binaries when is_list(Binaries) ->
86
lists:foreach(fun (B) ->
87
mod_esi:deliver(SessionID, binary_to_list(B))
90
mod_esi:deliver(SessionID, binary_to_list(Binary))
56
mod_esi:deliver(SessionID, binary_to_list(scheduler_graph(Env, Input))).
93
58
graph(_Env, Input) ->
94
59
Query = httpd:parse_query(Input),
96
61
RangeMin = percept_html:get_option_value("range_min", Query),
97
62
RangeMax = percept_html:get_option_value("range_max", Query),
98
Pids = percept_html:get_option_value("pids", Query),
99
Width = percept_html:get_option_value("width", Query),
100
Height = percept_html:get_option_value("height", Query),
63
Pids = percept_html:get_option_value("pids", Query),
64
Width = percept_html:get_option_value("width", Query),
65
Height = percept_html:get_option_value("height", Query),
102
67
% Convert Pids to id option list
103
IDs = [ {id, ID} || ID <- Pids],
68
IDs = [ {id, ID} || ID <- Pids],
106
StartTs = percept_db:select({system, start_ts}),
107
TsMin = percept_analyzer:seconds2ts(RangeMin, StartTs),
108
TsMax = percept_analyzer:seconds2ts(RangeMax, StartTs),
71
StartTs = percept_db:select({system, start_ts}),
72
TsMin = percept_analyzer:seconds2ts(RangeMin, StartTs),
73
TsMax = percept_analyzer:seconds2ts(RangeMax, StartTs),
110
Options = [{ts_exact, true},{ts_min, TsMin},{ts_max, TsMax} | IDs],
75
Options = [{ts_exact, true},{ts_min, TsMin},{ts_max, TsMax} | IDs],
112
77
Activities = percept_db:select({activity, Options}),
114
Counts = percept_analyzer:activities2count(Activities, StartTs),
79
Counts = percept_analyzer:activities2count(Activities, StartTs),
116
81
percept_image:graph(Width, Height,Counts).
118
83
scheduler_graph(_Env, Input) ->