Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py	(revision 2461)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/djproject/urls.py	(working copy)
@@ -12,6 +12,7 @@
 from hive.composer import KibanaProxyView, elastic_proxy, reporting_downloading_handler, reporting_logo_handler, composer_config, composer_status, composer_query, composer_proxy
 from hive.storage import storage_mangement
 from hive.log_location import handle_log_location_app
+from hive.llb_stats import handle_llb_stats_req
 
 js_info_dict = {
     #'packages': ('your.app.package',),
@@ -58,6 +59,7 @@
     url(r'^composer_config/(?P<app>\w+)', composer_config),
     url(r'^composer_status/(?P<app>\w+)', composer_status),
     url(r'^composer_query$', composer_query),
+    url(r'^llbstats(?:/(?P<app>\w+))?$', handle_llb_stats_req),
     url(r'^log/(?P<app>\w+)$', handle_log_location_app),
     url(r'^real_service$', real_service),
     url(r'^rs_block$', rs_block),
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/__init__.py	(added)
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/__init__.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/__init__.py	(revision 0)
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/db/llb_stats_queries.py	(working copy)
@@ -0,0 +1,128 @@
+import time
+import hashlib
+import httplib
+import json
+from django.http import HttpResponse
+from djproject.an_settings import CMDATA
+from hive.custom_exceptions import generic_exception as ge
+
+
+class LLBStatsDB:
+    """Class to handle all DB interactions for LLB Stats"""
+
+    def __init__(self):
+        pass
+
+    BASE_URL = "/v1/datasource/proxy/1/query"
+    CONTENT_TYPE = {'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'}
+
+    @staticmethod
+    def execute_db_query(req_dict):
+        """Executes a database query and returns a response"""
+        http_client = None
+
+        try:
+            req_payload = req_dict["body"]
+            timestamp = str(int(time.time()))
+            m = hashlib.md5()
+            m.update(CMDATA['COMPOSER_KEY'] + str(timestamp) + req_dict["url"] + CMDATA['COMPOSER_SECRET'])
+
+            query_string = req_dict["path"]
+            if query_string == '':
+                query_string += "time=" + timestamp + "&sign=" + m.hexdigest()
+            else:
+                query_string += "&time=" + timestamp + "&sign=" + m.hexdigest()
+
+            http_client = httplib.HTTPConnection(CMDATA['COMPOSER_IP'], str(CMDATA['COMPOSER_PORT']), True, timeout=300)
+            http_client.request(req_dict['method'], req_dict["url"] + "?" + query_string, req_payload,
+                                req_dict['config'])
+
+            response = http_client.getresponse()
+            response_data = {
+                'status': response.status,
+                'reason': response.reason,
+                'body': response.read(),
+            }
+        except ge.ANInternalException as exp:
+            return HttpResponse(json.dumps({
+                'parm_name': exp.parm_name,
+                'error': exp.error_code,
+                'message': exp.description,
+                'data': None
+            }), content_type='application/json', status=exp.error_code)
+        except Exception as e:
+            return HttpResponse(json.dumps({
+                'error': 500,
+                'message': "Request Composer_ui Error",
+                'data': str(e)
+            }), content_type='application/json')
+        else:
+            if response_data['status'] == 200:
+                return HttpResponse(response_data['body'], content_type='application/json')
+            else:
+                return HttpResponse(json.dumps({
+                    'error': response_data['status'],
+                    'message': response_data['reason'],
+                    'data': response_data['body']
+                }), content_type='application/json')
+        finally:
+            if http_client:
+                http_client.close()
+
+    @staticmethod
+    def get_llb_stats_query_str(request):
+        """Constructs the query for LLB stats"""
+        req_dict = {
+            "url": LLBStatsDB.BASE_URL,
+            "path": "db=composer&epoch=ms",
+            "method": "POST",
+            "body": {},
+            "config": LLBStatsDB.CONTENT_TYPE
+        }
+        query_string = ('SELECT LAST(linkGateway) AS linkGateway, last(linkThresh) AS linkThresh, last(linkUsage) '
+                        'AS linkUsage, last(linkBandwidIn) AS linkBandwidIn, last(linkBandwidOut) AS linkBandwidOut, '
+                        'last(linkConn) AS linkConn, last(linkHits) AS linkHits FROM llbStats WHERE time > now()-20s '
+                        'GROUP BY agent_host, linkName, linkStatus;')
+
+        if 'query' in request and 'agent_host' in request['query']:
+            query_string = ('SELECT LAST(linkGateway) AS linkGateway, last(linkThresh) AS linkThresh, last(linkUsage) '
+                            'AS linkUsage, last(linkBandwidIn) AS linkBandwidIn, last(linkBandwidOut) AS '
+                            'linkBandwidOut, last(linkConn) AS linkConn, last(linkHits) AS linkHits FROM llbStats '
+                            'WHERE agent_host =~ {} AND time > now()-20s GROUP BY agent_host, linkName, linkStatus;'
+                            ).format(request['query']['agent_host'])
+
+        query_string = LLBStatsDB.format_query_string(query_string)
+        req_dict["body"] = 'q=' + query_string
+        return req_dict
+
+    @staticmethod
+    def get_llb_monitoring_query_str(request):
+        """Constructs the query for LLB monitoring data"""
+        req_dict = {
+            "url": LLBStatsDB.BASE_URL,
+            "path": "db=composer&epoch=ms",
+            "method": "POST",
+            "body": {},
+            "config": LLBStatsDB.CONTENT_TYPE
+        }
+        query_string = ('SELECT TOP(hits, 5), linkName, agent_host FROM (SELECT MAX(linkHits)-MIN(linkHits) AS hits '
+                        'FROM llbStats GROUP BY linkName, agent_host) WHERE time > now()-20s; '
+                        'SELECT TOP(last, 5), linkName, agent_host FROM (SELECT LAST(linkConn) FROM llbStats GROUP BY '
+                        'linkName, agent_host) WHERE time > now()-20s;')
+
+        if 'query' in request and 'agent_host' in request['query']:
+            query_string = ('SELECT TOP(hits, 5), linkName, agent_host FROM (SELECT MAX(linkHits)-MIN(linkHits) AS '
+                            'hits FROM llbStats WHERE agent_host =~ {} GROUP BY linkName, agent_host) WHERE time > '
+                            'now()-20s; SELECT TOP(last, 5), linkName, agent_host FROM (SELECT LAST(linkConn) FROM '
+                            'llbStats WHERE agent_host =~ {} GROUP BY linkName, agent_host) WHERE time > now()-20s;'
+                            ).format(request['query']['agent_host'])
+
+        query_string = LLBStatsDB.format_query_string(query_string)
+        req_dict["body"] = 'q=' + query_string
+        return req_dict
+
+    @staticmethod
+    def format_query_string(query):
+        """Formats query string to ensure proper URL encoding"""
+        return query.strip().replace(' ', "%20").replace('<', "%3C").replace('>', "%3E").replace(',', "%2C") \
+            .replace(';', "%3B").replace('+', "%2B").replace('/', "%2F").replace('|', "%7C").replace('=', "%3D")
\ No newline at end of file
Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/llb_stats.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/llb_stats.py	(revision 0)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/hive/llb_stats.py	(working copy)
@@ -0,0 +1,27 @@
+from django.http import HttpResponse
+import json
+from hive.db.llb_stats_queries import LLBStatsDB
+
+
+def handle_llb_stats_req(request, app):
+    if app == '' or app is None and request.method == 'GET':
+        return get_llb_stats(request)
+    elif app == 'monitoring_data' and request.method == 'GET':
+        return get_monitoring_data(request)
+    else:
+        return HttpResponse(json.dumps({
+            'error': 405,
+            'message': "Invalid HTTP method"
+        }), content_type='application/json')
+
+
+def get_llb_stats(request):
+    req_dict = LLBStatsDB.get_llb_stats_query_str(request)
+    response = LLBStatsDB.execute_db_query(req_dict)
+    return response
+
+
+def get_monitoring_data(request):
+    req_dict = LLBStatsDB.get_llb_monitoring_query_str(request)
+    response = LLBStatsDB.execute_db_query(req_dict)
+    return response
\ No newline at end of file
