OSDN Git Service

Initial commit
[ultramonkey-l7/l7gui.git] / src / WebContent / top.jsp
1 <%@ page import="org.ultramonkey.l7.model.*, org.ultramonkey.l7.controller.*, org.ultramonkey.l7.view.*, java.util.*"
2         language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
3 <%
4
5         /*
6          * check session
7          */
8         if (session.isNew()) {
9         MessageView error = new MessageView(41398, LogCategorySet.GUI_USER_AUTHENTICATION,
10                         Message.INVALID_SESSSION);
11         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
12         response.sendRedirect(RedirectPages.LOGIN);
13         return;
14         }
15
16         /*
17          * get result message
18          */
19         MessageView message = (MessageView) session.getAttribute(SessionKeys.RESULT_MESSAGE);
20         String errorMessage = null;
21         int errorNumber = 0;
22         String category = "";
23         if ( (message != null) && (errorMessage != null) ) {
24                 errorMessage = message.getMessage();
25                 errorNumber = message.getErrno();
26                 category = message.getCategory();
27                 session.setAttribute(SessionKeys.RESULT_MESSAGE, null);
28         }
29
30         /*
31          * get l7vsadm data from L7guiFramework
32          */
33         L7guiFramework framework = new L7guiFramework();
34         L7vsAdmData admDataList = framework.getAdmData();
35         if (admDataList == null) {
36                 MessageView error = new MessageView(41399, LogCategorySet.GUI_VIRTUALSERVICE,
37                 Message.UNEXPECTED_ERROR);
38                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
39                 response.sendRedirect(RedirectPages.LOGIN);
40                 return;
41         }
42
43         /*
44          * get directord data from L7guiFramework
45          */
46         DirectorData dd = framework.getDirectorData();
47         if (dd == null){
48                 MessageView error = new MessageView(41400, LogCategorySet.GUI_IO_FILE,
49                                 Message.CLUSTER_DATA_ERROR);
50                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
51                 response.sendRedirect(RedirectPages.LOGIN);
52                 return;
53         }
54         
55         String checkTimeout = dd.checkTimeOut;
56         if ( (checkTimeout == null) || (checkTimeout.length() == 0) )
57                 checkTimeout = "-";
58         else 
59                 checkTimeout = checkTimeout + " [sec]";
60         
61         String negotiateTimeOut = dd.negotiateTimeOut;
62         if ( (negotiateTimeOut == null) || (negotiateTimeOut.length() == 0) )
63                 negotiateTimeOut = "-";
64         else 
65                 negotiateTimeOut = negotiateTimeOut + " [sec]";
66
67         String checkInterval = dd.checkInterval;
68         if ( (checkInterval == null) || (checkInterval.length() == 0) )
69                 checkInterval = "-";
70         else 
71                 checkInterval = checkInterval + " [sec]";
72         
73         String checkCount = dd.checkCount;
74         if ( (checkCount == null) || (checkCount.length() == 0) )
75                 checkCount = "-";
76         else 
77                 checkCount = checkCount + " [times]";
78
79         String callback = dd.callback;
80         if ( (callback == null) || (callback.length() == 0) )
81                 callback = "-";
82
83         String fallback = dd.fallback;
84         if ( (fallback == null) || (fallback.length() == 0) )
85                 fallback = "-";
86         
87         String logFile = dd.logfile;
88         if ( (logFile == null) || (logFile.length() == 0) )
89                 logFile = "-";
90         String execute = dd.execute;
91         if ( (execute == null) || (execute.length() == 0) )
92                 execute = "-";
93         
94         String supervised = dd.supervised;
95         if ( (supervised == null) || (supervised.length() == 0) )
96                 supervised = "-";
97         
98         String quiescent = dd.quiescent;
99         if ( (quiescent == null) || (quiescent.length() == 0) )
100                 quiescent = "-";
101         
102         
103         /*
104          * get cluster status and fix css seat
105          */
106         ClusterData cd = framework.getClusterData();
107         if (cd == null) {
108                 MessageView error = new MessageView(41401, LogCategorySet.GUI_IO_COMMAND,
109                                 Message.CLUSTER_DATA_ERROR);
110                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
111                 response.sendRedirect(RedirectPages.LOGIN);
112                 return;
113         }       
114
115         // IP CHECK
116         String selfIp = cd.self_ip;
117         String otherIp = cd.other_ip;
118         
119         if ( selfIp == null )
120                 selfIp = "";
121         if (otherIp == null )
122                 otherIp = "";
123
124         
125         /*
126          * get snmpAgent Data
127          */
128         SnmpAgentData snmp = framework.getSnmpAgentData();
129         if ( snmp == null ) {
130                 MessageView error = new MessageView(41402, LogCategorySet.GUI_IO_COMMAND,
131                                 Message.UNEXPECTED_ERROR);
132                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
133                 response.sendRedirect(RedirectPages.LOGIN);
134                 return;
135         }
136         int query = snmp.interval;
137         String queryUnit = "[msec]";
138         if (query > 1000){
139                 query = query / 1000 ;
140                 queryUnit = "[sec]";
141         }
142         
143         /*
144          * get replication Data
145          */
146         ReplicationData rep = framework.getReplicationData();
147         if ( rep == null ) {
148                 MessageView error = new MessageView(41403, LogCategorySet.GUI_IO_COMMAND,
149                                 Message.UNEXPECTED_ERROR);
150                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
151                 response.sendRedirect(RedirectPages.LOGIN);
152                 return;
153         }       
154         ReplicationStatus repStatus = rep.replicationMode;
155         String printRepStatus = null;
156         switch (repStatus){
157                 case MASTER:
158                         printRepStatus = "Master Running";
159                         break;
160                 case SLAVE:
161                         printRepStatus = "Slave Running";
162                         break;
163                 case MASTER_STOP:
164                         printRepStatus = "Master Stopped";
165                         break;
166                 case SLAVE_STOP:
167                         printRepStatus = "Slave Stopped";
168                         break;
169                 case SINGLE:
170                         printRepStatus = "Replication Invalid";
171                         break;
172                 case OUT:
173                         printRepStatus = "In Starting Replication";
174                         break;
175                 default :
176                         MessageView error = new MessageView(41404, LogCategorySet.GUI_IO_COMMAND,
177                                         Message.UNEXPECTED_ERROR);
178                         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
179                         response.sendRedirect(RedirectPages.LOGIN);
180                         return;
181         }
182
183
184                 
185         /*
186          * get process status
187          */
188         String l7vsdStatus = "Out of Service";
189         String l7vsdClass = "error";
190         String l7direcotordStatus = "Out of Service";
191         String l7directordClass = "error";
192         String snmpAgentStatus = "Out of Service";
193         String snmpAgentClass = "error" ;
194         String replicationStatus = "Out of Service";
195         String replicationClass = "side_error";
196         String clusterStatus = null;
197         String clusterClass = "error";
198         
199         // fix l7vsd Status
200         if ( framework.getL7vsdProcessStatus() ){
201                 l7vsdStatus = "In Service";
202                 l7vsdClass = "ins";
203         }
204         
205         // fix l7direcotord Status
206         if ( framework.getL7directordProcessStatus() ){
207                 l7direcotordStatus = "In Service";
208                 l7directordClass = "ins";
209         }
210         
211         // fix snmpAgent Status
212         if ( snmp.status == SnmpAgentStatus.CONNECTING ){ 
213                 snmpAgentStatus = "In Service";
214                 snmpAgentClass = "ins";
215         }
216
217         // fix replication Status
218         if ( rep.replicationMode != ReplicationStatus.SINGLE && rep.replicationMode != ReplicationStatus.OUT ){
219                 replicationStatus = "In Service";
220                 replicationClass = "side_ins";
221         }
222         
223         // fix Cluster Status
224         if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.STANDBY)) ){
225                 clusterStatus = "In Service";
226                 if (cd.self_status.equals(ClusterStatus.ACTIVE) )
227                         clusterClass = "ins";
228         }
229         
230                 
231         /*
232          * fix css seat
233          */     
234         String cssSeat = "l7gui_single_style.css";
235         if ( cd.self_status == ClusterStatus.ACTIVE ){
236                 cssSeat = "l7gui_act_style.css";
237         }
238         else if ( cd.self_status == ClusterStatus.STANDBY ){
239                 cssSeat = "l7gui_sby_style.css";
240         }
241
242 %>
243
244
245 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
246 <html>
247         <head>
248                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
249                 <meta http-equiv="Content-Script-Type" content="text/javascript" />
250                 <meta http-equiv="Content-Style-Type" content="text/css" />
251                 <meta http-equiv="Pragma" content="no-cache">
252                 <meta http-equiv="Cache-Control" content="no-cache">
253                 <meta http-equiv="Expires" content="0"> 
254                 <script src="l7gui.js" type="text/javascript"></script>
255                 <noscript> 
256                         <meta http-equiv="refresh" content="<%= RedirectPages.NOSCRIPT_TIME %>; url=<%= RedirectPages.LOGIN %>"/>
257                 </noscript> 
258                 <link rel="stylesheet" type="text/css" href="<%=cssSeat %>" />
259                 <link rel="shortcut icon" href="images/favicon.ico" />
260                 <title>GUI Console TOP</title>
261         </head>
262
263
264         <body class="normal">
265         <jsp:include page="menu.jsp" flush="false"/>
266
267
268         <div id="content">
269
270         <h1>GUI Console TOP</h1>
271         <h2> UltraMonkey-L7 Service</h2>
272
273                 <fieldset class="">
274                 <legend>UltraMoneky-L7 Service : Current status</legend>
275         
276                         <table class="infotable">
277                         <%
278                         if (clusterStatus != null){
279                         %>
280                                 <tr>
281                                 <th class="head" colspan="4">
282                                 <label for="UltraMoneky-L7">UltraMoneky-L7</label>
283                                 </th>
284                                 <th class="head">
285                                 <label for="HA Cluster">HA Cluster</label>
286                                 </th>                           
287                                 </tr>
288                         <%
289                         }
290                         %>
291                         <tr>
292                                 <th>
293                                 <label for="l7vsdStatus">l7vsd</label>
294                                 </th>
295                                 <th>
296                                 <label for="l7directord">l7directord</label>
297                                 </th>
298                                 <th>
299                                 <label for="SNMPAgent">SNMPAgent</label>
300                                 </th>
301                                 <th class="point">
302                                 <label for="Replication">Replication</label>
303                                 </th>
304                                 <%
305                                 if (clusterStatus != null){
306                                 %>
307                                         <th>
308                                         <label for="Heartbeat2">Heartbeat2</label>
309                                         </th>
310                                 <%
311                                 }
312                                 %>
313                         </tr>
314                         <tr>
315                                 <td class="<%=l7vsdClass %>"><%=l7vsdStatus %></td>
316                                 <td class="<%=l7directordClass %>"><%=l7direcotordStatus %></td>
317                                 <td class="<%=snmpAgentClass %>"><%=snmpAgentStatus %></td>
318                                 <td class="<%=replicationClass %>"><%=replicationStatus %></td>
319                                 <% if (cd.self_status == ClusterStatus.ACTIVE || cd.self_status == ClusterStatus.STANDBY){
320                                 %>
321                                 <td class="<%=clusterClass %>"><%= clusterStatus %></td>
322                                 <%
323                                 }
324                                 %>
325                         </tr>
326                 </table>
327                 </fieldset>
328
329
330         <h2>Redundancy</h2>
331                 <fieldset class="">
332                 <legend>Redundancy : Current Status</legend>
333
334                         <table class="infotable">
335                         <tr>
336                                 <th class="point">
337                                 <label for="empty"></label>
338                                 </th>
339                                 <th>
340                                 <label for="nodeStatus">Node Status</label>
341                                 </th>
342                                 <th>
343                                 <label for="realIp">Real IP Address</label>
344                                 </th>
345                         </tr>
346                         <tr>
347                                 <td class="left_point">
348                                 Self Node
349                                 </td>
350                                 <td class="center">
351                                 <%= cd.self_status %>
352                                 </td>
353                                 <td class="center">
354                                 <%= selfIp %>
355                                 </td>
356                         </tr>
357                                 <% if (cd.self_status != ClusterStatus.SINGLE){
358                                 %>
359                                 <tr>
360                                 <td class="left_point">
361                                 Peer Node
362                                 </td>
363                                 <td class="center">
364                                 <%= cd.other_status %>
365                                 </td>
366                                 <td class="center">
367                                 <%= otherIp %>
368                                 </td>
369                                 </tr>
370                                 <% }
371                                 %>
372                         </table>
373                 </fieldset>
374
375
376         <h2> VirtualService</h2>
377         <% if ( (cd.self_status.equals(ClusterStatus.ACTIVE)) || (cd.self_status.equals(ClusterStatus.SINGLE) )){
378         %>
379         <%
380                 /*
381                  * get VirtualService data from L7guiFramework
382                  */
383                 Vector<VirtualSetting> vsList = new Vector<VirtualSetting>();
384                 vsList = admDataList.virtualSettings;
385                 ArrayList<String> vsNameList = new ArrayList<String>(); 
386                 vsNameList.clear();
387         
388                 String vsIp  = null;
389                 String vsPort = null;
390                 String vsProtomod = null;
391                 String vsOption = null;
392                 String vsSchedule = null;
393                 String rsIP = null;
394                 String rsPort = null;
395                 int rsWeight = 0;
396                 long activeConnections = 0;
397                 long inactiveConnections = 0;
398                 String vsSorryFlag = null;
399         
400                 if ( vsList.size() > 0 ){
401         %>
402                         <fieldset class="">
403                         <legend>VirtualService : Current Status</legend>
404                                 <table class="infotable" cellspacing="0">
405                                 <tr>
406                                         <th class="head" colspan="5">
407                                         <label for="VirtualService">VirtualService</label>
408                                         </th>
409                                         <th class="head" colspan="5">
410                                         <label for="RealServices">RealServer</label>
411                                         </th>
412                                         <th rowspan="2">
413                                         <label for="SorryFlag">Sorry Flag</label>
414                                         </th>
415                                 </tr>
416                                 <tr>
417                                         <th>
418                                         <label for="VirtualIP Address">VirtualIP Address</label>
419                                         </th> 
420                                         <th>
421                                         <label for="Port Number">Port Number</label>
422                                         </th>
423                                         <th>
424                                         <label for="Persistence Type">Persistence Type</label>
425                                         </th>
426                                         <th>
427                                         <label for="Module option">Module Option</label>
428                                         </th>
429                                         <th class="point">
430                                         <label for="Scheduler Type">Scheduler Type</label>
431                                         </th>
432                                         <th>
433                                         <label for="RealServer IP Address">IP Address</label>                                           
434                                         </th>
435                                         <th>
436                                         <label for="RealServer Port Number">Port Number</label>                                                                 
437                                         </th>
438                                         <th>
439                                         <label for="RealServer weight">Weight</label>                                                                                           
440                                         </th>
441                                         <th>
442                                         <label for="ActiveConnections">Active Connections</label>                                                                                               
443                                         </th>
444                                         <th class="point">
445                                         <label for="InactiveConnections">Inactive Connections</label>                                                                                           
446                                         </th>                                   
447                                 </tr>
448                         <% 
449                                 for (int i = 0; i < vsList.size(); i++) {
450                                         try {
451                                                 VirtualSetting getVirtualSetting = vsList.get(i);
452                                 
453                                                 vsIp = getVirtualSetting.virtual.host;
454                                                 vsPort = getVirtualSetting.virtual.port;
455                                                 vsProtomod = getVirtualSetting.protomod;
456                                                 vsOption = getVirtualSetting.option;
457                                                 vsSchedule = getVirtualSetting.sched;
458                                 
459                                                 Vector<EndPoint> getRsList =getVirtualSetting.real;
460                                                 int rsNumber = getRsList.size();
461                                                 if ( rsNumber < 0 ){
462                                                         rsNumber = 1;
463                                                 }
464         
465                                                 boolean vsSorry = getVirtualSetting.sorryflag;
466                                                 
467                                                 if ( (vsIp == null) || (vsProtomod == null) || (vsOption == null) ){
468                                                         MessageView error = new MessageView(41405, LogCategorySet.GUI_VIRTUALSERVICE,
469                                                         Message.UNEXPECTED_ERROR);
470                                                         session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
471                                                         response.sendRedirect(RedirectPages.LOGIN);
472                                                         return;
473                                                 }
474                         %>
475                                 <tr>
476                                         <td class="center" rowspan="<%=rsNumber %>"><%=vsIp%></td>
477                                         <td class="center" rowspan="<%=rsNumber %>"><%=vsPort%></td>
478                                         <td class="center" rowspan="<%=rsNumber %>"><%=vsProtomod%></td>
479                                         <td class="center" rowspan="<%=rsNumber %>"><%=vsOption%></td>
480                                         <td class="point" rowspan="<%=rsNumber %>"><%=vsSchedule%></td>
481                                 <%
482                                         if ( rsNumber < 1 ){
483                                 %>
484                                                 <td class="center">-</td>
485                                                 <td class="center">-</td>
486                                                 <td class="center">-</td>
487                                                 <td class="center">-</td>
488                                                 <td class="point">-</td>                                                
489                                 <%
490                                         }
491                                         else{
492                                                 EndPoint getRs = getRsList.get(0);
493                                                 rsIP = getRs.host;
494                                                 rsPort = getRs.port;
495                                                 rsWeight = getRs.weight;
496                                                 activeConnections = getRs.actConn;
497                                                 inactiveConnections = getRs.inActConn;
498                                 %>
499                                                 <td class="center"><%=rsIP%></td>
500                                                 <td class="center"><%=rsPort%></td>
501                                                 <td class="center"><%=rsWeight%></td>
502                                                 <td class="center"><%=activeConnections%></td>
503                                                 <td class="point"><%=inactiveConnections%></td>                                         
504                                 <%
505                                         }
506                                         if(vsSorry == true){
507                                                 vsSorryFlag = "On";
508                                         }
509                                         else {
510                                                 vsSorryFlag = "Off";
511                                         }
512                                 %>
513                                 <td class="center" rowspan="<%=rsNumber %>"><%=vsSorryFlag %></td>
514                                 </tr>
515                                 <%
516                                         for ( int j = 1; j < rsNumber; j++ ){
517                                                 EndPoint addedGetRs = getRsList.get(j);
518                                                 rsIP = addedGetRs.host;
519                                                 rsPort = addedGetRs.port;
520                                                 rsWeight = addedGetRs.weight;
521                                                 activeConnections = addedGetRs.actConn;
522                                                 inactiveConnections = addedGetRs.inActConn;
523                                 %>
524                                 <tr>
525                                                 <td class="center"><%=rsIP%></td>
526                                                 <td class="center"><%=rsPort%></td>
527                                                 <td class="center"><%=rsWeight%></td>
528                                                 <td class="center"><%=activeConnections%></td>
529                                                 <td class="point"><%=inactiveConnections%></td>                                 
530                                 </tr>
531                                 <%
532                                         }
533                                 %>
534         
535                                 <%
536                                         }catch(NullPointerException e){
537                                                 MessageView error = new MessageView(41406, LogCategorySet.GUI_VIRTUALSERVICE,
538                                                                 Message.UNEXPECTED_ERROR);
539                                                 session.setAttribute(SessionKeys.RESULT_MESSAGE, error);
540                                                 response.sendRedirect(RedirectPages.LOGIN);
541                                                 return;
542                                         }
543                                 }
544                                 %>
545                                 </table>
546                         </fieldset>
547                 <%
548                 }
549                 else {
550                 %>
551                         <p class="error">No VirtualService List</p>
552                 <%
553                 }
554         }
555         else{
556                 %>
557                 <p class="error">No VirtualService List</p>
558                 <%
559         }
560                 %>
561
562         <h2>Monitor</h2>
563                 <fieldset class="">
564                 <legend>Monitor : Current Status</legend>
565                         <table class="infotable">
566                         <tr>
567                                 <th>
568                                 <label for="checkTimeOut">CheckTimeOut</label>
569                                 </th>
570                                 <th>
571                                 <label for="negotiateTimeOut">NegotiateTimeOut</label>
572                                 </th>
573                                 <th>
574                                 <label for="checkInterval">CheckInterval</label>
575                                 </th>
576                                 <th>
577                                 <label for="checkCount">CheckCount</label>
578                                 </th>
579                                 <th>
580                                 <label for="quiescent">Quiescent</label>
581                                 </th>
582                         </tr>
583                         <tr>
584                                 <td class="center"><%=checkTimeout%></td>
585                                 <td class="center"><%=negotiateTimeOut%></td>
586                                 <td class="center"><%=checkInterval%></td>
587                                 <td class="center"><%=checkCount%></td>
588                                 <td class="center"><%=quiescent%></td>
589                         </tr>
590                 </table>
591                 </fieldset>
592
593
594         <%
595         if (snmp.status == SnmpAgentStatus.CONNECTING) {
596         %>      
597         <h2>SNMP Agent</h2>
598                 <fieldset class="">
599                 <legend>SNMP Agent : Current Status</legend>
600                         <table class="infotable">
601                         <tr>
602                                 <th>
603                                 <label for="queryInterval">Query Interval</label>
604                                 </th>
605                         </tr>
606                         <tr>
607                                 <td class="center"><%=query %> <%=queryUnit %></td>
608                         </tr>
609                         </table>
610                 </fieldset>
611         <%
612         }
613         %>
614         
615         <%
616         if ( rep.replicationMode != ReplicationStatus.SINGLE ){
617         %>
618         <h2>Replication</h2>
619                 <fieldset class="">
620                 <legend>Replication : Current Status</legend>
621                         <table class="infotable">
622                         <tr>
623                                 <th>
624                                 <label for="Replication Mode">Replication Mode</label>
625                                 </th>
626                                 <th>
627                                 <label for="Interval">Interval</label>
628                                 </th>
629                         </tr>
630                         <tr>
631                                 <td class="center"><%=printRepStatus %></td>
632                                 <td class="center"><%=rep.interval %> [&#181;sec]</td>
633                         </tr>   
634                         </table>
635                         </fieldset>
636         <%
637         }
638         %>
639
640         </div>
641
642 </body>
643 </html>