Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/ChartController.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/ChartController.py	(revision 40203)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/ChartController.py	(working copy)
@@ -107,12 +107,13 @@
 
         return self
 
-    def generate_vertical_bar(self, title, data_list, chart_data, width=800, height=370, *args, **kw):
+    def generate_vertical_bar(self, title, data_list, chart_data, xrotate, width=800, height=370, *args, **kw):
         """
         Generate image of vertical bar
         :param string title: title of the chart
         :param list data_list: list with each data(value for x axis)
         :param list chart_data: the data for each status(value for mapping to y axis)
+        :param int xrotate: rotation angle for x axis labels
         :param int width: width of the chart
         :param int height: height of the chart
         """
@@ -142,7 +143,7 @@
             self.chart.valueAxis.labelTextFormat  = ['0', '0.2', '0.4', '0.6', '0.8', '1']
         # categoy axis (x axis)
         self.chart.categoryAxis.labelAxisMode     = 'low'
-        self.chart.categoryAxis.labels.angle      = 50
+        self.chart.categoryAxis.labels.angle      = xrotate
         self.chart.categoryAxis.labels.boxAnchor  = 'n'
         self.chart.categoryAxis.labels.dy         = -11
         self.chart.categoryAxis.labels.dx         = -14
Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/SSLStatFacade.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/SSLStatFacade.py	(revision 40203)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/SSLStatFacade.py	(working copy)
@@ -3,7 +3,7 @@
 import os
 from MonitorFileController import MonitorFileController
 from DataController import DataController
-import time
+from collections import defaultdict
 
 class SSLStatFacade():
     C_COLUMN_MATCH = {
@@ -47,7 +47,6 @@
             data_list = data_controller.get_data_list(content) + data_list
             # check if log data is enough or not
             cur_fisrt_datetime = datetime.strptime(data_list[0][0], '%a %b %d %H:%M:%S GMT %Y')
-            finish_strip = False
             if cur_fisrt_datetime < self.start_time:
                 is_enough_log_file = True
                 # you can do binary search to make it faster here
@@ -93,10 +92,10 @@
         if self.format_data_list==None:
             self.get_data()
         return [(data[0], data[3]) for data in self.format_data_list]
-    def get_data_from_db(self, type):
+    def get_data_from_db(self, type_name):
         """
         Get data from sqlite db by start time and type
-        :param string type: such as total or name of a virtual host
+        :param object type_name: such as total or list of virtual host or a specific virtual host
         :return dict
         example:
             {
@@ -106,6 +105,9 @@
                 "fatal_alerts": []
             }
         """
+        if type(type_name) != list:
+            type_name = [type_name]
+        type_sql = ",".join(["'{name}'".format(name=each) for each in type_name])
         ret = {}
         if not os.path.exists(self.C_PATH_SSL_STATUS_DB):
             return ret
@@ -125,11 +127,12 @@
             "SUM(alerts_sent),",
             "SUM(alerts_received),",
             "SUM(warning_alerts),",
-            "SUM(fatal_alerts)",
+            "SUM(fatal_alerts),",
+            "type as name",
             "FROM %s" % self.C_DB_SSL_STATUS,
             "WHERE timef BETWEEN '%s' AND '%s'" % (self.start_time, self.end_time),
-            "AND type = '%s'" % type,
-            "GROUP BY timef;"])
+            "AND type IN ({each})".format(each=type_sql),
+            "GROUP BY timef, name;"])
         data_handle = DataController()
         for each in need_db_list:
             result = data_handle.query_database(self.C_PATH_SSL_STATUS_DB, each, cmd)
@@ -137,27 +140,30 @@
                 ret['data'] = ret['data'] + result
         return ret
     def get_sql(self, type):
-        time_list = []
-        connection_attempts_list = []
-        successful_handshakes_list = []
-        active_connections_list = []
-        alerts_total_list = []
-        alerts_sent_list = []
-        alerts_received_list = []
-        warning_alerts_list = []
-        fatal_alerts_list = []
+        time_list = defaultdict(list)
+        connection_attempts_list = defaultdict(list)
+        successful_handshakes_list = defaultdict(list)
+        active_connections_list = defaultdict(list)
+        alerts_total_list = defaultdict(list)
+        alerts_sent_list = defaultdict(list)
+        alerts_received_list = defaultdict(list)
+        warning_alerts_list = defaultdict(list)
+        fatal_alerts_list = defaultdict(list)
         select_data = self.get_data_from_db(type)
         data = select_data['data']
         for each in data:
-            time_list.append(each[0])
-            connection_attempts_list.append(each[1])
-            successful_handshakes_list.append(each[2])
-            active_connections_list.append(each[3])
-            alerts_total_list.append(each[4])
-            alerts_sent_list.append(each[5])
-            alerts_received_list.append(each[6])
-            warning_alerts_list.append(each[7])
-            fatal_alerts_list.append(each[8])
+            key = each[len(each)-1] # last column is name
+            if not key or key.lower() == 'none':
+                continue
+            time_list[key].append(each[0])
+            connection_attempts_list[key].append(each[1])
+            successful_handshakes_list[key].append(each[2])
+            active_connections_list[key].append(each[3])
+            alerts_total_list[key].append(each[4])
+            alerts_sent_list[key].append(each[5])
+            alerts_received_list[key].append(each[6])
+            warning_alerts_list[key].append(each[7])
+            fatal_alerts_list[key].append(each[8])
         return {
             "time": time_list,
             "connection_attempts_list": connection_attempts_list,
Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPSYNDropStat.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPSYNDropStat.py	(revision 40203)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPSYNDropStat.py	(working copy)
@@ -3,7 +3,7 @@
 import os
 from MonitorFileController import MonitorFileController
 from DataController import DataController
-import time
+from collections import defaultdict
 
 class TCPSYNDropStat():
     C_COLUMN_MATCH = {
@@ -45,7 +45,6 @@
             data_list = data_controller.get_data_list(content) + data_list
             # check if log data is enough or not
             cur_fisrt_datetime = datetime.strptime(data_list[0][0], '%a %b %d %H:%M:%S GMT %Y')
-            finish_strip = False
             if cur_fisrt_datetime < self.start_time:
                 is_enough_log_file = True
                 # you can do binary search to make it faster here
@@ -91,10 +90,10 @@
         if self.format_data_list==None:
             self.get_data()
         return [(data[0], data[3]) for data in self.format_data_list]
-    def get_data_from_db(self, type):
+    def get_data_from_db(self, type_name):
         """
         Get data from sqlite db by start time and type
-        :param string type: such as total or name of a virtual host
+        :param object type_name: such as total or list of vs_name or a specific vs_name
         :return dict
         example:
             {
@@ -104,6 +103,9 @@
                 "system_stack_syn_route": []
             }
         """
+        if type(type_name) != list:
+            type_name = [type_name]
+        type_sql = ",".join(["'{name}'".format(name=each) for each in type_name])
         ret = {}
         if not os.path.exists(self.C_PATH_TCP_SYN_DROP_DB):
             return ret
@@ -121,11 +123,12 @@
             "SUM(mss_err_syn_drop),",
             "SUM(mss_size_syn_drop),",
             "SUM(eroute_err_syn_drop),",
-            "SUM(system_stack_syn_route)",
+            "SUM(system_stack_syn_route),",
+            "type as name",
             "FROM %s" % self.C_DB_TCP_SYN_DROUP,
             "WHERE timef BETWEEN '%s' AND '%s'" % (self.start_time, self.end_time),
-            "AND type = '%s'" % type,
-            "GROUP BY timef;"])
+            "AND type IN ({each})".format(each=type_sql),
+            "GROUP BY timef, name;"])
         data_handle = DataController()
         for each in need_db_list:
             result = data_handle.query_database(self.C_PATH_TCP_SYN_DROP_DB, each, cmd)
@@ -133,23 +136,26 @@
                 ret['data'] = ret['data'] + result
         return ret
     def get_sql(self, type):
-        time_list = []
-        in_use_syn_drop_list = []
-        over_max_syn_drop_list = []
-        mss_err_syn_drop_list = []
-        mss_size_syn_drop_list = []
-        eroute_err_syn_drop_list = []
-        system_stack_syn_route_list = []
+        time_list = defaultdict(list)
+        in_use_syn_drop_list = defaultdict(list)
+        over_max_syn_drop_list = defaultdict(list)
+        mss_err_syn_drop_list = defaultdict(list)
+        mss_size_syn_drop_list = defaultdict(list)
+        eroute_err_syn_drop_list = defaultdict(list)
+        system_stack_syn_route_list = defaultdict(list)
         select_data = self.get_data_from_db(type)
         data = select_data['data']
         for each in data:
