OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / log_adm.jsp
1 <%@ page import="org.ultramonkey.l7.model.*,
2                                  org.ultramonkey.l7.controller.*,
3                                  org.ultramonkey.l7.view.*, java.util.*,
4                                  java.text.SimpleDateFormat,java.text.NumberFormat"
5         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
6 <%
7     /*
8      * check session
9      */
10     if (session.isNew()) {
11         MessageView error = new MessageView(41255, LogCategorySet.GUI_USER_AUTHENTICATION, Message.INVALID_SESSSION); 
12         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
13         response.sendRedirect(RedirectPages.LOGIN);
14         return;
15     }
16
17     /*
18      * get result message
19      */
20     MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
21     String errorMessage = "";
22     int errorNumber = 0;
23     String category = "";
24     String resultJudge = "success";
25     if (message != null) {
26       errorMessage = message.getMessage();
27       errorNumber = message.getErrno();
28       category = message.getCategory();
29       session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
30       if ( errorNumber >= ErrNo.ERRORNUMBER )
31           resultJudge = "error";
32     }
33     
34     /*
35      * get command message
36      */
37     MessageView commandmessage = (MessageView) session.getAttribute(SessionKeys.COMMAND_MESSAGE);
38     String commandMessage = "";
39     int commandNumber = 0;
40     String commandCategory = "";
41     String commandJudge = "success";
42     if (commandmessage != null) {
43       commandMessage = commandmessage.getMessage();
44       commandNumber = commandmessage.getErrno();
45       commandCategory = commandmessage.getCategory();
46       session.setAttribute(SessionKeys.COMMAND_MESSAGE, null);
47       if ( commandNumber >= ErrNo.ERRORNUMBER )
48           commandJudge = "error";
49     }
50     
51     /*
52      * get adm_log info
53      */
54      L7guiFramework framework = new L7guiFramework();
55      LogData logdata = framework.getLogData();
56      
57      if (logdata == null){
58          MessageView error = new MessageView(41256, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
59          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
60          response.sendRedirect(RedirectPages.LOGIN);
61          return;
62      }
63
64      LogSet data = logdata.admLog;
65      
66      if (data == null){
67          MessageView error = new MessageView(41257, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
68          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
69          response.sendRedirect(RedirectPages.LOGIN);
70          return;
71      } 
72
73      Vector<LogFileData> logfiles = data.logFiles;
74      if (logfiles == null){
75          MessageView error = new MessageView(41258, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
76          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
77          response.sendRedirect(RedirectPages.LOGIN);
78          return;
79      }
80      
81      HashMap<LogData.LogCategory, LogData.LogLevel> logcategoryset = data.logLevel;
82      if (logcategoryset == null){
83          MessageView error = new MessageView(41259, LogCategorySet.GUI_LOG, Message.UNEXPECTED_ERROR);
84          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
85          response.sendRedirect(RedirectPages.LOGIN);
86          return;
87      }
88      
89      /*
90       * get cluster status
91       */
92      ClusterData cd = framework.getClusterData();
93      
94      if (cd == null){
95          MessageView error = new MessageView(41260, LogCategorySet.GUI_IO_COMMAND, Message.CLUSTER_DATA_ERROR);
96          session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
97          response.sendRedirect(RedirectPages.LOGIN);
98      }
99       
100     /*
101      * fix style seat
102      */
103     String cssSeat = "l7gui_single_style.css";
104     if ( cd.self_status == ClusterStatus.ACTIVE ){
105       cssSeat = "l7gui_act_style.css";
106     }
107     else if ( cd.self_status == ClusterStatus.STANDBY ){
108       cssSeat = "l7gui_sby_style.css";
109     }
110
111 %>
112
113
114 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
115
116 <html>
117   <head>
118     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
119         <meta http-equiv="Pragma" content="no-cache">
120         <meta http-equiv="Cache-Control" content="no-cache">
121         <meta http-equiv="Expires" content="0">                 
122         <meta http-equiv="Content-Script-Type" content="text/javascript" />
123     <meta http-equiv="Content-Style-Type" content="text/css" />
124     <script src="l7gui.js" type="text/javascript"></script>
125     <noscript> 
126          <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
127       </noscript> 
128     <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
129     <link rel="shortcut icon" href="images/favicon.ico"/>
130         <title>Log - Admin command (l7vsadm) -</title>
131     </head>
132     
133   
134   <body class="normal">
135   <jsp:include page="menu.jsp" flush="false"/>
136   <div id="content">
137
138
139     <h1>Log - Admin command (l7vsadm) -</h1>
140     <%
141     if ( (message != null ) && (errorMessage != null) ) {
142     %>
143     
144     <p class="<%=resultJudge %>">[<%=category%>-<%=errorNumber%>]</p>
145     <p class="<%=resultJudge %>"><%=errorMessage%></p>
146     
147     <%
148     } else if ( (commandmessage != null) && (commandMessage != null) ) {
149     %>
150     <p class="<%=commandJudge %>">[<%=commandCategory%>-<%=commandNumber%>]</p>
151     <p class="<%=commandJudge %>"><%=commandMessage%></p>
152     <%
153     }
154     %>
155     
156     <h2> Download Log File</h2>
157     <h4>Please select the following list you would like to download the log file. </h4>
158       <table  class="infotable" cellspacing="0">
159
160       <tr>
161       <th>LogFileName</th><th>LastUpdate</th><th>FileSize(byte)</th>
162       </tr>
163       
164       <%
165                 SimpleDateFormat dfm = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");
166                 NumberFormat num = NumberFormat.getInstance();
167         Iterator<LogFileData> i = logfiles.iterator();
168         
169         while ( i.hasNext() ){
170             LogFileData log = (LogFileData) i.next();
171             
172             if ( log != null && log.fileName != null){
173                    out.println("<tr>");
174                    out.println("<td>");
175                    out.println("<a href=\"LogOutputServlet?type=" + LogCategorySet.L7VSADM + "&log=" + log.fileName + "\">" + log.fileName + "</a>");
176                    out.println("</td>");
177                    out.println("<td class=\"center\">" + dfm.format(log.time) + "</td>");            
178                    out.println("<td class=\"right\">" + num.format(log.size) + "</td>");               
179                    out.println("</tr>");
180             }
181         }
182       %>     
183     </table>      
184
185     <br />
186
187     <h2>Change Log Level</h2>
188     <h4>Please select log level you would like to change.</h4>
189     
190     <form method="post" action="LogLevelServlet" name="log_adm">
191     <input type="hidden" name="type" value="<%=LogCategorySet.L7VSADM %>">
192       <table  class="infotable" cellspacing="0">  
193
194       <tr>
195         <th>Category</th><th>Level</th>
196       </tr>
197         <% 
198             TreeSet<LogData.LogCategory> tree = new TreeSet<LogData.LogCategory>(logcategoryset.keySet());
199             Iterator<LogData.LogCategory> it = tree.iterator();
200         
201         while (it.hasNext()) {
202             LogData.LogCategory logcategory = (LogData.LogCategory) it.next();
203   
204             if (logcategory != null){
205         %>
206       <tr>
207       <td><%= logcategory %></td>
208       <td>
209       <select id="<%= logcategory %>" name="<%= logcategory %>">
210         <option value="<%=LogData.LogLevel.NONE %>"<%
211                   if ( logcategoryset.get(logcategory) == LogData.LogLevel.NONE)
212                           out.print(" selected");
213                   %>></option>
214         <option value="<%=LogData.LogLevel.INFO %>"<%
215                   if ( logcategoryset.get(logcategory) == (LogData.LogLevel.INFO)){ 
216                     out.print(" selected");
217                   }
218                   %>>INFO</option>
219         <option value="<%=LogData.LogLevel.DEBUG %>"<%
220                    if ( logcategoryset.get(logcategory) == (LogData.LogLevel.DEBUG)) {
221                        out.print(" selected");
222                    }
223                   %>>DEBUG</option>
224         <option value="<%=LogData.LogLevel.ERROR %>"<%
225                   if (logcategoryset.get(logcategory) == (LogData.LogLevel.ERROR)){
226                       out.print(" selected");
227                   }
228                   %>>ERROR</option>          
229         <option value="<%=LogData.LogLevel.WARN %>"<%
230                   if ( logcategoryset.get(logcategory) == (LogData.LogLevel.WARN)){ 
231                     out.print(" selected");
232                   }
233                   %>>WARN</option>
234         <option value="<%=LogData.LogLevel.FATAL %>"<%
235                   if ( logcategoryset.get(logcategory) == (LogData.LogLevel.FATAL)){ 
236                     out.print(" selected");
237                   }
238                   %>>FATAL</option>
239      </select>
240       </td>
241       </tr>
242           <%
243           }
244       }
245       %>
246       </table>
247
248       <br>
249       <input type="submit" name="button" value="<%= ButtonMode.SAVE %>" onClick="return confirm(log_adm_save)" />
250       <%
251           if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY) {
252       %>
253       <input type="submit" name="button" value="<%= ButtonMode.SAVESYNC %>" onClick="return confirm(log_adm_savesync)" />
254       <%
255           }
256       %>    
257     </form>
258   
259   </div>
260   </body>
261 </html>