appmon_web.erl

来自「OTP是开放电信平台的简称」· ERL 代码 · 共 1,037 行 · 第 1/3 页

ERL
1,037
字号
	"<FORM Name=reload>" ++	"<INPUT TYPE=\"button\" onClick=\"node_selected()\"               VALUE=\"Reload\">\n" ++	"</FORM>" ++	"<!--<A HREF=\"../../appmon/application_help.html\" TARGET=main>Help</A>-->".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Print spaces between the application name and the spec link       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%print_space(N,Space)when N >0 ->    print_space(N-1,"&nbsp;" ++ Space);print_space(_N,Space)->    Space.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The Private functions that do the job                              %%%% To build the the page that shows process in an application         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Generates the javascript that govern the look of the page that      %%%%the processes of an application                                     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Args is the list whit input args should be App Mode, Nodeapplication_javascript(Args)when length(Args)>=3 ->    Vars=	"<SCRIPT>            var proc;            var app=\"" ++ element(2,lists:nth(1,Args)) ++ "\";            var node=\"" ++ element(2,lists:nth(3,Args)) ++ "\";",    CommonFuncs=	" function reload_bottom_frame()          {parent.proc_data.location.href=\"/appmon/blank.html\";}	 function show_process_info()          {            if(proc.indexOf(\"#Port\")== -1)            {    	      if(proc.charAt(0)==\'<\')                 window.location=\"./proc_info?name=\" + proc + \"&node=\" + node                else                {                  start=proc.indexOf(\"<\");                  endpoint=proc.lastIndexOf(\">\");                  window.location=\"./proc_info?name=\" + proc.slice(start,endpoint+1) + \"&node=\" + node  ;               }           }                  }        function trace()        {           if(proc.charAt(0)==\'<\')              window.location=\"./trace?name=\" + app +  \"&mode=\" + get_mode() +  \"&node=\" + node + \"&proc=\" +  proc;           else           {              start=proc.indexOf(\"<\");              endpoint=proc.lastIndexOf(\">\");              window.location=\"./trace?name=\" + app + \"&mode=\" + get_mode() + \"&node=\" + node + \"&proc=\" +                  proc.slice(start,endpoint+1) ;           }                        }          function reload_page()\n       {          window.location=\"./application_info?name=\" + app + \"&mode=\" + get_mode() + \"&node=\" + node ;        }       function get_mode()       {          for (i= 0; i < document.reload_form.mode.length; i++)          {             if (document.reload_form.mode[i].checked)                  return(document.reload_form.mode[i].value);          }          return(\"all\");       }",       Vars++CommonFuncs++"</SCRIPT>";application_javascript(_)->    "<SCRIPT></SCRIPT>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Create the body i.e the process tree for the applications whose    %%%% name is the second arg in the first tuple                          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%args is the list [{_,Appname},{_,Mode},{_Node}]application_body(Args) when is_list(Args),length(Args) >= 3 ->    App=element(2,lists:nth(1,Args)),    Mode=element(2,lists:nth(2,Args)),    Node=element(2,lists:nth(3,Args)),    "<BODY BGCOLOR=\"FFFFFF\" onLoad=reload_bottom_frame() >"	++ mode_selection(Mode) ++ 	selected_app_header(App,Node) ++ process_tree(App,Mode,Node)++ 	"</BODY>";%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% If the pattern above ain't match then something is wrong           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%application_body(_Whatever)->    "Please use the links to the left".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Create the part of the process tree page side where the user can   %%%% select the mode the view the tree in.                              %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%mode_selection(Mode)->    "<FORM NAME=\"reload_form\">\n" ++	"<TABLE>" ++	"<TR>\n" ++	"<!--<TD><INPUT TYPE=\"button\" NAME=\"refresh_but\" VALUE=\"Reload\" onClick=\"reload_page()\">         &nbsp;&nbsp;&nbsp;&nbsp;</TD>\n-->" ++	print_radio_buttons([{"all","All processes"},{"sup_child","Supervised processes"},	{"sup","Only supervisors"}],Mode) ++	"</TR>\n </TABLE>\n" ++	"</FORM>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Print the radiobuttons. if the mode is the one the current         %%%% radiobutton represent set the one checked                          %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%print_radio_buttons([],_)->    [];print_radio_buttons([{Mode,Name}|Rest],Mode)->    "<TD><INPUT TYPE=\"radio\" NAME=\"mode\" CHECKED=\"true\" VALUE=\""++ 	Mode ++"\" onClick=\"reload_page()\">&nbsp;&nbsp;" ++Name ++	"</TD>\n" ++ print_radio_buttons(Rest,Mode);print_radio_buttons([{Mode1,Name}|Rest],Mode)->    "<TD><INPUT TYPE=\"radio\" NAME=\"mode\" VALUE=\""++ Mode1 ++	"\" onClick=\"reload_page()\">&nbsp;&nbsp;" ++ Name ++	"</TD>\n" ++	print_radio_buttons(Rest,Mode).       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The part that shows the name of the application  that the process  %%%% tree represent                                                     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%selected_app_header(App,Node)->    {Year,Mon,Day}=date(),    "<TABLE>        <TR>           <TD>Node:</TD>           <TD>" ++Node ++"</TD>        </TR>        <TR>           <TD>Application:</TD>           <TD>" ++App ++"</TD>        </TR>       <TR>            <TD>Date:</TD>           <TD>" ++ integer_to_list(Day) ++ "/" ++                  integer_to_list(Mon) ++"&nbsp;-&nbsp;"++                  integer_to_list(Year)  ++          "</TD>         </TR>     </TABLE>     <TABLE WIDTH=100%>       <TR>         <TD>             <HR WIDTH=\"80%\">             <!--<FONT SIZE=4>Process tree</FONT>             <HR ALIGN=\"center\" WIDTH=\"80%\">-->         </TD>       </TR>     </TABLE>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%get the process tree from process_info and build the nested         %%%% unordered list that represent the applications process tree        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%process_tree(App,Mode,Node)->    case process_info:get_processes(list_to_atom(App),				    list_to_atom(Mode),				    list_to_atom(Node)) of	unknown->	    "Unknown application please update application tree";	{Tree,Traced_dict} ->	    "<UL>" ++		htmlify_tree(Tree,Traced_dict,1,Node,Mode,App) ++		"</UL>"    end.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Build each node in the tree and then build its children            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%htmlify_tree({Pid,Childs,Childs2},Proc_tab,N,Node,Mode,App)->    case ets:lookup(Proc_tab,Pid) of	[] when N<3->	     print_pid(Pid,Node,Mode,App,notrace)++		htmlify_prim_child(Childs,Proc_tab,N+1,Node,Mode,App) ++		htmlify_sec_child(Childs2);	[_Traced]->	    print_pid(Pid,Node,Mode,App,"<FONT SIZE=2 COLOR=\"firebrick\">Stop Trace</FONT>")++		htmlify_prim_child(Childs,Proc_tab,N+1,Node,Mode,App) ++		htmlify_sec_child(Childs2);	[]-> 	    print_pid(Pid,Node,Mode,App,"<FONT SIZE=2>Start Trace</FONT>")++		htmlify_prim_child(Childs,Proc_tab,N+1,Node,Mode,App) ++		htmlify_sec_child(Childs2)	      	     end.print_pid(Pid,Node,_Mode,_App,notrace)->    "<LI><A TARGET=\"proc_data\" STYLE=\"text-decoration:none; color:blue\" HREF=\"./proc_info?name=" ++ urlify_pid(Pid) ++ 	"&node="++ Node  ++" \" >"++ htmlify_pid(Pid,[])  ++ 	"</A>";print_pid([$P,$o,$r,$t|Rest],_Node,_Mode,_App,_TrMode)->    "<LI>" ++ htmlify_pid([$P,$o,$r,$t|Rest],[]);print_pid(Pid,Node,Mode,App,TrMode)->    "<LI><A TARGET=\"proc_data\" STYLE=\"text-decoration:none; color:blue\" HREF=\"./proc_info?name=" ++ 	urlify_pid(Pid) ++ "&node="++ Node  ++" \" >"++	htmlify_pid(Pid,[])  ++ "</A>"++ 	"&nbsp;&nbsp;&nbsp                <A HREF=\"./trace?app="++App++"&mode="++Mode++	"&node="++Node++"&proc="++urlify_pid(Pid)++"\">               "++TrMode++"</A>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Change the '<' sign and the '>' sign to the html representation   %%%% of the sign                                                       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%htmlify_pid([60|Pid],New)->    htmlify_pid(Pid,";tl&"++New);htmlify_pid([139|Pid],New)->    htmlify_pid(Pid,";tl&"++New);htmlify_pid([62|Pid],New)->    htmlify_pid(Pid,";tg&"++New);htmlify_pid([155|Pid],New)->    htmlify_pid(Pid,";tg&"++New);htmlify_pid([Chr|Pid],New)->    htmlify_pid(Pid,[Chr|New]);htmlify_pid([],New)->    lists:reverse(New).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Change the < and > sign to the representation of the signs in      %%%% the HTTP protocol                                                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%urlify_pid(Pid) ->    case regexp:first_match(Pid,"[<].*[>]") of	{match,Start,Len}->	    "%3C"++string:substr(Pid,Start+1,Len-2)++"%3E";	_->	    Pid    end.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Change the < and > sign from the representation of the signs in    %%%% the HTTP protocol                                                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%unurlify_pid(Pid)->    unurlify_pid(Pid,[]).unurlify_pid([$%,$3,$C|Rest],New)->    unurlify_pid(Rest,[60|New]);unurlify_pid([$%,$3,$E|Rest],New)->    unurlify_pid(Rest,[62|New]);unurlify_pid([Chr|Rest],New)->    unurlify_pid(Rest,[Chr|New]);unurlify_pid([],New)->    lists:reverse(New).%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Make html of the list of primary childs                            %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%htmlify_prim_child([],_Proc_tab,_N,_Node,_Mode,_App)->    [];htmlify_prim_child(Childs,Proc_tab,N,Node,Mode,App)->    Fun=fun(Child)->		htmlify_tree(Child,Proc_tab,N,Node,Mode,App)	end,    "<UL>\n" ++ lists:map(Fun,Childs) ++ "</UL>\n".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Make html of hte list whit sedondary childs, they has no childs    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%htmlify_sec_child([])->    [];htmlify_sec_child(Sec_child_list)->    Htmlify_child=fun(Pid1)->			  "<LI><FONT COLOR=\"#FF2222\">" ++ Pid1 ++			      "</FONT></LI>\n"		  end,    "<UL>" ++ lists:map(Htmlify_child,Sec_child_list) ++ "</UL>\n".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The Private functions that do the job                              %%%% To build the the page that shows process data                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The function that creates the collects the various part of         %%%% the side that shows information about a specific process,          %%%% Pid_name should be the list representation of a pid                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%process_body(Args) when length(Args)==2->    Pid=element(2,lists:nth(1,Args)),    Node=element(2,lists:nth(2,Args)),    "<BODY BGCOLOR=\"#FFFFFF\">"  ++	process_information_table(Pid,Node) ++ "</BODY>";process_body(_)->    "<BODY BGCOLOR=\"#FFFFFF\">Please dont call this side manually</BODY>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Create the table that shows the name of the pid to show extended   %%%% info about                                                         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Get the table that shows the extended info about a process         %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%process_information_table(Pid_name,Node)->    PidID=unurlify_pid(Pid_name),    case catch list_to_pid(PidID) of	Pid when is_pid(Pid) -> 	    get_process_table(Pid,Node);	_Other ->	    io_lib:format("Not a process id ~s",[PidID])    end.	      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Create the table that shoows the extended info about processes     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%get_process_table(Pid,Node_name) when is_list(Node_name)->    Node=list_to_atom(Node_name),    get_process_table(Pid,Node);get_process_table(Pid,Node) when is_atom(Node)->    case lists:member(Node,[node()|nodes()]) of	true-> 	    Proc_data=process_info:get_process_data(Pid,Node),	    "<TABLE BORDER=1 >                <TR BGCOLOR=\"#8899AA\"><TD COLSPAN=6 ALIGN=\"center\" >                        <FONT size=4> Process" ++		htmlify_pid(pid_to_list(Pid),[])  ++  "</FONT>               </TD></TR>" ++		   start_process_proc_data(Proc_data) ++		"</TABLE><BR><BR>";	_ ->	    "Please try again the Node dont exists"    end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?