-            time_list.append(each[0])
-            in_use_syn_drop_list.append(each[1])
-            over_max_syn_drop_list.append(each[2])
-            mss_err_syn_drop_list.append(each[3])
-            mss_size_syn_drop_list.append(each[4])
-            eroute_err_syn_drop_list.append(each[5])
-            system_stack_syn_route_list.append(each[6])
+            key = each[len(each)-1] # last column is name
+            if not key or key.lower() == 'none':
+                continue
+            time_list[key].append(each[0])
+            in_use_syn_drop_list[key].append(each[1])
+            over_max_syn_drop_list[key].append(each[2])
+            mss_err_syn_drop_list[key].append(each[3])
+            mss_size_syn_drop_list[key].append(each[4])
+            eroute_err_syn_drop_list[key].append(each[5])
+            system_stack_syn_route_list[key].append(each[6])
         return {
             "time": time_list,
             "in_use_syn_drop_list": in_use_syn_drop_list,
Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPStatistics.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPStatistics.py	(revision 40203)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/monitor_log/TCPStatistics.py	(working copy)
@@ -8,7 +8,7 @@
 import os
 from DataController import DataController
 import re
-import time
+from collections import defaultdict
 
 class TCPStatistics:
     """
@@ -35,10 +35,10 @@
         self.start_time = self.get_start_time(from_time)
         self.end_time = datetime.utcnow()
 
-    def get_data_from_db(self, type):
+    def get_data_from_db(self, type_name):
         """
         Get data from sqlite db by start time and type
-        :param string type: such as global or name of a virtual service
+        :param object type_name: such as global or list of vs_name or a specific vs_name
         :return dict
         example:
             {
@@ -48,6 +48,9 @@
                 "time_wait": []
             }
         """
+        if type(type_name) != list:
+            type_name = [type_name]
+        type_sql = ",".join(["'{name}'".format(name=each) for each in type_name])
         ret = {}
         if not os.path.exists(self.C_PATH_TCP_STATUS_DB):
             return ret
@@ -69,11 +72,12 @@
             "SUM(closing),",
             "SUM(last_ack),",
             "SUM(fin_wait_2),",
-            "SUM(time_wait)",
+            "SUM(time_wait),",
+            "type as name",
             "FROM %s" % self.C_DB_TCP_STATUS,
             "WHERE timef BETWEEN '%s' AND '%s'" % (self.start_time, self.end_time),
-            "AND type = '%s'" % type,
-            "GROUP BY timef;"])
+            "AND type IN ({each})".format(each=type_sql),
+            "GROUP BY timef, name;"])
         data_handle = DataController()
         for each in need_db_list:
             result = data_handle.query_database(self.C_PATH_TCP_STATUS_DB, each, cmd)
@@ -101,31 +105,34 @@
             return current_date_time - timedelta(days=30*period_number)
 
     def get_sql(self, type):
-        time_list = []
-        listen_list = []
-        syn_sent_list = []
-        syn_rcvd_list = []
-        established_list = []
-        close_wait_list = []
-        fin_wait_1_list = []
-        closing_list = []
-        last_ack_list = []
-        fin_wait_2_list = []
-        time_wait_list = []
+        time_list = defaultdict(list)
+        listen_list = defaultdict(list)
+        syn_sent_list = defaultdict(list)
+        syn_rcvd_list = defaultdict(list)
+        established_list = defaultdict(list)
+        close_wait_list = defaultdict(list)
+        fin_wait_1_list = defaultdict(list)
+        closing_list = defaultdict(list)
+        last_ack_list = defaultdict(list)
+        fin_wait_2_list = defaultdict(list)
+        time_wait_list = defaultdict(list)
         select_data = self.get_data_from_db(type)
         data = select_data['data']
         for each in data:
-            time_list.append(each[0])
-            listen_list.append(each[1])
-            syn_sent_list.append(each[2])
-            syn_rcvd_list.append(each[3])
-            established_list.append(each[4])
-            close_wait_list.append(each[5])
-            fin_wait_1_list.append(each[6])
-            closing_list.append(each[7])
-            last_ack_list.append(each[8])
-            fin_wait_2_list.append(each[9])
-            time_wait_list.append(each[10])
+            key = each[len(each)-1] # last column is name
+            if not key or key.lower() == 'none':
+                continue
+            time_list[key].append(each[0])
+            listen_list[key].append(each[1])
+            syn_sent_list[key].append(each[2])
+            syn_rcvd_list[key].append(each[3])
+            established_list[key].append(each[4])
+            close_wait_list[key].append(each[5])
+            fin_wait_1_list[key].append(each[6])
+            closing_list[key].append(each[7])
+            last_ack_list[key].append(each[8])
+            fin_wait_2_list[key].append(each[9])
+            time_wait_list[key].append(each[10])
         return {
             "time": time_list,
             "listen_list": listen_list,
Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/report.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/report.py	(revision 40203)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/hive/report.py	(working copy)
@@ -1,7 +1,4 @@
-from pyecharts import Bar, Line, Page
-from pyecharts.chart import Chart
-from pyecharts.engine import create_default_environment
-from reportlab.lib import colors  
+from reportlab.lib import colors
 from reportlab.lib.enums import TA_JUSTIFY
 from reportlab.lib.pagesizes import letter
 from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Image, TableStyle
@@ -15,15 +12,16 @@
 from django.utils.translation import ugettext_lazy as _
 from hive.metric import *
 from hive.utils import andebug, get_current_session
-from hive.model.legacycli import cli_parse, RegexParser, EasyParser, MATCHALL, MATCHONE
+from hive.model.legacycli import cli_parse, RegexParser, MATCHONE
 from hive.utils import local_equirement
-import random, time, csv, codecs
+import time, csv, codecs
 from hive.monitor_log.TCPSYNDropStat import TCPSYNDropStat
 from hive.monitor_log.TCPStatistics import TCPStatistics
 from hive.monitor_log.SSLStatFacade import SSLStatFacade
 from hive.monitor_log.ChartController import ChartController
 from hive.monitor_log.TCPResetCount import TCPResetCount
 from hive.monitor_log.ItemController import ItemController
+from collections import defaultdict
 
 TIMEFORMAT='%Y-%m-%d %X'
 chart_path = "/var/crash/statmon/"
@@ -33,10 +31,14 @@
 current_font = "alibaba"
 
 itemController = ItemController()
+logo_path = None
+
+pdfmetrics.registerFont(TTFont('alibaba', 'Alibaba-PuHuiTi-Regular.ttf'))
+pdfmetrics.registerFont(TTFont('alibabajp', font_file_path + 'AlibabaSansJP/AlibabaSansJP-Regular.ttf'))
 
 def generate_report_table_cover(data, col_num):
     t = Table(data, colWidths=int(480/col_num), rowHeights=20)
-    
+
     t.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, -1), colors.white),
                             ('ALIGN', (1,1), (-1,-1), 'LEFT'),
                             ('ALIGN', (0,0), (0, -1), 'RIGHT'),
@@ -65,25 +67,18 @@
         col_widths = [first_col_width] + [data_col_width] * data_col_count
 
     t = Table(data, colWidths=col_widths, rowHeights=20)
-    data_len = len(data)
-
-    for each in range(data_len):
-        if each % 2 == 0:
-            bg_color = colors.lightgrey
-        else:
-            bg_color = colors.white
-
-        t.setStyle(TableStyle([
-            ('BACKGROUND', (0, each), (-1, each), bg_color),
-            ('FONT', (0, 0), (-1, -1), current_font),
-            ('FONTSIZE', (0, 0), (-1, -1), 10),
-            ('ALIGN', (0, 0), (0, -1), 'LEFT'),
-            ('ALIGN', (1, 0), (-1, -1), 'RIGHT'),
-            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
-            ('WORDWRAP', (0, 0), (-1, -1), True),
-            ('LEFTPADDING', (0, 0), (-1, -1), 4),
-            ('RIGHTPADDING', (0, 0), (-1, -1), 4),
-        ]))
+    style_cmds = [
+        ('ROWBACKGROUNDS', (0, 0), (-1, -1), [colors.lightgrey, colors.white]),
+        ('FONT', (0,0), (-1, -1), current_font),
+        ('FONTSIZE', (0, 0), (-1, -1), 10),
+        ('ALIGN', (0, 0), (0, -1), 'LEFT'),
+        ('ALIGN', (1, 0), (-1, -1), 'RIGHT'),
+        ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
+        ('WORDWRAP', (0, 0), (-1, -1), True),
+        ('LEFTPADDING', (0, 0), (-1, -1), 4),
+        ('RIGHTPADDING', (0, 0), (-1, -1), 4),
+    ]
+    t.setStyle(TableStyle(style_cmds))
     return t
 
 def get_time_range(from_time, to_time):
@@ -97,7 +92,7 @@
     d.add(ReportLine(0, 0, 480, 0, strokeColor=colors.lightgrey))
     return d
 
-def Draw_Line_Chart(chart_name, env, styles, story, time_list, chart_item, table_data, yaxis_name=""):
+def Draw_Line_Chart(chart_name, styles, story, time_list, chart_item, table_data, yaxis_name=""):
     ptext = '<font size="12">%s</font>' % chart_name
     story.append(Paragraph(ptext, styles[current_font]))
     d = Draw_a_Line()
@@ -127,7 +122,7 @@
 
     return story
 
-def Draw_Bar_Chart(chart_name, env, styles, story, xaxis_list, chart_item, table_data, xrotate):
+def Draw_Bar_Chart(chart_name, styles, story, xaxis_list, chart_item, table_data, xrotate):
     ptext = '<font size="12">%s</font>' % chart_name
     story.append(Paragraph(ptext, styles[current_font]))
     d = Draw_a_Line()
@@ -141,7 +136,7 @@
 
     chartController = ChartController()
     try:
-        d = chartController.generate_vertical_bar(chart_item['xaxis_name'], xaxis_list, yvals)
+        d = chartController.generate_vertical_bar(chart_item['xaxis_name'], xaxis_list, yvals, xrotate)
         im = Image(d, 7*inch, 3*inch)
         story.append(im)
     except Exception as e:
@@ -354,11 +349,10 @@
         }
 
 def get_pdf_logo():
-    if local_equirement():
-        logo_path = "/ca/webui/htdocs/new/src/media/img/themes/new/login-logo-cn.png"
-    else:
-        logo_path = "/ca/webui/htdocs/new/src/media/img/themes/new/Array-Logo-en-2024.png"
-    return logo_path
+    global logo_path
+    if logo_path:
+        return logo_path
+    return "/ca/webui/htdocs/new/src/media/img/themes/new/Array-Logo-en-2024-small.png"
 
 def get_system_data_sql(from_time, to_time):
     time_list = []
@@ -421,34 +415,46 @@
     }
 
 def get_rs_data_sql(from_time, to_time, rs_name):
-    time_list = []
-    cc_list = []
-    cps_list = []
-    request_list = []
-    inbound_list = []
-    outbound_list = []
-    average_in_list = []
-    average_out_list = []
-    average_response_list = []
-    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count), avg(average_packets_in), avg(average_packets_out), avg(average_response_time), max(connection_count),max(reqcount) from GlobalRealServiceStats where $__timeFilter(timef/1000) and service_name = "%s" GROUP BY timef;' %rs_name, 
+    if type(rs_name) != list:
+        rs_name = [rs_name]
+    rs_name_sql = ",".join(["'{name}'".format(name=name) for name in rs_name])
+    time_list = defaultdict(list)
+    cc_list = defaultdict(list)
+    cps_list = defaultdict(list)
+    request_list = defaultdict(list)
+    inbound_list = defaultdict(list)
+    outbound_list = defaultdict(list)
+    average_in_list = defaultdict(list)
+    average_out_list = defaultdict(list)
+    average_response_list = defaultdict(list)
+    err_list = defaultdict(list)
+    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count), avg(average_packets_in), avg(average_packets_out), avg(average_response_time), max(connection_count),max(reqcount), service_name as name from GlobalRealServiceStats where $__timeFilter(timef/1000) and service_name IN ({name}) GROUP BY timef, name;'.format(name=rs_name_sql),
                     'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
 
-    errcode_dic = {'rawSql': 'select INCREMENT(resp_100), INCREMENT(resp_101), INCREMENT(resp_200), INCREMENT(resp_206), INCREMENT(resp_301), INCREMENT(resp_302), INCREMENT(resp_303), INCREMENT(resp_304), INCREMENT(resp_305), INCREMENT(resp_307), INCREMENT(resp_400), INCREMENT(resp_401), INCREMENT(resp_402), INCREMENT(resp_403), INCREMENT(resp_404), INCREMENT(resp_405), INCREMENT(resp_406), INCREMENT(resp_407), INCREMENT(resp_416), INCREMENT(resp_500), INCREMENT(resp_501), INCREMENT(resp_502), INCREMENT(resp_503), INCREMENT(resp_504), INCREMENT(resp_505), INCREMENT(resp_others) from RealServiceHTTPCodeStatistics WHERE $__timeFilter(time) and service_name = "%s" group by service_name;' %rs_name,
+    errcode_dic = {'rawSql': 'select INCREMENT(resp_100), INCREMENT(resp_101), INCREMENT(resp_200), INCREMENT(resp_206), INCREMENT(resp_301), INCREMENT(resp_302), INCREMENT(resp_303), INCREMENT(resp_304), INCREMENT(resp_305), INCREMENT(resp_307), INCREMENT(resp_400), INCREMENT(resp_401), INCREMENT(resp_402), INCREMENT(resp_403), INCREMENT(resp_404), INCREMENT(resp_405), INCREMENT(resp_406), INCREMENT(resp_407), INCREMENT(resp_416), INCREMENT(resp_500), INCREMENT(resp_501), INCREMENT(resp_502), INCREMENT(resp_503), INCREMENT(resp_504), INCREMENT(resp_505), INCREMENT(resp_others), service_name as name from RealServiceHTTPCodeStatistics WHERE $__timeFilter(time) and service_name IN ({name}) group by service_name;'.format(name=rs_name_sql),
                     'to': to_time, 'from': from_time, 'format': 'table'}
     errcode_data = query_metric(errcode_dic)
+    for each in errcode_data['data']:
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        err_list[key].append(each[0:len(each)-1]) # all columns except name
 
     data = select_data['data']
     for each in data:
-        time_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        cc_list.append(value_toFixed(each[3], 0))
-        cps_list.append(value_toFixed(each[7], 0))
-        request_list.append(value_toFixed(each[8], 0))
-        inbound_list.append(each[1])
-        outbound_list.append(each[2])
-        average_in_list.append(each[4])
-        average_out_list.append(each[5])
-        average_response_list.append(value_toFixed(each[6],2))
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        time_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        cc_list[key].append(value_toFixed(each[3], 0))
+        cps_list[key].append(value_toFixed(each[7], 0))
+        request_list[key].append(value_toFixed(each[8], 0))
+        inbound_list[key].append(each[1])
+        outbound_list[key].append(each[2])
+        average_in_list[key].append(each[4])
+        average_out_list[key].append(each[5])
+        average_response_list[key].append(value_toFixed(each[6],2))
 
     return {
         'time': time_list,
@@ -460,7 +466,7 @@
         'average_in_list': average_in_list,
         'average_out_list': average_out_list,
         'average_response_list': average_response_list,
-        'err_list' : errcode_data['data']
+        'err_list' : err_list
     }
 
 def get_link_data_sql(from_time, to_time, link_name):
@@ -520,63 +526,84 @@
     return map_dict, time_list
 
 def get_vs_data_sql(from_time, to_time, vs_name):
-    time_list = []
-    time_cache_list = []
-    time_comp_list = []
-    cc_list = []
-    cps_list = []
-    inbound_list = []
-    outbound_list = []
-    average_in_list = []
-    average_out_list = []
-    average_rtt_list = []
-    average_request_time_list = []
-    average_response_time_list = []
-    cache_list = []
-    compress_data = []
-    compress_all = []
-    err_list = []
+    if type(vs_name) != list:
+        vs_name = [vs_name]
+    vs_name_sql = ",".join(["'{name}'".format(name=name) for name in vs_name])
+    pk_name_sql = ",".join(["'{\"service_name\": \"%s\"}'" % name for name in vs_name])
+    time_list = defaultdict(list)
+    time_cache_list = defaultdict(list)
+    time_comp_list = defaultdict(list)
+    cc_list = defaultdict(list)
+    cps_list = defaultdict(list)
+    inbound_list = defaultdict(list)
+    outbound_list = defaultdict(list)
+    average_in_list = defaultdict(list)
+    average_out_list = defaultdict(list)
+    average_rtt_list = defaultdict(list)
+    average_request_time_list = defaultdict(list)
+    average_response_time_list = defaultdict(list)
+    cache_list = defaultdict(list)
+    compress_data = defaultdict(list)
+    compress_all = defaultdict(list)
+    err_list = defaultdict(list)
 
-    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count), avg(average_packets_in), avg(average_packets_out), avg(average_rtt), max(connection_count), avg(average_request_time), avg(average_response_time) from GlobalVirtualServiceStats where $__timeFilter(timef/1000) and service_name = "%s" GROUP BY timef;' %vs_name, 
+    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count), avg(average_packets_in), avg(average_packets_out), avg(average_rtt), max(connection_count), avg(average_request_time), avg(average_response_time), service_name as name from GlobalVirtualServiceStats where $__timeFilter(timef/1000) and service_name IN ({names}) GROUP BY timef, name;'.format(names=vs_name_sql),
                     'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
 
     data = select_data['data']
     for each in data:
-        time_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        cc_list.append(value_toFixed(each[3],0))
-        cps_list.append(value_toFixed(each[7],0))
-        inbound_list.append(each[1])
-        outbound_list.append(each[2])
-        average_in_list.append(each[4])
-        average_out_list.append(each[5])
-        average_rtt_list.append(value_toFixed(each[6],2))
-        average_request_time_list.append(value_toFixed(each[8],2))
-        average_response_time_list.append(value_toFixed(each[9],2))
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        time_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        cc_list[key].append(value_toFixed(each[3],0))
+        cps_list[key].append(value_toFixed(each[7],0))
+        inbound_list[key].append(each[1])
+        outbound_list[key].append(each[2])
+        average_in_list[key].append(each[4])
+        average_out_list[key].append(each[5])
+        average_rtt_list[key].append(value_toFixed(each[6],2))
+        average_request_time_list[key].append(value_toFixed(each[8],2))
+        average_response_time_list[key].append(value_toFixed(each[9],2))
 
-    select_dic_cache = {'rawSql': "select $__timeGroup(time) as timef, avg(cacheHitRatio) from PervsCacheStatistics where $__timeFilter(timef/1000) and pk = '{\"service_name\": \"%s\"}' GROUP BY timef;" %vs_name, 
+    select_dic_cache = {'rawSql': "select $__timeGroup(time) as timef, avg(cacheHitRatio), pk from PervsCacheStatistics where $__timeFilter(timef/1000) and pk IN ({names}) GROUP BY timef, pk;".format(names=pk_name_sql),
                             'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data_cache = query_metric(select_dic_cache)
 
     for each in select_data_cache['data']:
-        time_cache_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        cache_list.append(value_toFixed(each[1], 2))
+        pk_str = each[len(each)-1] # last column is pk
+        if not pk_str or pk_str.lower() == 'none':
+            continue
+        pk_dict = json.loads(pk_str)
+        if 'service_name' not in pk_dict:
+            continue
+        key = pk_dict['service_name']
+        time_cache_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        cache_list[key].append(value_toFixed(each[1], 2))
 
-    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(compRatioComp), avg(compRatioAll) from PervsCompressStatistics where $__timeFilter(timef/1000) and service_name = '%s' GROUP BY timef" %vs_name, 
+    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(compRatioComp), avg(compRatioAll), service_name as name from PervsCompressStatistics where $__timeFilter(timef/1000) and service_name IN ({names}) GROUP BY timef, name".format(names=vs_name_sql),
                             'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
 
 
     for each in select_data['data']:
-        time_comp_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        compress_data.append(value_toFixed(each[1],0))
-        compress_all.append(value_toFixed(each[2],0))
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        time_comp_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        compress_data[key].append(value_toFixed(each[1],0))
+        compress_all[key].append(value_toFixed(each[2],0))
 
-    errcode_dic = {'rawSql': 'select INCREMENT(resp_100), INCREMENT(resp_101), INCREMENT(resp_200), INCREMENT(resp_206), INCREMENT(resp_301), INCREMENT(resp_302), INCREMENT(resp_303), INCREMENT(resp_304), INCREMENT(resp_307), INCREMENT(resp_400), INCREMENT(resp_401), INCREMENT(resp_402), INCREMENT(resp_403), INCREMENT(resp_404), INCREMENT(resp_405), INCREMENT(resp_406), INCREMENT(resp_407), INCREMENT(resp_416), INCREMENT(resp_500), INCREMENT(resp_501), INCREMENT(resp_502), INCREMENT(resp_503), INCREMENT(resp_504), INCREMENT(resp_505), INCREMENT(resp_901), INCREMENT(resp_902), INCREMENT(resp_903), INCREMENT(resp_904), INCREMENT(resp_905), INCREMENT(resp_906), INCREMENT(resp_others) from VirtualServiceHTTPCodeStatistics WHERE $__timeFilter(time) and service_name = "%s" group by service_name;' %vs_name,
+    errcode_dic = {'rawSql': 'select INCREMENT(resp_100), INCREMENT(resp_101), INCREMENT(resp_200), INCREMENT(resp_206), INCREMENT(resp_301), INCREMENT(resp_302), INCREMENT(resp_303), INCREMENT(resp_304), INCREMENT(resp_307), INCREMENT(resp_400), INCREMENT(resp_401), INCREMENT(resp_402), INCREMENT(resp_403), INCREMENT(resp_404), INCREMENT(resp_405), INCREMENT(resp_406), INCREMENT(resp_407), INCREMENT(resp_416), INCREMENT(resp_500), INCREMENT(resp_501), INCREMENT(resp_502), INCREMENT(resp_503), INCREMENT(resp_504), INCREMENT(resp_505), INCREMENT(resp_901), INCREMENT(resp_902), INCREMENT(resp_903), INCREMENT(resp_904), INCREMENT(resp_905), INCREMENT(resp_906), INCREMENT(resp_others), service_name as name from VirtualServiceHTTPCodeStatistics WHERE $__timeFilter(time) and service_name IN ({names}) group by service_name;'.format(names=vs_name_sql),
                             'to': to_time, 'from': from_time, 'format': 'table'}
     errcode_data = query_metric(errcode_dic)
-    err_list = errcode_data['data']
-            
+    for each in errcode_data['data']:
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        err_list[key].append(each[0:len(each)-1]) # all columns except name
+
     return {
         "time": time_list,
         "time_cache_list":time_cache_list,
@@ -597,22 +624,29 @@
     }
 
 def get_ssl_vh_sql(from_time, to_time, vhost_name):
-    time_list = []
-    cc_list = []
-    cps_list = []
-    net_in_list = []
-    net_out_list = []
+    if type(vhost_name) != list:
+        vhost_name = [vhost_name]
+    vh_name_sql = ",".join(["'{name}'".format(name=name) for name in vhost_name])
+
+    time_list = defaultdict(list)
+    cc_list = defaultdict(list)
+    cps_list = defaultdict(list)
+    net_in_list = defaultdict(list)
+    net_out_list = defaultdict(list)
 
-    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count),  max(connection_count) from ExSSLVirtualHostStatistics where $__timeFilter(timef/1000) and name = '%s' GROUP BY timef;"% vhost_name, 
+    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count),  max(connection_count), name from ExSSLVirtualHostStatistics where $__timeFilter(timef/1000) and name IN ({names}) GROUP BY timef, name;".format(names=vh_name_sql),
                         'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
     data = select_data['data']
     for each in data:
-        time_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        net_in_list.append(each[1])
-        net_out_list.append(each[2])
-        cc_list.append(value_toFixed(each[3],0))
-        cps_list.append(value_toFixed(each[4],0))
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        time_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        net_in_list[key].append(each[1])
+        net_out_list[key].append(each[2])
+        cc_list[key].append(value_toFixed(each[3],0))
+        cps_list[key].append(value_toFixed(each[4],0))
 
     return {
         "time": time_list,
@@ -623,22 +657,28 @@
     }
 
 def get_ssl_rh_sql(from_time, to_time, rhost_name):
-    time_list = []
-    cc_list = []
-    cps_list = []
-    net_in_list = []
-    net_out_list = []
+    if type(rhost_name) != list:
+        rhost_name = [rhost_name]
+    rh_name_sql = ",".join(["'{name}'".format(name=name) for name in rhost_name])
+    time_list = defaultdict(list)
+    cc_list = defaultdict(list)
+    cps_list = defaultdict(list)
+    net_in_list = defaultdict(list)
+    net_out_list = defaultdict(list)
 
-    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count),  max(connection_count) from ExSSLRealHostStatistics where $__timeFilter(timef/1000) and name = '%s' GROUP BY timef;"%rhost_name, 
+    select_dic = {'rawSql': "select $__timeGroup(time) as timef, avg(average_bandwidth_in), avg(average_bandwidth_out), max(current_connection_count),  max(connection_count), name from ExSSLRealHostStatistics where $__timeFilter(timef/1000) and name IN ({names}) GROUP BY timef, name;".format(names=rh_name_sql),
                         'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
     data = select_data['data']
     for each in data:
-        time_list.append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
-        net_in_list.append(each[1])
-        net_out_list.append(each[2])
-        cc_list.append(value_toFixed(each[3],0))
-        cps_list.append(value_toFixed(each[4],0))
+        key = each[len(each)-1] # last column is name
+        if not key or key.lower() == 'none':
+            continue
+        time_list[key].append(time.strftime(TIMEFORMAT, time.localtime(int(each[0])/1000)))
+        net_in_list[key].append(each[1])
+        net_out_list[key].append(each[2])
+        cc_list[key].append(value_toFixed(each[3],0))
+        cps_list[key].append(value_toFixed(each[4],0))
 
     return {
         "time": time_list,
@@ -732,7 +772,7 @@
         "handshake_total_count_list": handshake_total_count_list,
         "handshake_success_count_list": handshake_success_count_list
     }
-def generateSystemReport(from_time, to_time, system_list, env, styles, story):
+def generateSystemReport(from_time, to_time, system_list, styles, story):
     system_data_dic = get_system_data_sql(from_time, to_time)
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("System Status")) + '</font>'
@@ -745,7 +785,7 @@
             "item_value" : system_data_dic['cpu_usage']
         }]
         table_data = zip(system_data_dic['time'], system_data_dic['cpu_usage'])
-        story = Draw_Line_Chart(unicode(_("CPU Usage(%)")), env, styles, story, system_data_dic['time'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("CPU Usage(%)")), styles, story, system_data_dic['time'], graph_item, table_data)
 
     if "mem_usage" in system_list:
         graph_item = [{
@@ -759,13 +799,13 @@
             "item_value" : system_data_dic['conn_mem']
         }]
         table_data = zip(system_data_dic['time'], system_data_dic['sys_mem'], system_data_dic['net_mem'], system_data_dic['conn_mem'])
-        story = Draw_Line_Chart(unicode(_("Memory Usage (%)")), env, styles, story, system_data_dic['time'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Memory Usage (%)")), styles, story, system_data_dic['time'], graph_item, table_data)
 
     if "net_load" in system_list:
         graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(system_data_dic['net_in'], system_data_dic['net_out'])
-        
+
         table_data = zip(system_data_dic['net_time'], net_in_table, net_out_table)
-        story = Draw_Line_Chart(unicode(_("Network Load(bps)")), env, styles, story, system_data_dic['net_time'], graph_item, table_data, yaxis_name)
+        story = Draw_Line_Chart(unicode(_("Network Load(bps)")), styles, story, system_data_dic['net_time'], graph_item, table_data, yaxis_name)
 
     if "conn_status" in system_list:
         graph_item = [{
@@ -773,8 +813,8 @@
             "item_value" : system_data_dic['cps']
         }]
         table_data = zip(system_data_dic['time'], system_data_dic['cps'])
-        story = Draw_Line_Chart(unicode(_("Connection Status")), env, styles, story, system_data_dic['time'], graph_item, table_data)
-        
+        story = Draw_Line_Chart(unicode(_("Connection Status")), styles, story, system_data_dic['time'], graph_item, table_data)
+
     if "drop_packets" in system_list:
         if 'drop_in' in system_data_dic and 'drop_out' in system_data_dic:
             graph_item = [{
@@ -785,7 +825,7 @@
                 "item_value" : system_data_dic['drop_out']
             }]
             table_data = zip(system_data_dic['time'], system_data_dic['drop_in'], system_data_dic['drop_out'])
-            story = Draw_Line_Chart(unicode(_("Drop Packets")), env, styles, story, system_data_dic['time'], graph_item, table_data)
+            story = Draw_Line_Chart(unicode(_("Drop Packets")), styles, story, system_data_dic['time'], graph_item, table_data)
 
     if "unicast_packets" in system_list:
         if 'unicast_in' in system_data_dic and 'unicast_out' in system_data_dic:
@@ -797,8 +837,8 @@
                 "item_value" : system_data_dic['unicast_out']
             }]
             table_data = zip(system_data_dic['time'], system_data_dic['unicast_in'], system_data_dic['unicast_out'])
-            story = Draw_Line_Chart(unicode(_("Unicast Packets")), env, styles, story, system_data_dic['time'], graph_item, table_data)
-        
+            story = Draw_Line_Chart(unicode(_("Unicast Packets")), styles, story, system_data_dic['time'], graph_item, table_data)
+
     run_status = get_system_run_status(system_list, system_data_dic)
     intervalStart, intervalEnd = get_time_range(from_time, to_time)
     end_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(intervalEnd))
@@ -815,94 +855,112 @@
             ptext += unicode(_('the system encountered the following abnormal conditions:'))+'</font>'
             ptext += run_status
         story.append(Paragraph(ptext, styles[current_font]))
-    
+
     return story
 
-def generateSLBVSReport(from_time, to_time, slb_vs_list, env, styles, story):
+def get_data_by_vs_names_for_tcp(from_time, vs_names):
+    tcp_status = TCPStatistics(from_time)
+    tcp_syn_drop = TCPSYNDropStat(from_time)
+    tcp_status_dic = {}
+    tcp_syn_drop_dic = {}
+    if vs_names:
+        tcp_status_dic = tcp_status.get_sql(vs_names)
+        tcp_syn_drop_dic = tcp_syn_drop.get_sql(vs_names)
+    return tcp_status_dic, tcp_syn_drop_dic
+
+def get_data_by_slb_vs_list(from_time, to_time, slb_vs_list):
+    name_list = [name for name in slb_vs_list]
+    vs_names = []
+    for each_vs in slb_vs_list:
+        if 'vs_tcp' in slb_vs_list[each_vs] and slb_vs_list[each_vs]['vs_tcp']:
+            vs_names.append(each_vs)
+    vs_datas = get_vs_data_sql(from_time, to_time, name_list)
+    tcp_status_dic, tcp_syn_drop_dic = get_data_by_vs_names_for_tcp(from_time, vs_names)
+    return vs_datas, tcp_status_dic, tcp_syn_drop_dic
+
+def generateSLBVSReport(vs_data_dic, tcp_status_dic, tcp_syn_drop_dic, slb_vs_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("SLB Virtual Service Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
-    for each_vs in slb_vs_list:
-        vs_data_dic = get_vs_data_sql(from_time, to_time, each_vs)
 
+    for each_vs in slb_vs_list:
         if 'vs_cc' in slb_vs_list[each_vs]:
             graph_item = [{
                 "item_name" : unicode(_("Concurrent Connections")),
-                "item_value" : vs_data_dic['cc_list']
+                "item_value" : vs_data_dic['cc_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time'], vs_data_dic['cc_list'])
-            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data)
-        
+            table_data = zip(vs_data_dic['time'][each_vs], vs_data_dic['cc_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data)
+
         if 'vs_cps' in slb_vs_list[each_vs]:
             graph_item = [{
                 "item_name" : unicode(_("CPS")),
-                "item_value" : vs_data_dic['cps_list']
+                "item_value" : vs_data_dic['cps_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time'], vs_data_dic['cps_list'])
-            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data)
-        
+            table_data = zip(vs_data_dic['time'][each_vs], vs_data_dic['cps_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data)
+
         if 'vs_throughput' in slb_vs_list[each_vs]:
-            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(vs_data_dic['inbound_list'], vs_data_dic['outbound_list'])
-            
-            table_data = zip(vs_data_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Throughput(bps)"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data, yaxis_name)
-        
+            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(vs_data_dic['inbound_list'][each_vs], vs_data_dic['outbound_list'][each_vs])
+
+            table_data = zip(vs_data_dic['time'][each_vs], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Throughput(bps)"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data, yaxis_name)
+
         if 'vs_pkg_rate' in slb_vs_list[each_vs]:
-            graph_item, net_in_table, net_out_table, yaxis_name = package_rate_report(vs_data_dic['average_in_list'], vs_data_dic['average_out_list'])
-            
-            table_data = zip(vs_data_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Package Rate(pps)"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data, yaxis_name)
-        
+            graph_item, net_in_table, net_out_table, yaxis_name = package_rate_report(vs_data_dic['average_in_list'][each_vs], vs_data_dic['average_out_list'][each_vs])
+
+            table_data = zip(vs_data_dic['time'][each_vs], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Package Rate(pps)"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data, yaxis_name)
+
         if 'vs_rtt' in slb_vs_list[each_vs]:
             graph_item = [{
                 "item_name" : unicode(_("Average Client Connection RTT")),
-                "item_value" : vs_data_dic['average_rtt_list']
+                "item_value" : vs_data_dic['average_rtt_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time'], vs_data_dic['average_rtt_list']) 
-            story = Draw_Line_Chart(unicode(_("Average Client Connection RTT"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data)
+            table_data = zip(vs_data_dic['time'][each_vs], vs_data_dic['average_rtt_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Average Client Connection RTT"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data)
 
         if 'vs_request_time' in slb_vs_list[each_vs]:
             graph_item = [{
                 "item_name" : unicode(_("Average Process Request Time")),
-                "item_value" : vs_data_dic['average_request_time_list']
+                "item_value" : vs_data_dic['average_request_time_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time'], vs_data_dic['average_request_time_list'])
-            story = Draw_Line_Chart(unicode(_("Average Process Request Time"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data)
+            table_data = zip(vs_data_dic['time'][each_vs], vs_data_dic['average_request_time_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Average Process Request Time"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data)
 
         if 'vs_response_time' in slb_vs_list[each_vs]:
             graph_item = [{
                 "item_name" : unicode(_("Average Process Response Time")),
-                "item_value" : vs_data_dic['average_response_time_list']
+                "item_value" : vs_data_dic['average_response_time_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time'], vs_data_dic['average_response_time_list'])
-            story = Draw_Line_Chart(unicode(_("Average Process Response Time"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time'], graph_item, table_data)
+            table_data = zip(vs_data_dic['time'][each_vs], vs_data_dic['average_response_time_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Average Process Response Time"))+"(%s)"%each_vs, styles, story, vs_data_dic['time'][each_vs], graph_item, table_data)
 
         if 'vs_cache_hit_radio' in slb_vs_list[each_vs]:
             graph_item = graph_item = [{
                 "item_name" : unicode(_("Cache Hit Ratio")),
-                "item_value" : vs_data_dic['cache_list']
+                "item_value" : vs_data_dic['cache_list'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time_cache_list'], vs_data_dic['cache_list']) 
-            story = Draw_Line_Chart(unicode(_("Cache Hit Ratio(%)"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time_cache_list'], graph_item, table_data)
-        
+            table_data = zip(vs_data_dic['time_cache_list'][each_vs], vs_data_dic['cache_list'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Cache Hit Ratio(%)"))+"(%s)"%each_vs, styles, story, vs_data_dic['time_cache_list'][each_vs], graph_item, table_data)
+
         if 'vs_compression_radio_data' in slb_vs_list[each_vs]:
             graph_item = graph_item = [{
                 "item_name" : unicode(_("Compression Ratio for Compressible Data")),
-                "item_value" : vs_data_dic['compress_data']
+                "item_value" : vs_data_dic['compress_data'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time_comp_list'], vs_data_dic['compress_data']) 
-            story = Draw_Line_Chart(unicode(_("Compression Ratio for Compressible Data(%)"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time_comp_list'], graph_item, table_data)
+            table_data = zip(vs_data_dic['time_comp_list'][each_vs], vs_data_dic['compress_data'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Compression Ratio for Compressible Data(%)"))+"(%s)"%each_vs, styles, story, vs_data_dic['time_comp_list'][each_vs], graph_item, table_data)
         if 'vs_compression_radio_all' in slb_vs_list[each_vs]:
             graph_item = graph_item = [{
                 "item_name" : unicode(_("Compression Ratio for All Data")),
-                "item_value" : vs_data_dic['compress_all']
+                "item_value" : vs_data_dic['compress_all'][each_vs]
             }]
-            table_data = zip(vs_data_dic['time_comp_list'], vs_data_dic['compress_all']) 
-            story = Draw_Line_Chart(unicode(_("Compression Ratio for All Data(%)"))+"(%s)"%each_vs, env, styles, story, vs_data_dic['time_comp_list'], graph_item, table_data)
+            table_data = zip(vs_data_dic['time_comp_list'][each_vs], vs_data_dic['compress_all'][each_vs])
+            story = Draw_Line_Chart(unicode(_("Compression Ratio for All Data(%)"))+"(%s)"%each_vs, styles, story, vs_data_dic['time_comp_list'][each_vs], graph_item, table_data)
         if "vs_response_code" in slb_vs_list[each_vs]:
-            err_data = vs_data_dic["err_list"][0] if vs_data_dic["err_list"] else [0]*31
+            err_data = vs_data_dic["err_list"][each_vs][0] if vs_data_dic["err_list"][each_vs] else [0]*31
             errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 901, 902, 903, 904, 905, 906, 'others']
             graph_item = {
                 "xaxis_name" : unicode(_("Response Code")),
@@ -910,196 +968,209 @@
                 "item_value" : err_data
             }
             table_data = zip(errcode_list, err_data)
-            story = Draw_Bar_Chart(unicode(_("HTTP Response Code Statistics"))+"(%s)"%each_vs, env, styles, story, errcode_list, graph_item, table_data, 50)
+            story = Draw_Bar_Chart(unicode(_("HTTP Response Code Statistics"))+"(%s)"%each_vs, styles, story, errcode_list, graph_item, table_data, 50)
 
         if 'vs_tcp' in slb_vs_list[each_vs] and slb_vs_list[each_vs]['vs_tcp']:
-            tcp_status = TCPStatistics(from_time)
-            tcp_syn_drop = TCPSYNDropStat(from_time)
-            tcp_status_dic = tcp_status.get_sql(each_vs)
-            tcp_syn_drop_dic = tcp_syn_drop.get_sql(each_vs)
             for filter in slb_vs_list[each_vs]['vs_tcp']:
                 field = str(filter).replace("vs_", "")
-                if field in list(tcp_status.C_COLUMN_MATCH.keys()):
-                    column = tcp_status.C_COLUMN_MATCH[field] # ex: LISTEN
+                if field in list(TCPStatistics.C_COLUMN_MATCH.keys()):
+                    column = TCPStatistics.C_COLUMN_MATCH[field] # ex: LISTEN
                     if 'time' in tcp_status_dic and (field + '_list') in tcp_status_dic:
                         graph_item = [{
                             "item_name" : unicode(_(column)),
-                            "item_value" : tcp_status_dic[field + '_list']
+                            "item_value" : tcp_status_dic[field + '_list'][each_vs]
                         }]
-                        table_data = zip(tcp_status_dic['time'], tcp_status_dic[field + '_list'])
-                        story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vs, env, styles, story, tcp_status_dic['time'], graph_item, table_data)
-                if field in list(tcp_syn_drop.C_COLUMN_MATCH.keys()):
-                    column = tcp_syn_drop.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
+                        table_data = zip(tcp_status_dic['time'][each_vs], tcp_status_dic[field + '_list'][each_vs])
+                        story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vs, styles, story, tcp_status_dic['time'][each_vs], graph_item, table_data)
+                if field in list(TCPSYNDropStat.C_COLUMN_MATCH.keys()):
+                    column = TCPSYNDropStat.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
                     if 'time' in tcp_syn_drop_dic and (field + '_list') in tcp_syn_drop_dic:
                         graph_item = [{
                             "item_name" : unicode(_(column)),
-                            "item_value" : tcp_syn_drop_dic[field + '_list']
+                            "item_value" : tcp_syn_drop_dic[field + '_list'][each_vs]
                         }]
-                        table_data = zip(tcp_syn_drop_dic['time'], tcp_syn_drop_dic[field + '_list'])
-                        story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vs, env, styles, story, tcp_syn_drop_dic['time'], graph_item, table_data)
+                        table_data = zip(tcp_syn_drop_dic['time'][each_vs], tcp_syn_drop_dic[field + '_list'][each_vs])
+                        story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vs, styles, story, tcp_syn_drop_dic['time'][each_vs], graph_item, table_data)
 
     return story
 
-def generateSLBRSReport(from_time, to_time, slb_rs_list, env, styles, story):
+def get_data_by_slb_rs_list(from_time, to_time, slb_rs_list):
+    name_list = [name for name in slb_rs_list]
+    rs_datas = get_rs_data_sql(from_time, to_time, name_list)
+    return rs_datas
+
+def generateSLBRSReport(rs_data_dic, slb_rs_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("SLB Real Service Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
+
     for each_rs in slb_rs_list:
-        rs_data_dic = get_rs_data_sql(from_time, to_time, each_rs)
         if 'rs_cc' in slb_rs_list[each_rs]:
             graph_item = [{
                 "item_name" : unicode(_("Concurrent Connections")),
-                "item_value" : rs_data_dic['cc_list']
+                "item_value" : rs_data_dic['cc_list'][each_rs]
             }]
-            table_data = zip(rs_data_dic['time'], rs_data_dic['cc_list'])
-            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data)
-        
+            table_data = zip(rs_data_dic['time'][each_rs], rs_data_dic['cc_list'][each_rs])
+            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data)
+
         if 'rs_cps' in slb_rs_list[each_rs]:
             graph_item = [{
                 "item_name" : unicode(_("CPS")),
-                "item_value" : rs_data_dic['cps_list']
+                "item_value" : rs_data_dic['cps_list'][each_rs]
             }]
-            table_data = zip(rs_data_dic['time'], rs_data_dic['cps_list'])
-            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data)
-        
+            table_data = zip(rs_data_dic['time'][each_rs], rs_data_dic['cps_list'][each_rs])
+            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data)
+
         if 'rs_request' in slb_rs_list[each_rs]:
             graph_item = [{
                 "item_name" : unicode(_("Outstanding Request Count")),
-                "item_value" : rs_data_dic['request_list']
+                "item_value" : rs_data_dic['request_list'][each_rs]
             }]
-            table_data = zip(rs_data_dic['time'], rs_data_dic['request_list'])
-            story = Draw_Line_Chart(unicode(_("Outstanding Request Count"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data)
-        
+            table_data = zip(rs_data_dic['time'][each_rs], rs_data_dic['request_list'][each_rs])
+            story = Draw_Line_Chart(unicode(_("Outstanding Request Count"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data)
+
         if 'rs_throughput' in slb_rs_list[each_rs]:
-            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(rs_data_dic['inbound_list'], rs_data_dic['outbound_list'])
-            
-            table_data = zip(rs_data_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Throughput(bps)"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data, yaxis_name)
-        
+            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(rs_data_dic['inbound_list'][each_rs], rs_data_dic['outbound_list'][each_rs])
+
+            table_data = zip(rs_data_dic['time'][each_rs], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Throughput(bps)"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data, yaxis_name)
+
         if 'rs_pkg_rate' in slb_rs_list[each_rs]:
-            graph_item, net_in_table, net_out_table, yaxis_name = package_rate_report(rs_data_dic['average_in_list'], rs_data_dic['average_out_list'])
-            
-            table_data = zip(rs_data_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Package Rate(pps)"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data, yaxis_name)
+            graph_item, net_in_table, net_out_table, yaxis_name = package_rate_report(rs_data_dic['average_in_list'][each_rs], rs_data_dic['average_out_list'][each_rs])
+
+            table_data = zip(rs_data_dic['time'][each_rs], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Package Rate(pps)"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data, yaxis_name)
 
         if 'rs_response_time' in slb_rs_list[each_rs]:
             graph_item = [{
                 "item_name" : unicode(_("Average Response Time")),
-                "item_value" : rs_data_dic['average_response_list']
+                "item_value" : rs_data_dic['average_response_list'][each_rs]
             }]
-            table_data = zip(rs_data_dic['time'], rs_data_dic['average_response_list'])
-            story = Draw_Line_Chart(unicode(_("Average Response Time"))+"(%s)"%each_rs, env, styles, story, rs_data_dic['time'], graph_item, table_data)
+            table_data = zip(rs_data_dic['time'][each_rs], rs_data_dic['average_response_list'][each_rs])
+            story = Draw_Line_Chart(unicode(_("Average Response Time"))+"(%s)"%each_rs, styles, story, rs_data_dic['time'][each_rs], graph_item, table_data)
 
         if 'rs_response_code' in slb_rs_list[each_rs]:
             errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 305, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 'others']
-            err_data = rs_data_dic['err_list'][0] if rs_data_dic['err_list'] else [0]*26
+            err_data = rs_data_dic['err_list'][each_rs][0] if rs_data_dic['err_list'][each_rs] else [0]*26
             graph_item = {
                 "xaxis_name" : unicode(_("Response Code")),
                 "yaxis_name" : unicode(_("Hits")),
                 "item_value" : err_data
             }
             table_data = zip(errcode_list, err_data)
-            story = Draw_Bar_Chart(unicode(_("HTTP Response Code Statistics"))+"(%s)"%each_rs, env, styles, story, errcode_list, graph_item, table_data, 30)
+            story = Draw_Bar_Chart(unicode(_("HTTP Response Code Statistics"))+"(%s)"%each_rs, styles, story, errcode_list, graph_item, table_data, 30)
 
     return story
 
-def generateSSLVHostReport(from_time, to_time, slb_vh_dic, env, styles, story):
+def get_data_by_vh_names(from_time, vh_names):
+    ssl_status = SSLStatFacade(from_time)
+    ssl_status_dic = ssl_status.get_sql(vh_names)
+    return ssl_status_dic
+
+def get_data_by_slb_vh_list(from_time, to_time, slb_vh_list):
+    name_list = [name for name in slb_vh_list]
+    ssl_vhost_dic = get_ssl_vh_sql(from_time, to_time, name_list)
+    ssl_status_dic = get_data_by_vh_names(from_time, name_list)
+    return ssl_vhost_dic, ssl_status_dic
+
+def generateSSLVHostReport(ssl_vhost_dic, ssl_status_dic, slb_vh_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="12">' + unicode(_("SSL Virtual Host Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    ssl_status = SSLStatFacade(from_time)
-    for each_vh in slb_vh_dic:
-        ssl_vhost_dic = get_ssl_vh_sql(from_time, to_time,each_vh)
-        if "vh_cc" in slb_vh_dic[each_vh]:
+
+    for each_vh in slb_vh_list:
+        if "vh_cc" in slb_vh_list[each_vh]:
             graph_item = [{
                 "item_name" : unicode(_("Concurrent Connections")),
-                "item_value" : ssl_vhost_dic['cc_list']
+                "item_value" : ssl_vhost_dic['cc_list'][each_vh]
             }]
-            table_data = zip(ssl_vhost_dic['time'], ssl_vhost_dic['cc_list'])
-            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_vh, env, styles, story, ssl_vhost_dic['time'], graph_item, table_data)
-        
-        if "vh_cps" in slb_vh_dic[each_vh]:
+            table_data = zip(ssl_vhost_dic['time'][each_vh], ssl_vhost_dic['cc_list'][each_vh])
+            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_vh, styles, story, ssl_vhost_dic['time'][each_vh], graph_item, table_data)
+
+        if "vh_cps" in slb_vh_list[each_vh]:
             graph_item = [{
                 "item_name" : unicode(_("CPS")),
-                "item_value" : ssl_vhost_dic['cps_list']
+                "item_value" : ssl_vhost_dic['cps_list'][each_vh]
             }]
-            table_data = zip(ssl_vhost_dic['time'], ssl_vhost_dic['cps_list'])
-            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_vh, env, styles, story, ssl_vhost_dic['time'], graph_item, table_data)
-        
-        if "vh_throughput" in slb_vh_dic[each_vh]:
-            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(ssl_vhost_dic['net_in_list'], ssl_vhost_dic['net_out_list'])
-            
-            table_data = zip(ssl_vhost_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Throughput"))+"(%s)"%each_vh, env, styles, story, ssl_vhost_dic['time'], graph_item, table_data, yaxis_name)
-        ssl_status_dic = ssl_status.get_sql(each_vh)
-        for filter in slb_vh_dic[each_vh]:
+            table_data = zip(ssl_vhost_dic['time'][each_vh], ssl_vhost_dic['cps_list'][each_vh])
+            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_vh, styles, story, ssl_vhost_dic['time'][each_vh], graph_item, table_data)
+
+        if "vh_throughput" in slb_vh_list[each_vh]:
+            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(ssl_vhost_dic['net_in_list'][each_vh], ssl_vhost_dic['net_out_list'][each_vh])
+
+            table_data = zip(ssl_vhost_dic['time'][each_vh], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Throughput"))+"(%s)"%each_vh, styles, story, ssl_vhost_dic['time'][each_vh], graph_item, table_data, yaxis_name)
+        for filter in slb_vh_list[each_vh]:
             field = str(filter).replace("vh_", "")
-            if field not in list(ssl_status.C_COLUMN_MATCH.keys()):
+            if field not in list(SSLStatFacade.C_COLUMN_MATCH.keys()):
                 continue
-            column = ssl_status.C_COLUMN_MATCH[field] # ex: Connection Attempts
+            column = SSLStatFacade.C_COLUMN_MATCH[field] # ex: Connection Attempts
             graph_item = [{
                 "item_name" : unicode(_(column)),
-                "item_value" : ssl_status_dic[field + '_list']
+                "item_value" : ssl_status_dic[field + '_list'][each_vh]
             }]
-            table_data = zip(ssl_status_dic['time'], ssl_status_dic[field + '_list'])
-            story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vh, env, styles, story, ssl_status_dic['time'], graph_item, table_data)
+            table_data = zip(ssl_status_dic['time'][each_vh], ssl_status_dic[field + '_list'][each_vh])
+            story = Draw_Line_Chart(unicode(_(column))+"(%s)"%each_vh, styles, story, ssl_status_dic['time'][each_vh], graph_item, table_data)
     return story
 
-def generateSSLRHostReport(from_time, to_time, slb_rh_dic, env, styles, story):
+def get_data_by_slb_rh_list(from_time, to_time, slb_rh_list):
+    name_list = [name for name in slb_rh_list]
+    ssl_rhost_dic = get_ssl_rh_sql(from_time, to_time, name_list)
+    return ssl_rhost_dic
+
+def generateSSLRHostReport(ssl_rhost_dic, slb_rh_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="12">' + unicode(_("SSL Real Host Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
-    for each_rh in slb_rh_dic:
-        ssl_rhost_dic = get_ssl_rh_sql(from_time, to_time,each_rh)
-        if "rh_cc" in slb_rh_dic[each_rh]:
+
+    for each_rh in slb_rh_list:
+        if "rh_cc" in slb_rh_list[each_rh]:
             graph_item = [{
                 "item_name" : unicode(_("Concurrent Connections")),
-                "item_value" : ssl_rhost_dic['cc_list']
+                "item_value" : ssl_rhost_dic['cc_list'][each_rh]
             }]
-            table_data = zip(ssl_rhost_dic['time'], ssl_rhost_dic['cc_list'])
-            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_rh, env, styles, story, ssl_rhost_dic['time'], graph_item, table_data)
+            table_data = zip(ssl_rhost_dic['time'][each_rh], ssl_rhost_dic['cc_list'][each_rh])
+            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_rh, styles, story, ssl_rhost_dic['time'][each_rh], graph_item, table_data)
 
-        if "rh_cps" in slb_rh_dic[each_rh]:
+        if "rh_cps" in slb_rh_list[each_rh]:
             graph_item = [{
                 "item_name" : unicode(_("CPS")),
-                "item_value" : ssl_rhost_dic['cps_list']
+                "item_value" : ssl_rhost_dic['cps_list'][each_rh]
             }]
-            table_data = zip(ssl_rhost_dic['time'], ssl_rhost_dic['cps_list'])
-            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_rh, env, styles, story, ssl_rhost_dic['time'], graph_item, table_data)
+            table_data = zip(ssl_rhost_dic['time'][each_rh], ssl_rhost_dic['cps_list'][each_rh])
+            story = Draw_Line_Chart(unicode(_("CPS"))+"(%s)"%each_rh, styles, story, ssl_rhost_dic['time'][each_rh], graph_item, table_data)
 
-        if "rh_throughput" in slb_rh_dic[each_rh]:
-            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(ssl_rhost_dic['net_in_list'], ssl_rhost_dic['net_out_list'])
-            
-            table_data = zip(ssl_rhost_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Throughput"))+"(%s)"%each_rh, env, styles, story, ssl_rhost_dic['time'], graph_item, table_data, yaxis_name)
+        if "rh_throughput" in slb_rh_list[each_rh]:
+            graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(ssl_rhost_dic['net_in_list'][each_rh], ssl_rhost_dic['net_out_list'][each_rh])
+
+            table_data = zip(ssl_rhost_dic['time'][each_rh], net_in_table, net_out_table)
+            story = Draw_Line_Chart(unicode(_("Throughput"))+"(%s)"%each_rh, styles, story, ssl_rhost_dic['time'][each_rh], graph_item, table_data, yaxis_name)
 
     return story
 
-def generateSLBTotalReport(from_time, to_time, slb_total_list, env, styles, story):
+def generateSLBTotalReport(from_time, to_time, slb_total_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("SLB Global Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
+
     slb_total_dic = get_slb_total_sql(from_time, to_time)
     if "total_throughput" in slb_total_list:
         graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(slb_total_dic['slb_in_list'], slb_total_dic['slb_out_list'])
-        
+
         table_data = zip(slb_total_dic['slb_time_list'], net_in_table, net_out_table)
-        story = Draw_Line_Chart(unicode(_("SLB Throughput(bps)")), env, styles, story, slb_total_dic['slb_time_list'], graph_item, table_data, yaxis_name)
-        
+        story = Draw_Line_Chart(unicode(_("SLB Throughput(bps)")), styles, story, slb_total_dic['slb_time_list'], graph_item, table_data, yaxis_name)
+
     if "curr_conn" in slb_total_list:
         graph_item = [{
             "item_name" : unicode(_("Concurrent Connections")),
             "item_value" : slb_total_dic['slb_cc_list']
         }]
         table_data = zip(slb_total_dic['slb_time_list'], slb_total_dic['slb_cc_list'])
-        story = Draw_Line_Chart(unicode(_("Concurrent Connections")), env, styles, story, slb_total_dic['slb_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Concurrent Connections")), styles, story, slb_total_dic['slb_time_list'], graph_item, table_data)
 
     if "cps" in slb_total_list:
         graph_item = [{
@@ -1107,25 +1178,25 @@
             "item_value" : slb_total_dic['slb_cps_list']
         }]
         table_data = zip(slb_total_dic['slb_time_list'], slb_total_dic['slb_cps_list'])
-        story = Draw_Line_Chart(unicode(_("CPS")), env, styles, story, slb_total_dic['slb_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("CPS")), styles, story, slb_total_dic['slb_time_list'], graph_item, table_data)
 
     if "ssl_throughput" in slb_total_list:
         graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(slb_total_dic['ssl_in_list'], slb_total_dic['ssl_out_list'])
-        
+
         table_data = zip(slb_total_dic['ssl_time_list'], net_in_table, net_out_table)
-        story = Draw_Line_Chart(unicode(_("SSL Total Throughput(bps)")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
+        story = Draw_Line_Chart(unicode(_("SSL Total Throughput(bps)")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
 
     if "ssl_vh_throughput" in slb_total_list:
         graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(slb_total_dic['vhost_in_list'], slb_total_dic['vhost_out_list'])
-        
+
         table_data = zip(slb_total_dic['ssl_time_list'], net_in_table, net_out_table)
-        story = Draw_Line_Chart(unicode(_("SSL Virtual Host Throughput(bps)")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
+        story = Draw_Line_Chart(unicode(_("SSL Virtual Host Throughput(bps)")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
 
     if "ssl_rh_throughput" in slb_total_list:
         graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(slb_total_dic['rhost_in_list'], slb_total_dic['rhost_out_list'])
-        
+
         table_data = zip(slb_total_dic['ssl_time_list'], net_in_table, net_out_table)
-        story = Draw_Line_Chart(unicode(_("SSL Real Host Throughput(bps)")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
+        story = Draw_Line_Chart(unicode(_("SSL Real Host Throughput(bps)")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data, yaxis_name)
 
     if "global_ssl_cc" in slb_total_list:
         graph_item = [{
@@ -1133,7 +1204,7 @@
             "item_value" : slb_total_dic['ssl_cc_list']
         }]
         table_data = zip(slb_total_dic['ssl_time_list'], slb_total_dic['ssl_cc_list'])
-        story = Draw_Line_Chart(unicode(_("SSL Concurrent Connections")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("SSL Concurrent Connections")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
 
     if "global_ssl_cps" in slb_total_list:
         graph_item = [{
@@ -1141,7 +1212,7 @@
             "item_value" : slb_total_dic['ssl_cps_list']
         }]
         table_data = zip(slb_total_dic['ssl_time_list'], slb_total_dic['ssl_cps_list'])
-        story = Draw_Line_Chart(unicode(_("SSL CPS")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("SSL CPS")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
 
     if 'compress_ratio' in slb_total_list:
         graph_item = [{
@@ -1149,7 +1220,7 @@
             "item_value" : slb_total_dic['compress_list']
         }]
         table_data = zip(slb_total_dic['time'], slb_total_dic['compress_list'])
-        story = Draw_Line_Chart(unicode(_("Compression Ratio for All Data(%)")), env, styles, story, slb_total_dic['time'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Compression Ratio for All Data(%)")), styles, story, slb_total_dic['time'], graph_item, table_data)
 
     if 'cache_hit_radio' in slb_total_list:
         graph_item = [{
@@ -1157,7 +1228,7 @@
             "item_value" : slb_total_dic['cache_list']
         }]
         table_data = zip(slb_total_dic['cache_time_list'], slb_total_dic['cache_list'])
-        story = Draw_Line_Chart(unicode(_("Cache Hit Ratio(%)")), env, styles, story, slb_total_dic['cache_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Cache Hit Ratio(%)")), styles, story, slb_total_dic['cache_time_list'], graph_item, table_data)
 
     if "handshake_success_rate" in slb_total_list:
         graph_item = [{
@@ -1177,11 +1248,11 @@
                         slb_total_dic['handshake_success_rate_list'],
                         slb_total_dic['handshake_total_count_list'],
                         slb_total_dic['handshake_success_count_list'])
-        story = Draw_Line_Chart(unicode(_("SSL Handshake Success Rate Statistics")), env, styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("SSL Handshake Success Rate Statistics")), styles, story, slb_total_dic['ssl_time_list'], graph_item, table_data)
 
     return story
 
-def generateLLBTotalReport(from_time, to_time, llb_total_list, env, styles, story):
+def generateLLBTotalReport(from_time, to_time, llb_total_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("LLB Total Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
@@ -1208,7 +1279,7 @@
             })
             zip_list.append(total_dic[each]['bandwidth_list'])
         table_data = zip(*zip_list)
-        story = Draw_Line_Chart(unicode(_("Bandwidth Usage")), env, styles, story, time_list, graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Bandwidth Usage")), styles, story, time_list, graph_item, table_data)
 
     if "link_throughput" in llb_total_list and total_dic and time_list:
         graph_item = []
@@ -1227,7 +1298,7 @@
             })
             zip_list.append(value_format_1024_table(total_dic[each]['through_list']))
         table_data = zip(*zip_list)
-        story = Draw_Line_Chart(unicode(_("Total Link Throughput(bps)")), env, styles, story, time_list, graph_item, table_data, yaxis_name)
+        story = Draw_Line_Chart(unicode(_("Total Link Throughput(bps)")), styles, story, time_list, graph_item, table_data, yaxis_name)
 
     if "curr_conn" in llb_total_list and total_dic and time_list:
         graph_item = []
@@ -1239,7 +1310,7 @@
             })
             zip_list.append(total_dic[each]['cc_list'])
         table_data = zip(*zip_list)
-        story = Draw_Line_Chart(unicode(_("Concurrent Connections")), env, styles, story, time_list, graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Concurrent Connections")), styles, story, time_list, graph_item, table_data)
 
     if "total_hits" in llb_total_list and total_dic and time_list:
         graph_item = []
@@ -1251,16 +1322,16 @@
             })
             zip_list.append(total_dic[each]['hit_list'])
         table_data = zip(*zip_list)
-        story = Draw_Line_Chart(unicode(_("Total Hits")), env, styles, story, time_list, graph_item, table_data)
+        story = Draw_Line_Chart(unicode(_("Total Hits")), styles, story, time_list, graph_item, table_data)
 
     return story
 
-def generateLLBReport(from_time, to_time, llb_list, env, styles, story):
+def generateLLBReport(from_time, to_time, llb_list, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">' + unicode(_("LLB Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
+
     for each_link in llb_list:
         link_data_dic = get_link_data_sql(from_time, to_time, each_link)
         if 'bandwidth_usage' in llb_list[each_link]:
@@ -1269,13 +1340,13 @@
                 "item_value" : link_data_dic['bandwidth_list']
             }]
             table_data = zip(link_data_dic['time'], link_data_dic['bandwidth_list'])
-            story = Draw_Line_Chart(unicode(_("Bandwidth Usage"))+"(%s)"%each_link, env, styles, story, link_data_dic['time'], graph_item, table_data)
+            story = Draw_Line_Chart(unicode(_("Bandwidth Usage"))+"(%s)"%each_link, styles, story, link_data_dic['time'], graph_item, table_data)
 
         if 'link_throughput' in llb_list[each_link]:
             graph_item, net_in_table, net_out_table, yaxis_name = inbound_outbound_report(link_data_dic['inbound_list'], link_data_dic['outbound_list'])
             
             table_data = zip(link_data_dic['time'], net_in_table, net_out_table)
-            story = Draw_Line_Chart(unicode(_("Link Throughput(bps)"))+"(%s)"%each_link, env, styles, story, link_data_dic['time'], graph_item, table_data, yaxis_name)
+            story = Draw_Line_Chart(unicode(_("Link Throughput(bps)"))+"(%s)"%each_link, styles, story, link_data_dic['time'], graph_item, table_data, yaxis_name)
 
         if 'curr_conn' in llb_list[each_link]:
             graph_item = [{
@@ -1283,7 +1354,7 @@
                 "item_value" : link_data_dic['cc_list']
             }]
             table_data = zip(link_data_dic['time'], link_data_dic['cc_list'])
-            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_link, env, styles, story, link_data_dic['time'], graph_item, table_data)
+            story = Draw_Line_Chart(unicode(_("Concurrent Connections"))+"(%s)"%each_link, styles, story, link_data_dic['time'], graph_item, table_data)
 
         if 'total_hits' in llb_list[each_link]:
             graph_item = [{
@@ -1291,19 +1362,19 @@
                 "item_value" : link_data_dic['hit_list']
             }]
             table_data = zip(link_data_dic['time'], link_data_dic['hit_list'])
-            story = Draw_Line_Chart(unicode(_("Hits"))+"(%s)"%each_link, env, styles, story, link_data_dic['time'], graph_item, table_data)
+            story = Draw_Line_Chart(unicode(_("Hits"))+"(%s)"%each_link, styles, story, link_data_dic['time'], graph_item, table_data)
 
     return story
 
-def generateGSLBReport(from_time, to_time, gslb_list, env, styles, story):
+def generateGSLBReport(from_time, to_time, styles, story):
     story.append(Spacer(1, 12))
     ptext = '<font size="16">'+ unicode(_("GSLB Status")) + '</font>'
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
-    
+
     time_list = []
     hit_list = []
-    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, max(total_req) from QueryStatistics where $__timeFilter(timef/1000) GROUP BY timef;', 
+    select_dic = {'rawSql': 'select $__timeGroup(time) as timef, max(total_req) from QueryStatistics where $__timeFilter(timef/1000) GROUP BY timef;',
                         'to': to_time, 'from': from_time, 'format': 'time_series'}
     select_data = query_metric(select_dic)
     data = select_data['data']
@@ -1316,23 +1387,22 @@
         "item_value" : hit_list
     }]
     table_data = zip(time_list, hit_list)
-    story = Draw_Line_Chart(unicode(_("Total Hits")), env, styles, story, time_list, graph_item, table_data)
-    
+    story = Draw_Line_Chart(unicode(_("Total Hits")), styles, story, time_list, graph_item, table_data)
+
     return story
 
-def generateTCPReport(from_time, tcp_list, env, styles, story):
+def generateTCPReport(from_time, tcp_list, styles, story):
     """
     Get PDF data of tcp status and filter columns
     :param string from_time: start time, ex: now-1d
     :param list tcp_list: needed columns
-    :param object env
     :param object styles
     :param object story: pdf object
     """
-    tcp_status = TCPStatistics(from_time)
-    tcp_syn_drop = TCPSYNDropStat(from_time)
-    tcp_status_dic = tcp_status.get_sql(tcp_status.C_GLOBAL_INDEX)
-    tcp_syn_drop_dic = tcp_syn_drop.get_sql(tcp_syn_drop.C_TYPE_TOTAL)
+    vs_names = [TCPStatistics.C_GLOBAL_INDEX, TCPSYNDropStat.C_TYPE_TOTAL]
+    tcp_status_dic, tcp_syn_drop_dic = get_data_by_vs_names_for_tcp(from_time, vs_names)
+    status_type = TCPStatistics.C_GLOBAL_INDEX
+    syn_drop_type = TCPSYNDropStat.C_TYPE_TOTAL
     tcp_reset_cnt = TCPResetCount(from_time)
     tcp_reset_cnt_dic = tcp_reset_cnt.get_sql(tcp_reset_cnt.C_TYPE_TOTAL)
     story.append(Spacer(1, 12))
@@ -1341,24 +1411,24 @@
     story.append(Spacer(1, 12))
 
     for field in tcp_list:
-        if field in list(tcp_status.C_COLUMN_MATCH.keys()):
+        if field in list(TCPStatistics.C_COLUMN_MATCH.keys()):
             if "time" in tcp_status_dic and (field + '_list') in tcp_status_dic:
-                column = tcp_status.C_COLUMN_MATCH[field] # ex: LISTEN
+                column = TCPStatistics.C_COLUMN_MATCH[field] # ex: LISTEN
                 graph_item = [{
                     "item_name" : unicode(_(column)),
-                    "item_value" : tcp_status_dic[field + '_list']
+                    "item_value" : tcp_status_dic[field + '_list'][status_type]
                 }]
-                table_data = zip(tcp_status_dic['time'], tcp_status_dic[field + '_list'])
-                story = Draw_Line_Chart(unicode(_(column)), env, styles, story, tcp_status_dic['time'], graph_item, table_data)
-        if field in list(tcp_syn_drop.C_COLUMN_MATCH.keys()):
+                table_data = zip(tcp_status_dic['time'][status_type], tcp_status_dic[field + '_list'][status_type])
+                story = Draw_Line_Chart(unicode(_(column)), styles, story, tcp_status_dic['time'][status_type], graph_item, table_data)
+        if field in list(TCPSYNDropStat.C_COLUMN_MATCH.keys()):
             if "time" in tcp_syn_drop_dic and (field + '_list') in tcp_syn_drop_dic:
-                column = tcp_syn_drop.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
+                column = TCPSYNDropStat.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
                 graph_item = [{
                     "item_name" : unicode(_(column)),
-                    "item_value" : tcp_syn_drop_dic[field + '_list']
+                    "item_value" : tcp_syn_drop_dic[field + '_list'][syn_drop_type]
                 }]
-                table_data = zip(tcp_syn_drop_dic['time'], tcp_syn_drop_dic[field + '_list'])
-                story = Draw_Line_Chart(unicode(_(column)), env, styles, story, tcp_syn_drop_dic['time'], graph_item, table_data)
+                table_data = zip(tcp_syn_drop_dic['time'][syn_drop_type], tcp_syn_drop_dic[field + '_list'][syn_drop_type])
+                story = Draw_Line_Chart(unicode(_(column)), styles, story, tcp_syn_drop_dic['time'][syn_drop_type], graph_item, table_data)
         if "reset_count:" in field:
             ptext = '<font size="16">' + unicode(_("TCP Reset Count")) + '</font>'
             story.append(Paragraph(ptext, styles[current_font]))
@@ -1373,14 +1443,13 @@
                     "item_value" : tcp_reset_cnt_dic[reset_id]['count_list']
                 }]
                 table_data = zip(tcp_reset_cnt_dic[reset_id]['time'], tcp_reset_cnt_dic[reset_id]['count_list'])
-                story = Draw_Line_Chart("Reset Id: " + reset_id, env, styles, story, tcp_reset_cnt_dic[reset_id]['time'], graph_item, table_data)
+                story = Draw_Line_Chart("Reset Id: " + reset_id, styles, story, tcp_reset_cnt_dic[reset_id]['time'], graph_item, table_data)
     return story
-def generateSSLTotalReport(from_time, ssl_list, env, styles, story):
+def generateSSLTotalReport(ssl_status_dic, ssl_list, styles, story):
     """
     Get PDF data of SSL total statistics and filter columns
     :param string from_time: start time, ex: now-1d
     :param list ssl_list: needed columns
-    :param object env
     :param object styles
     :param object story: pdf object
     """
@@ -1389,21 +1458,20 @@
     story.append(Paragraph(ptext, styles[current_font]))
     story.append(Spacer(1, 12))
 
-    ssl_status = SSLStatFacade(from_time)
-    ssl_status_dic = ssl_status.get_sql(ssl_status.C_TYPE_TOTAL)
-    fields = list(ssl_status.C_COLUMN_MATCH.keys())
+    total_type = SSLStatFacade.C_TYPE_TOTAL
+    fields = list(SSLStatFacade.C_COLUMN_MATCH.keys())
     if "time" not in ssl_status_dic:
         return story
     for field in fields:
         if field not in ssl_list:
             continue
-        column = ssl_status.C_COLUMN_MATCH[field] # ex: Connection Attempts
+        column = SSLStatFacade.C_COLUMN_MATCH[field] # ex: Connection Attempts
         graph_item = [{
             "item_name" : unicode(_(column)),
-            "item_value" : ssl_status_dic[field + '_list']
+            "item_value" : ssl_status_dic[field + '_list'][total_type]
         }]
-        table_data = zip(ssl_status_dic['time'], ssl_status_dic[field + '_list'])
-        story = Draw_Line_Chart(unicode(_(column)), env, styles, story, ssl_status_dic['time'], graph_item, table_data)
+        table_data = zip(ssl_status_dic['time'][total_type], ssl_status_dic[field + '_list'][total_type])
+        story = Draw_Line_Chart(unicode(_(column)), styles, story, ssl_status_dic['time'][total_type], graph_item, table_data)
     return story
 def generateSystemCSV(cw, from_time, to_time, end_time, start_time, system_list):
     cw.writerow("")
@@ -1513,164 +1581,163 @@
                     slb_total_dic['handshake_success_count_list']))
     return cw
 
-def generateSLBVSCSV(cw, from_time, to_time, vs_name, slb_vs_list):
-    cw.writerow([unicode(_("SLB Virtual Service Status"))+"(%s)"%vs_name])
-    vs_data_dic = get_vs_data_sql(from_time, to_time, vs_name)
+def generateSLBVSCSV(cw, from_time, to_time, slb_vs_list):
+    vs_data_dic, tcp_status_dic, tcp_syn_drop_dic = get_data_by_slb_vs_list(from_time, to_time, slb_vs_list)
 
-    if 'vs_cc' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Concurrent Count'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Concurrent Count'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['cc_list']))
-    if 'vs_cps' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('CPS'))])
-        cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['cps_list']))
-    if 'vs_throughput' in slb_vs_list[vs_name]:
-        net_in_table = value_format_1024_table(vs_data_dic['inbound_list'])
-        net_out_table = value_format_1024_table(vs_data_dic['outbound_list'])
-        cw.writerow([unicode(_('Throughput'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
-        cw.writerows(zip(vs_data_dic['time'], net_in_table, net_out_table))
-    if 'vs_pkg_rate' in slb_vs_list[vs_name]:
-        net_in_table = value_format_1024_table(vs_data_dic['average_in_list'])
-        net_out_table = value_format_1024_table(vs_data_dic['average_out_list'])
-        cw.writerow([unicode(_('Package Rate'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Package Rate In(pps)')), unicode(_('Average Package Rate Out(pps)'))])
-        cw.writerows(zip(vs_data_dic['time'], net_in_table, net_out_table))
-    if 'vs_rtt' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Average Client Connection RTT'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Client Connection RTT'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['average_rtt_list']))
-    if 'vs_request_time' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Average Process Request Time'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Process Request Time'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['average_request_time_list']))
-    if 'vs_response_time' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Average Process Response Time'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Process Response Time'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['average_response_time_list']))
-    if "vs_response_code" in slb_vs_list[vs_name]:
-        err_data = vs_data_dic["err_list"][0] if vs_data_dic["err_list"] else [0]*31
-        errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 901, 902, 903, 904, 905, 906, 'others']
-        cw.writerow([unicode(_('HTTP Response Code Statistics'))])
-        cw.writerow([unicode(_('Response Code')), unicode(_('Hits'))])
-        cw.writerows(zip(errcode_list, err_data))
-    if 'vs_cache_hit_radio' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Cache Hit Ratio'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Cache Hit Ratio(%)'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['cache_list']))
-    if 'vs_compression_radio_data' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Compression Ratio for Compressible Data'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Compression Ratio for Compressible Data(%)'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['compress_data']))
-    if 'vs_compression_radio_all' in slb_vs_list[vs_name]:
-        cw.writerow([unicode(_('Compression Ratio for All Data'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Compression Ratio for All Data(%)'))])
-        cw.writerows(zip(vs_data_dic['time'], vs_data_dic['compress_all']))
-    if 'vs_tcp' in slb_vs_list[vs_name] and slb_vs_list[vs_name]['vs_tcp']:
-        tcp_status = TCPStatistics(from_time)
-        tcp_syn_drop = TCPSYNDropStat(from_time)
-        tcp_status_dic = tcp_status.get_sql(vs_name)
-        tcp_syn_drop_dic = tcp_syn_drop.get_sql(vs_name)
-        for filter in slb_vs_list[vs_name]['vs_tcp']:
-            field = str(filter).replace("vs_", "")
-            if field in list(tcp_status.C_COLUMN_MATCH.keys()):
-                column = tcp_status.C_COLUMN_MATCH[field] # ex: LISTEN
-                cw.writerow([unicode(_(column))])
-                cw.writerow([unicode(_('Time')), unicode(_(column))])
-                if 'time' in tcp_status_dic and (field + '_list') in tcp_status_dic:
-                    cw.writerows(zip(tcp_status_dic['time'], tcp_status_dic[field + '_list']))
-            if field in list(tcp_syn_drop.C_COLUMN_MATCH.keys()):
-                column = tcp_syn_drop.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
-                cw.writerow([unicode(_(column))])
-                cw.writerow([unicode(_('Time')), unicode(_(column))])
-                if 'time' in tcp_syn_drop_dic and (field + '_list') in tcp_syn_drop_dic:
-                    cw.writerows(zip(tcp_syn_drop_dic['time'], tcp_syn_drop_dic[field + '_list']))
+    for vs_name in slb_vs_list:
+        cw.writerow([unicode(_("SLB Virtual Service Status"))+"(%s)"%vs_name])
 
+        if 'vs_cc' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Concurrent Count'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Concurrent Count'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['cc_list'][vs_name]))
+        if 'vs_cps' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('CPS'))])
+            cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['cps_list'][vs_name]))
+        if 'vs_throughput' in slb_vs_list[vs_name]:
+            net_in_table = value_format_1024_table(vs_data_dic['inbound_list'][vs_name])
+            net_out_table = value_format_1024_table(vs_data_dic['outbound_list'][vs_name])
+            cw.writerow([unicode(_('Throughput'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], net_in_table, net_out_table))
+        if 'vs_pkg_rate' in slb_vs_list[vs_name]:
+            net_in_table = value_format_1024_table(vs_data_dic['average_in_list'][vs_name])
+            net_out_table = value_format_1024_table(vs_data_dic['average_out_list'][vs_name])
+            cw.writerow([unicode(_('Package Rate'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Package Rate In(pps)')), unicode(_('Average Package Rate Out(pps)'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], net_in_table, net_out_table))
+        if 'vs_rtt' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Average Client Connection RTT'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Client Connection RTT'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['average_rtt_list'][vs_name]))
+        if 'vs_request_time' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Average Process Request Time'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Process Request Time'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['average_request_time_list'][vs_name]))
+        if 'vs_response_time' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Average Process Response Time'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Process Response Time'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['average_response_time_list'][vs_name]))
+        if "vs_response_code" in slb_vs_list[vs_name]:
+            err_data = vs_data_dic["err_list"][vs_name][0] if vs_data_dic["err_list"][vs_name] else [0]*31
+            errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 901, 902, 903, 904, 905, 906, 'others']
+            cw.writerow([unicode(_('HTTP Response Code Statistics'))])
+            cw.writerow([unicode(_('Response Code')), unicode(_('Hits'))])
+            cw.writerows(zip(errcode_list, err_data))
+        if 'vs_cache_hit_radio' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Cache Hit Ratio'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Cache Hit Ratio(%)'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['cache_list'][vs_name]))
+        if 'vs_compression_radio_data' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Compression Ratio for Compressible Data'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Compression Ratio for Compressible Data(%)'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['compress_data'][vs_name]))
+        if 'vs_compression_radio_all' in slb_vs_list[vs_name]:
+            cw.writerow([unicode(_('Compression Ratio for All Data'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Compression Ratio for All Data(%)'))])
+            cw.writerows(zip(vs_data_dic['time'][vs_name], vs_data_dic['compress_all'][vs_name]))
+        if 'vs_tcp' in slb_vs_list[vs_name] and slb_vs_list[vs_name]['vs_tcp']:
+            for filter in slb_vs_list[vs_name]['vs_tcp']:
+                field = str(filter).replace("vs_", "")
+                if field in list(TCPStatistics.C_COLUMN_MATCH.keys()):
+                    column = TCPStatistics.C_COLUMN_MATCH[field] # ex: LISTEN
+                    cw.writerow([unicode(_(column))])
+                    cw.writerow([unicode(_('Time')), unicode(_(column))])
+                    if 'time' in tcp_status_dic and (field + '_list') in tcp_status_dic:
+                        cw.writerows(zip(tcp_status_dic['time'][vs_name], tcp_status_dic[field + '_list'][vs_name]))
+                if field in list(TCPSYNDropStat.C_COLUMN_MATCH.keys()):
+                    column = TCPSYNDropStat.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
+                    cw.writerow([unicode(_(column))])
+                    cw.writerow([unicode(_('Time')), unicode(_(column))])
+                    if 'time' in tcp_syn_drop_dic and (field + '_list') in tcp_syn_drop_dic:
+                        cw.writerows(zip(tcp_syn_drop_dic['time'][vs_name], tcp_syn_drop_dic[field + '_list'][vs_name]))
     return cw
 
-def generateSLBRSCSV(cw, from_time, to_time, rs_name, slb_rs_list):
-    cw.writerow([unicode(_("SLB Real Service Status"))+"(%s)"%rs_name])
-    rs_data_dic = get_rs_data_sql(from_time, to_time, rs_name)
+def generateSLBRSCSV(cw, from_time, to_time, slb_rs_list):
+    rs_data_dic = get_data_by_slb_rs_list(from_time, to_time, slb_rs_list)
 
-    if 'rs_cc' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('Concurrent Count'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Concurrent Count'))])
-        cw.writerows(zip(rs_data_dic['time'], rs_data_dic['cc_list']))
-    if 'rs_cps' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('CPS'))])
-        cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
-        cw.writerows(zip(rs_data_dic['time'], rs_data_dic['cps_list']))
-    if 'rs_request' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('Outstanding Request Count'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Outstanding Request Count'))])
-        cw.writerows(zip(rs_data_dic['time'], rs_data_dic['request_list']))
-    if 'rs_throughput' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('Throughput'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
-        cw.writerows(zip(rs_data_dic['time'], value_format_1024_table(rs_data_dic['inbound_list']), value_format_1024_table(rs_data_dic['outbound_list'])))
-    if 'rs_pkg_rate' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('Package Rate'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Package Rate In(pps)')), unicode(_('Average Package Rate Out(pps)'))])
-        cw.writerows(zip(rs_data_dic['time'], value_format_1024_table(rs_data_dic['average_in_list']), value_format_1024_table(rs_data_dic['average_out_list'])))
-    if 'rs_response_time' in slb_rs_list[rs_name]:
-        cw.writerow([unicode(_('Average Response Time'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Average Response Time'))])
-        cw.writerows(zip(rs_data_dic['time'], rs_data_dic['average_response_list']))
-    if 'rs_response_code' in slb_rs_list[rs_name]:
-        errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 305, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 'others']
-        err_data = rs_data_dic['err_list'][0] if rs_data_dic['err_list'] else [0]*26
-        cw.writerow([unicode(_('HTTP Response Code Statistics'))])
-        cw.writerow([unicode(_('Response Code')), unicode(_('Hits'))])
-        cw.writerows(zip(errcode_list, err_data))
+    for rs_name in slb_rs_list:
+        cw.writerow([unicode(_("SLB Real Service Status"))+"(%s)"%rs_name])
+        if 'rs_cc' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('Concurrent Count'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Concurrent Count'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], rs_data_dic['cc_list'][rs_name]))
+        if 'rs_cps' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('CPS'))])
+            cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], rs_data_dic['cps_list'][rs_name]))
+        if 'rs_request' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('Outstanding Request Count'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Outstanding Request Count'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], rs_data_dic['request_list'][rs_name]))
+        if 'rs_throughput' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('Throughput'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], value_format_1024_table(rs_data_dic['inbound_list'][rs_name]), value_format_1024_table(rs_data_dic['outbound_list'][rs_name])))
+        if 'rs_pkg_rate' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('Package Rate'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Package Rate In(pps)')), unicode(_('Average Package Rate Out(pps)'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], value_format_1024_table(rs_data_dic['average_in_list'][rs_name]), value_format_1024_table(rs_data_dic['average_out_list'][rs_name])))
+        if 'rs_response_time' in slb_rs_list[rs_name]:
+            cw.writerow([unicode(_('Average Response Time'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Average Response Time'))])
+            cw.writerows(zip(rs_data_dic['time'][rs_name], rs_data_dic['average_response_list'][rs_name]))
+        if 'rs_response_code' in slb_rs_list[rs_name]:
+            errcode_list = [100, 101, 200, 206, 301, 302, 303, 304, 305, 307, 400, 401, 402, 403, 404, 405, 406, 407, 416, 500, 501, 502, 503, 504, 505, 'others']
+            err_data = rs_data_dic['err_list'][rs_name][0] if rs_data_dic['err_list'][rs_name] else [0]*26
+            cw.writerow([unicode(_('HTTP Response Code Statistics'))])
+            cw.writerow([unicode(_('Response Code')), unicode(_('Hits'))])
+            cw.writerows(zip(errcode_list, err_data))
     return cw
 
-def generateSSLVHostCSV(cw, from_time, to_time, vh_name, slb_vh_list):
+def generateSSLVHostCSV(cw, from_time, to_time, slb_vh_list):
     cw.writerow("")
-    cw.writerow([unicode(_('SSL Virtual Host Status'))+"(%s)"%vh_name])
-    ssl_vhost_dic = get_ssl_vh_sql(from_time, to_time,vh_name)
-    
-    if 'vh_cc' in slb_vh_list[vh_name]:
-        cw.writerow([unicode(_('Concurrent Connections'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Concurrent Connections'))])
-        cw.writerows(zip(ssl_vhost_dic['time'], ssl_vhost_dic['cc_list']))
-    if 'vh_cps' in slb_vh_list[vh_name]:
-        cw.writerow([unicode(_('CPS'))])
-        cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
-        cw.writerows(zip(ssl_vhost_dic['time'], ssl_vhost_dic['cps_list']))
-    if 'vh_throughput' in slb_vh_list[vh_name]:
-        cw.writerow([unicode(_('Throughput'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
-        cw.writerows(zip(ssl_vhost_dic['time'], value_format_1024_table(ssl_vhost_dic['net_in_list']), value_format_1024_table(ssl_vhost_dic['net_out_list'])))
-    ssl_status = SSLStatFacade(from_time)
-    ssl_status_dic = ssl_status.get_sql(vh_name)
-    for filter in slb_vh_list[vh_name]:
-        field = str(filter).replace("vh_", "")
-        if field not in list(ssl_status.C_COLUMN_MATCH.keys()):
-            continue
-        column = ssl_status.C_COLUMN_MATCH[field] # ex: Connection Attempts
-        cw.writerow([unicode(_(column))])
-        cw.writerow([unicode(_('Time')), unicode(_(column))])
-        cw.writerows(zip(ssl_status_dic['time'], ssl_status_dic[field + '_list']))
+    ssl_vhost_dic, ssl_status_dic = get_data_by_slb_vh_list(from_time, to_time, slb_vh_list)
+
+    for vh_name in slb_vh_list:
+        cw.writerow([unicode(_('SSL Virtual Host Status'))+"(%s)"%vh_name])
+        if 'vh_cc' in slb_vh_list[vh_name]:
+            cw.writerow([unicode(_('Concurrent Connections'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Concurrent Connections'))])
+            cw.writerows(zip(ssl_vhost_dic['time'][vh_name], ssl_vhost_dic['cc_list'][vh_name]))
+        if 'vh_cps' in slb_vh_list[vh_name]:
+            cw.writerow([unicode(_('CPS'))])
+            cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
+            cw.writerows(zip(ssl_vhost_dic['time'][vh_name], ssl_vhost_dic['cps_list'][vh_name]))
+        if 'vh_throughput' in slb_vh_list[vh_name]:
+            cw.writerow([unicode(_('Throughput'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
+            cw.writerows(zip(ssl_vhost_dic['time'][vh_name], value_format_1024_table(ssl_vhost_dic['net_in_list'][vh_name]), value_format_1024_table(ssl_vhost_dic['net_out_list'][vh_name])))
+        for filter in slb_vh_list[vh_name]:
+            field = str(filter).replace("vh_", "")
+            if field not in list(SSLStatFacade.C_COLUMN_MATCH.keys()):
+                continue
+            column = SSLStatFacade.C_COLUMN_MATCH[field] # ex: Connection Attempts
+            cw.writerow([unicode(_(column))])
+            cw.writerow([unicode(_('Time')), unicode(_(column))])
+            cw.writerows(zip(ssl_status_dic['time'][vh_name], ssl_status_dic[field + '_list'][vh_name]))
     return cw
 
-def generateSSLRHostCSV(cw, from_time, to_time, rh_name, slb_rh_list):
+def generateSSLRHostCSV(cw, from_time, to_time, slb_rh_list):
     cw.writerow("")
-    cw.writerow([unicode(_('SSL Real Host Status'))+"(%s)"%rh_name])
-    ssl_rhost_dic = get_ssl_rh_sql(from_time, to_time,rh_name)
-    
-    if 'rh_cc' in slb_rh_list[rh_name]:
-        cw.writerow([unicode(_('Concurrent Connections'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Concurrent Connections'))])
-        cw.writerows(zip(ssl_rhost_dic['time'], ssl_rhost_dic['cc_list']))
-    if 'rh_cps' in slb_rh_list[rh_name]:
-        cw.writerow([unicode(_('CPS'))])
-        cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
-        cw.writerows(zip(ssl_rhost_dic['time'], ssl_rhost_dic['cps_list']))
-    if 'rh_throughput' in slb_rh_list[rh_name]:
-        cw.writerow([unicode(_('Throughput'))])
-        cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
-        cw.writerows(zip(ssl_rhost_dic['time'], value_format_1024_table(ssl_rhost_dic['net_in_list']), value_format_1024_table(ssl_rhost_dic['net_out_list'])))
+    ssl_rhost_dic = get_data_by_slb_rh_list(from_time, to_time, slb_rh_list)
+
+    for rh_name in slb_rh_list:
+        cw.writerow([unicode(_('SSL Real Host Status'))+"(%s)"%rh_name])
+
+        if 'rh_cc' in slb_rh_list[rh_name]:
+            cw.writerow([unicode(_('Concurrent Connections'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Concurrent Connections'))])
+            cw.writerows(zip(ssl_rhost_dic['time'][rh_name], ssl_rhost_dic['cc_list'][rh_name]))
+        if 'rh_cps' in slb_rh_list[rh_name]:
+            cw.writerow([unicode(_('CPS'))])
+            cw.writerow([unicode(_('Time')), unicode(_('CPS'))])
+            cw.writerows(zip(ssl_rhost_dic['time'][rh_name], ssl_rhost_dic['cps_list'][rh_name]))
+        if 'rh_throughput' in slb_rh_list[rh_name]:
+            cw.writerow([unicode(_('Throughput'))])
+            cw.writerow([unicode(_('Time')), unicode(_('Inbound(bps)')), unicode(_('Outbound(bps)'))])
+            cw.writerows(zip(ssl_rhost_dic['time'][rh_name], value_format_1024_table(ssl_rhost_dic['net_in_list'][rh_name]), value_format_1024_table(ssl_rhost_dic['net_out_list'][rh_name])))
     return cw
 
 def generateLLBTotalCSV(cw, from_time, to_time, llb_total_list):
@@ -1766,26 +1833,26 @@
     :param string from_time: start time, ex: now-1d
     :param list tcp_list: needed columns
     """
+    vs_names = [TCPStatistics.C_GLOBAL_INDEX, TCPSYNDropStat.C_TYPE_TOTAL]
+    tcp_status_dic, tcp_syn_drop_dic = get_data_by_vs_names_for_tcp(from_time, vs_names)
+    status_type = TCPStatistics.C_GLOBAL_INDEX
+    syn_drop_type = TCPSYNDropStat.C_TYPE_TOTAL
     cw.writerow([unicode(_('TCP Global Statistics'))])
-    tcp_status = TCPStatistics(from_time)
-    tcp_status_dic = tcp_status.get_sql(tcp_status.C_GLOBAL_INDEX)
-    tcp_syn_drop = TCPSYNDropStat(from_time)
-    tcp_syn_drop_dic = tcp_syn_drop.get_sql(tcp_syn_drop.C_TYPE_TOTAL)
     tcp_reset_cnt = TCPResetCount(from_time)
     tcp_reset_cnt_dic = tcp_reset_cnt.get_sql(tcp_reset_cnt.C_TYPE_TOTAL)
     for field in tcp_list:
-        if field in list(tcp_status.C_COLUMN_MATCH.keys()):
-            column = tcp_status.C_COLUMN_MATCH[field] # ex: LISTEN
+        if field in list(TCPStatistics.C_COLUMN_MATCH.keys()):
+            column = TCPStatistics.C_COLUMN_MATCH[field] # ex: LISTEN
             cw.writerow([unicode(_(column))])
             cw.writerow([unicode(_('Time')), unicode(_(column))])
             if "time" in tcp_status_dic and (field + '_list') in tcp_status_dic:
-                cw.writerows(zip(tcp_status_dic['time'], tcp_status_dic[field + '_list']))
-        if field in list(tcp_syn_drop.C_COLUMN_MATCH.keys()):
-            column = tcp_syn_drop.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
+                cw.writerows(zip(tcp_status_dic['time'][status_type], tcp_status_dic[field + '_list'][status_type]))
+        if field in list(TCPSYNDropStat.C_COLUMN_MATCH.keys()):
+            column = TCPSYNDropStat.C_COLUMN_MATCH[field] # ex: In Use SYN Drop
             cw.writerow([unicode(_(column))])
             cw.writerow([unicode(_('Time')), unicode(_(column))])
             if "time" in tcp_syn_drop_dic and (field + '_list') in tcp_syn_drop_dic:
-                cw.writerows(zip(tcp_syn_drop_dic['time'], tcp_syn_drop_dic[field + '_list']))
+                cw.writerows(zip(tcp_syn_drop_dic['time'][syn_drop_type], tcp_syn_drop_dic[field + '_list'][syn_drop_type]))
         if "reset_count:" in field:
             cw.writerow([unicode(_('TCP Reset Count'))])
             reset_ids = field.replace("reset_count:", "")
@@ -1803,18 +1870,18 @@
     :param list ssl_list: needed columns
     """
     cw.writerow([unicode(_('SSL Total Statistics'))])
-    ssl_status = SSLStatFacade(from_time)
-    fields = list(ssl_status.C_COLUMN_MATCH.keys())
-    ssl_status_dic = ssl_status.get_sql(ssl_status.C_TYPE_TOTAL)
+    ssl_status_dic = get_data_by_vh_names(from_time, SSLStatFacade.C_TYPE_TOTAL)
+    fields = list(SSLStatFacade.C_COLUMN_MATCH.keys())
+    total_type = SSLStatFacade.C_TYPE_TOTAL
     if "time" not in ssl_status_dic:
         return cw
     for field in fields:
         if field not in ssl_list:
             continue
-        column = ssl_status.C_COLUMN_MATCH[field] # ex: Connection Attempts
+        column = SSLStatFacade.C_COLUMN_MATCH[field] # ex: Connection Attempts
         cw.writerow([unicode(_(column))])
         cw.writerow([unicode(_('Time')), unicode(_(column))])
-        cw.writerows(zip(ssl_status_dic['time'], ssl_status_dic[field + '_list']))
+        cw.writerows(zip(ssl_status_dic['time'][total_type], ssl_status_dic[field + '_list'][total_type]))
     return cw
 def generateCSVReport(report_name, from_time, to_time, end_time, start_time, system_list, slb_vs_list, slb_rs_list, slb_vh_list, slb_rh_list, slb_total_list, llb_list, llb_total_list, gslb_list, tcp_list, ssl_total_list):
     sys_info = get_system_version()
@@ -1828,7 +1895,7 @@
         cw.writerow([unicode(_('System RAM')), sys_info['system_ram']])
         cw.writerow([unicode(_('Cumulative Running Time')), sys_info['system_boot']])
         cw.writerow([unicode(_('Model')), sys_info['system_model']])
-        
+
         if system_list:
             cw = generateSystemCSV(cw, from_time, to_time, end_time, start_time, system_list)
         if slb_total_list:
@@ -1836,24 +1903,16 @@
             cw = generateSLBTotalCSV(cw, from_time, to_time, slb_total_list)
         if slb_vs_list:
             cw.writerow("")
-            for each in slb_vs_list:
-                vs_name = each
-                cw = generateSLBVSCSV(cw, from_time, to_time, vs_name, slb_vs_list)
+            cw = generateSLBVSCSV(cw, from_time, to_time, slb_vs_list)
         if slb_rs_list:
             cw.writerow("")
-            for each in slb_rs_list:
-                rs_name = each
-                cw = generateSLBRSCSV(cw, from_time, to_time, rs_name, slb_rs_list)
+            cw = generateSLBRSCSV(cw, from_time, to_time, slb_rs_list)
         if slb_vh_list:
             cw.writerow("")
-            for each in slb_vh_list:
-                vh_name = each
-                cw = generateSSLVHostCSV(cw, from_time, to_time, vh_name, slb_vh_list)
+            cw = generateSSLVHostCSV(cw, from_time, to_time, slb_vh_list)
         if slb_rh_list:
             cw.writerow("")
-            for each in slb_rh_list:
-                rh_name = each
-                cw = generateSSLRHostCSV(cw, from_time, to_time, rh_name, slb_rh_list)
+            cw = generateSSLRHostCSV(cw, from_time, to_time, slb_rh_list)
         if llb_total_list:
             cw.writerow("")
             cw = generateLLBTotalCSV(cw, from_time, to_time, llb_total_list)
@@ -1880,35 +1939,41 @@
     canvas.restoreState()
 
 def myLaterPages(canvas, doc):
-    styles=getSampleStyleSheet()
     canvas.saveState()
-    p = Paragraph("<img src='%s' width=70 height=21></img>" % get_pdf_logo(), styles["Heading1"])
-    w, h = p.wrap(doc.width, doc.bottomMargin)
-    p.drawOn(canvas, doc.leftMargin, doc.topMargin + doc.height - 0.5*cm)
-    #canvas.line(doc.leftMargin, doc.bottomMargin+doc.height + 0.5*cm, doc.leftMargin+doc.width, doc.bottomMargin+doc.height + 0.5*cm) 
+    logo_path = get_pdf_logo()
+    canvas.drawImage(logo_path, doc.leftMargin, doc.topMargin + doc.height - 0.5*cm, width=70, height=21, preserveAspectRatio=True, mask='auto')
     canvas.setFont(current_font,10)
     canvas.drawRightString(7.5 * inch, 0.75 * inch, unicode(_("Page %s")) % (doc.page))
     canvas.restoreState()
 
 def generatePDFReport(pdf_name, from_time, to_time, end_time, start_time, system_list, slb_vs_list, slb_rs_list, slb_vh_list, slb_rh_list, slb_total_list, llb_list, llb_total_list, gslb_list, tcp_list, ssl_total_list):
+    # Fetching data from Database before generating report
+    if slb_vs_list:
+        vs_data_dic, tcp_status_dic, tcp_syn_drop_dic = get_data_by_slb_vs_list(from_time, to_time, slb_vs_list)
+    if slb_rs_list:
+        rs_data_dic = get_data_by_slb_rs_list(from_time, to_time, slb_rs_list)
+    if slb_vh_list:
+        ssl_vhost_dic, each_ssl_status_dic = get_data_by_slb_vh_list(from_time, to_time, slb_vh_list)
+    if slb_rh_list:
+        ssl_rhost_dic = get_data_by_slb_rh_list(from_time, to_time, slb_rh_list)
+    if ssl_total_list:
+        ssl_status_dic = get_data_by_vh_names(from_time, SSLStatFacade.C_TYPE_TOTAL)
+
     sys_info = get_system_version()
     doc = SimpleDocTemplate(report_file_path+pdf_name,pagesize=letter,
                         rightMargin=60,leftMargin=60,
                         topMargin=70,bottomMargin=55)
-    env = create_default_environment("png")
-    pdfmetrics.registerFont(TTFont('alibaba', 'Alibaba-PuHuiTi-Regular.ttf'))
-    pdfmetrics.registerFont(TTFont('alibabajp', font_file_path + 'AlibabaSansJP/AlibabaSansJP-Regular.ttf'))
 
     styles=getSampleStyleSheet()
     styles.add(ParagraphStyle(fontName='alibaba', name='alibaba', alignment=TA_JUSTIFY))
     styles.add(ParagraphStyle(fontName='alibabajp', name='alibabajp', alignment=TA_JUSTIFY))
-    data = [[unicode(_("Create Time")), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())], 
-            [unicode(_("Statistics From")), start_time], 
-            [unicode(_("Statistics To")), end_time], 
-            [unicode(_("Host Name")), sys_info['host_name']], 
+    data = [[unicode(_("Create Time")), time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())],
+            [unicode(_("Statistics From")), start_time],
+            [unicode(_("Statistics To")), end_time],
+            [unicode(_("Host Name")), sys_info['host_name']],
             [unicode(_("System CPU")), sys_info['system_cpu']],
-            [unicode(_("System RAM")), sys_info['system_ram']], 
-            [unicode(_("Model")), sys_info['system_model']], 
+            [unicode(_("System RAM")), sys_info['system_ram']],
+            [unicode(_("Model")), sys_info['system_model']],
             [unicode(_("Cumulative Running Time")), sys_info['system_boot']]]
     t = generate_report_table_cover(data, 3)
     im = Image(get_pdf_logo(), 2*inch, 0.57*inch)
@@ -1918,29 +1983,29 @@
     story.append(t)
 
     if system_list:
-        story = generateSystemReport(from_time, to_time, system_list, env, styles, story)
+        story = generateSystemReport(from_time, to_time, system_list, styles, story)
     if slb_total_list:
-        story = generateSLBTotalReport(from_time, to_time, slb_total_list, env, styles, story)
+        story = generateSLBTotalReport(from_time, to_time, slb_total_list, styles, story)
     if slb_vs_list:
-        story = generateSLBVSReport(from_time, to_time, slb_vs_list, env, styles, story)
+        story = generateSLBVSReport(vs_data_dic, tcp_status_dic, tcp_syn_drop_dic, slb_vs_list, styles, story)
     if slb_rs_list:
-        story = generateSLBRSReport(from_time, to_time, slb_rs_list, env, styles, story)
+        story = generateSLBRSReport(rs_data_dic, slb_rs_list, styles, story)
     if slb_vh_list:
-        story = generateSSLVHostReport(from_time, to_time, slb_vh_list, env, styles, story)
+        story = generateSSLVHostReport(ssl_vhost_dic, each_ssl_status_dic, slb_vh_list, styles, story)
     if slb_rh_list:
-        story = generateSSLRHostReport(from_time, to_time, slb_rh_list, env, styles, story)
+        story = generateSSLRHostReport(ssl_rhost_dic, slb_rh_list, styles, story)
     if llb_total_list:
-        story = generateLLBTotalReport(from_time, to_time, llb_total_list, env, styles, story)
+        story = generateLLBTotalReport(from_time, to_time, llb_total_list, styles, story)
     if llb_list:
-        story = generateLLBReport(from_time, to_time, llb_list, env, styles, story)
+        story = generateLLBReport(from_time, to_time, llb_list, styles, story)
     if gslb_list:
-        story = generateGSLBReport(from_time, to_time, gslb_list, env, styles, story)
+        story = generateGSLBReport(from_time, to_time, styles, story)
     if tcp_list:
-        story = generateTCPReport(from_time, tcp_list, env, styles, story)
+        story = generateTCPReport(from_time, tcp_list, styles, story)
     if ssl_total_list:
-        story = generateSSLTotalReport(from_time, ssl_total_list, env, styles, story)
+        story = generateSSLTotalReport(ssl_status_dic, ssl_total_list, styles, story)
     doc.build(story,onFirstPage=myFirstPages, onLaterPages=myLaterPages)
-    
+
     return
 
 def generateReport(request):
