From e70c5bbc13b5c3bc7d5eb82c295d48ca6eac2a99 Mon Sep 17 00:00:00 2001 From: midoks Date: Sun, 24 Jul 2022 00:45:24 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E7=BB=9F=E8=AE=A1=20x10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/db.py | 32 +- plugins/webstats/index.html | 61 ++-- plugins/webstats/index.py | 194 +++++++++- plugins/webstats/js/stats.js | 691 ++++++++++++++++++++++++++++++----- 4 files changed, 864 insertions(+), 114 deletions(-) diff --git a/class/core/db.py b/class/core/db.py index de1426031..cf5822744 100755 --- a/class/core/db.py +++ b/class/core/db.py @@ -11,12 +11,13 @@ class Sql(): #------------------------------ __DB_FILE = None # 数据库文件 __DB_CONN = None # 数据库连接对象 - __DB_TABLE = "" # 被操作的表名称 - __OPT_WHERE = "" # where条件 - __OPT_LIMIT = "" # limit条件 - __OPT_ORDER = "" # order条件 - __OPT_FIELD = "*" # field条件 - __OPT_PARAM = () # where值 + __DB_TABLE = "" # 被操作的表名称 + __OPT_WHERE = "" # where条件 + __OPT_LIMIT = "" # limit条件 + __OPT_GROUP = "" # group条件 + __OPT_ORDER = "" # order条件 + __OPT_FIELD = "*" # field条件 + __OPT_PARAM = () # where值 def __init__(self): self.__DB_FILE = 'data/default.db' @@ -66,6 +67,13 @@ class Sql(): self.__OPT_ORDER = "" return self + def group(self, group): + if len(group): + self.__OPT_GROUP = " GROUP BY " + group + else: + self.__OPT_GROUP = "" + return self + def limit(self, limit): # LIMIT条件 if len(limit): @@ -112,18 +120,24 @@ class Sql(): except Exception as ex: return "error: " + str(ex) - def inquiry(self): + def inquiry(self, input_field=''): # 查询数据集 # 不清空查询参数 self.__GetConn() try: sql = "SELECT " + self.__OPT_FIELD + " FROM " + self.__DB_TABLE + \ - self.__OPT_WHERE + self.__OPT_ORDER + self.__OPT_LIMIT + self.__OPT_WHERE + self.__OPT_GROUP + self.__OPT_ORDER + self.__OPT_LIMIT + # print(sql) result = self.__DB_CONN.execute(sql, self.__OPT_PARAM) data = result.fetchall() # 构造字曲系列 if self.__OPT_FIELD != "*": - field = self.__OPT_FIELD.split(',') + + if input_field != "": + field = input_field.split(',') + else: + field = self.__OPT_FIELD.split(',') + tmp = [] for row in data: i = 0 diff --git a/plugins/webstats/index.html b/plugins/webstats/index.html index 95449822b..4ad797949 100755 --- a/plugins/webstats/index.html +++ b/plugins/webstats/index.html @@ -17,10 +17,47 @@ color: #fff; } +.divpre { + padding: 9.5px; + margin: 0 0 10px; + font-size: 13px; + line-height: 1.42857143; + color: #333; + word-break: break-all; + word-wrap: break-word; + background-color: #f6f6f6; + border: 1px solid #ddd; + border-radius: 4px; + max-height: 100px; + overflow: auto; +} + .form-control{ border-radius: 0px; } +.ws_tips { + color: #777; + margin-left: -10px; + vertical-align: middle; +} + +.tips { + border: 1px solid #cbcbcb; + border-radius: 8px; + color: #cbcbcb; + cursor: pointer; + display: inline-block; + font-family: arial; + font-size: 12px; + font-style: normal; + height: 14px; + line-height: 14px; + margin-left: 5px; + text-align: center; + width: 14px; +} + .ws_setting .ws_title { display: inline-block; width: 100px; @@ -44,12 +81,6 @@ height: 26px; } -.ws_setting .ws_content .ws_tips { - color: #777; - margin-left: -10px; - vertical-align: middle; -} - .ws_setting .tab-nav { margin-bottom: 10px; } @@ -63,21 +94,6 @@ resize: none; } -.ws_setting .ws_content .tips { - border: 1px solid #cbcbcb; - border-radius: 8px; - color: #cbcbcb; - cursor: pointer; - display: inline-block; - font-family: arial; - font-size: 12px; - font-style: normal; - height: 14px; - line-height: 14px; - margin-left: 5px; - text-align: center; - width: 14px; -} .ws_setting .ws_content .item-line { display: block; @@ -98,7 +114,8 @@

服务

概览

-

错误日志

+

客服端统计

+

错误日志

网站日志

全局设置

diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index 2193bbe8a..ac6761d41 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -329,7 +329,7 @@ def getLogsList(): limit = str(page_size) + ' offset ' + str(page_size * (page - 1)) conn = pSqliteDb('web_logs', domain) - field = 'time,ip,domain,server_name,method,status_code,request_time,uri,body_length' + field = 'time,ip,domain,server_name,method,protocol,status_code,request_headers,ip_list,client_port,body_length,user_agent,referer,request_time,uri,body_length' condition = '' conn = conn.field(field) conn = conn.where("1=1", ()) @@ -384,6 +384,193 @@ def getLogsList(): return mw.returnJson(True, 'ok', data) +def getLogsErrorList(): + args = getArgs() + check = checkArgs(args, ['page', 'page_size', + 'site', 'status_code', 'query_date']) + if not check[0]: + return check[1] + + page = int(args['page']) + page_size = int(args['page_size']) + domain = args['site'] + tojs = args['tojs'] + status_code = args['status_code'] + query_date = args['query_date'] + setDefaultSite(domain) + + limit = str(page_size) + ' offset ' + str(page_size * (page - 1)) + conn = pSqliteDb('web_logs', domain) + + field = 'time,ip,domain,server_name,method,protocol,status_code,request_headers,ip_list,client_port,body_length,user_agent,referer,request_time,uri,body_length' + conn = conn.field(field) + conn = conn.where("1=1", ()) + + if status_code != "all": + if status_code.find("x") > -1: + status_code = status_code.replace("x", "%") + conn = conn.andWhere("status_code like ?", (status_code,)) + else: + conn = conn.andWhere("status_code=?", (status_code,)) + else: + conn = conn.andWhere( + "(status_code like '50%' or status_code like '40%')", ()) + + todayTime = time.strftime('%Y-%m-%d 00:00:00', time.localtime()) + todayUt = int(time.mktime(time.strptime(todayTime, "%Y-%m-%d %H:%M:%S"))) + if query_date == 'today': + conn = conn.andWhere("time>=?", (todayUt,)) + elif query_date == "yesterday": + conn = conn.andWhere("time>=? and time<=?", (todayUt - 86400, todayUt)) + elif query_date == "l7": + conn = conn.andWhere("time>=?", (todayUt - 7 * 86400,)) + elif query_date == "l30": + conn = conn.andWhere("time>=?", (todayUt - 30 * 86400,)) + else: + exlist = query_date.split("-") + conn = conn.andWhere("time>=? and time<=?", (exlist[0], exlist[1])) + + clist = conn.limit(limit).order('time desc').inquiry() + count_key = "count(*) as num" + count = conn.field(count_key).limit('').order('').inquiry() + count = count[0][count_key] + + data = {} + _page = {} + _page['count'] = count + _page['p'] = page + _page['row'] = page_size + _page['tojs'] = tojs + data['page'] = mw.getPage(_page) + data['data'] = clist + + return mw.returnJson(True, 'ok', data) + + +def toSumField(sql): + l = sql.split(",") + field = "" + for x in l: + field += "sum(" + x + ") as " + x + "," + field = field.strip(',') + return field + + +def getClientStatList(): + args = getArgs() + check = checkArgs(args, ['page', 'page_size', + 'site', 'query_date']) + if not check[0]: + return check[1] + + page = int(args['page']) + page_size = int(args['page_size']) + domain = args['site'] + tojs = args['tojs'] + query_date = args['query_date'] + setDefaultSite(domain) + + conn = pSqliteDb('client_stat', domain) + stat = pSqliteDb('client_stat', domain) + + # 列表 + limit = str(page_size) + ' offset ' + str(page_size * (page - 1)) + field = 'time,weixin,android,iphone,mac,windows,linux,edeg,firefox,msie,metasr,qh360,theworld,tt,maxthon,opera,qq,uc,pc2345,safari,chrome,machine,mobile,other' + field_sum = toSumField(field.replace("time,", "")) + time_field = "substr(time,1,8)," + field_sum = time_field + field_sum + + stat = stat.field(field_sum) + if query_date == "today": + todayTime = time.strftime( + '%Y%m%d00', time.localtime(time.time() - 0 * 86400)) + stat.where("time >= ?", (todayTime,)) + elif query_date == "yesterday": + todayTime = time.strftime( + '%Y%m%d00', time.localtime(time.time() - 1 * 86400)) + stat.where("time >= ?", (todayTime,)) + elif query_date == "l7": + todayTime = time.strftime( + '%Y%m%d00', time.localtime(time.time() - 7 * 86400)) + stat.where("time >= ?", (todayTime,)) + elif query_date == "l30": + todayTime = time.strftime( + '%Y%m%d00', time.localtime(time.time() - 30 * 86400)) + stat.where("time >= ?", (todayTime,)) + else: + exlist = query_date.split("-") + start = time.strftime( + '%Y%m%d00', time.localtime(int(exlist[0]))) + end = time.strftime( + '%Y%m%d23', time.localtime(int(exlist[1]))) + stat.where("time >= ? and time <= ? ", (start, end,)) + + # 图表数据 + statlist = stat.group('substr(time,1,4)').inquiry(field) + + if len(statlist) > 0: + del(statlist[0]['time']) + + pc = 0 + pc_key_list = ['chrome', 'qh360', 'edeg', 'firefox', 'safari', 'msie', + 'metasr', 'theworld', 'tt', 'maxthon', 'opera', 'qq', 'pc2345'] + + for x in pc_key_list: + pc += statlist[0][x] + + mobile = 0 + mobile_key_list = ['mobile', 'android', 'iphone', 'weixin'] + for x in mobile_key_list: + mobile += statlist[0][x] + reqest_total = pc + mobile + + sum_data = { + "pc": pc, + "mobile": mobile, + "reqest_total": reqest_total, + } + + statlist = sorted(statlist[0].items(), + key=lambda x: x[1], reverse=True) + _statlist = statlist[0:10] + __statlist = {} + statlist = [] + for x in _statlist: + __statlist[x[0]] = x[1] + statlist.append(__statlist) + else: + sum_data = { + "pc": 0, + "mobile": 0, + "reqest_total": 0, + } + statlist = [] + + # 列表数据 + conn = conn.field(field_sum) + clist = conn.group('substr(time,1,8)').limit( + limit).order('time desc').inquiry(field) + + sql = "SELECT count(*) num from (\ + SELECT count(*) as num FROM client_stat GROUP BY substr(time,1,8)\ + )" + result = conn.query(sql, ()) + result = list(result) + count = result[0][0] + + data = {} + _page = {} + _page['count'] = count + _page['p'] = page + _page['row'] = page_size + _page['tojs'] = tojs + data['page'] = mw.getPage(_page) + data['data'] = clist + data['stat_list'] = statlist + data['sum_data'] = sum_data + + return mw.returnJson(True, 'ok', data) + if __name__ == "__main__": func = sys.argv[1] if func == 'status': @@ -406,5 +593,10 @@ if __name__ == "__main__": print(getDefaultSite()) elif func == 'get_logs_list': print(getLogsList()) + elif func == 'get_logs_error_list': + print(getLogsErrorList()) + elif func == 'get_client_stat_list': + print(getClientStatList()) + else: print('error') diff --git a/plugins/webstats/js/stats.js b/plugins/webstats/js/stats.js index 6bbc59425..b8b51393f 100644 --- a/plugins/webstats/js/stats.js +++ b/plugins/webstats/js/stats.js @@ -165,31 +165,443 @@ function wsOverview(){ -function wsSitesErrorLog(){ + + +function wsClientStatLogRequest(page){ + var args = {}; - args['page'] = 1; + args['page'] = page; args['page_size'] = 10; - args['site'] = 'unset'; - args['tojs'] = 'wsSitesErrorLog'; - wsPost('get_logs_list', '' ,args, function(rdata){ + + args['site'] = $('select[name="site"]').val(); + args['status_code'] = $('select[name="status_code"]').val(); + + var query_date = 'today'; + if ($('#time_choose').attr("data-name") != ''){ + query_date = $('#time_choose').attr("data-name"); + } else { + query_date = $('#search_time button.cur').attr("data-name"); + } + args['query_date'] = query_date; + + args['tojs'] = 'wsClientStatLogRequest'; + wsPost('get_client_stat_list', '' ,args, function(rdata){ var rdata = $.parseJSON(rdata.data); - // console.log(rdata); var list = ''; var data = rdata.data.data; - for(i in data){ - list += ''; - list += '' + data[i]['time']+''; - list += '' + data[i]['domain'] +''; - list += '' + data[i]['ip'] +''; - list += '' + data[i]['body_length'] +''; - list += '' + data[i]['request_time'] +'ms'; - list += '' + data[i]['uri'] +''; - list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; - list += '详情'; - list += ''; + if (data.length > 0){ + for(i in data){ + list += ''; + list += '' + data[i]['time']+''; + list += '' + data[i]['android'] +''; + list += '' + data[i]['iphone'] +''; + list += '' + data[i]['windows'] +''; + list += '' + data[i]['chrome'] +''; + list += '' + data[i]['weixin'] +''; + list += '' + data[i]['qh360'] +''; + list += '' + data[i]['edeg'] +''; + list += '' + data[i]['firefox'] +''; + list += '' + data[i]['safari'] +''; + list += '' + data[i]['mac'] +''; + list += '' + data[i]['msie'] +''; + list += '' + data[i]['machine'] +''; + list += '' + data[i]['other'] +''; + list += ''; + } + } else{ + list += '网站日志为空'; } - var table = '
\ -
\ + + var table = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \\ + \ + '+ list +'\ +
日期安桌iOSWindowsChrome微信360Edge火狐SafariMacIE机器 ?其他
\ +
\ +
'; + $('#ws_table').html(table); + $('#wsPage').html(rdata.data.page); + $('[data-toggle="tooltip"]').tooltip(); + + + // 图形化 + var initData = rdata.data.stat_list; + var sumData = rdata.data.sum_data; + var colorList = ['#6ec71e','#4885FF']; + var source_name = {android:'安卓',iphone:'iOS',windows:'Windows',chrome:'Chrome',weixin:'微信',qh360:'360',edeg:'Edge',firefox:'火狐',safari:'Safari',mac:'Mac',linux:'Linux',msie:'IE',metasr:'搜狗',theworld:'世界之窗',tt:'腾讯TT',maxthon:'遨游',opera:'Opera',qq:'QQ浏览器',uc:'UC',pc2345:'2345',other:'其他',machine:'Machine'}; + var lenend2_obj = {}; + + var leftEc = echarts.init(document.getElementById('echart_left_total')); + var rightEc = echarts.init(document.getElementById('echart_right_total')); + + + var datas = [ + { value: sumData.pc, name: 'PC客服端' }, + { value: sumData.mobile, name: '移动客服端' }, + ]; + + var leftOption = { + backgroundColor:'#fff', + title: { + text: sumData.reqest_total, + textStyle: { + color: '#484848', + fontSize: 17 + }, + subtext: '总请求数', + subtextStyle: { + color: '#717171', + fontSize: 15 + }, + itemGap: 20, + left: 'center', + top: '42%' + }, + tooltip: { + trigger: 'item' + }, + series: [{ + type: 'pie', + radius: ['45%', '55%'], + center: ["50%", "50%"], + clockwise: true, + avoidLabelOverlap: false, + hoverOffset: 15, + itemStyle: { + normal: { + label: { + show: true, + position: 'outside', + color: '#666', + formatter: function(params) { + var percent = 0; + var total = 0; + for (var i = 0; i < datas.length; i++) { + total += datas[i].value; + } + if(params.name !== '') { + return params.name + '\n' + '\n' + params.value + '/次'; + }else { + return ''; + } + }, + }, + labelLine: { + length: 20, + length2: 10 + }, + color: function(params) { + return colorList[params.dataIndex] + } + } + }, + data: datas + },{ + itemStyle: { + normal: { + color: '#F5F6FA', + } + }, + type: 'pie', + hoverAnimation: false, + radius: ['42%', '58%'], + center: ["50%", "50%"], + label: { + normal: { + show:false, + } + }, + data: [], + z:-1 + }] + } + leftEc.setOption(leftOption); + + var xAxixName = $('#search_time button.cur').text(); + var is_compare = false; + + var lenend = []; + var serData = []; + for(var i = 0;i (is_compare?2:4)) { + lenend2_obj[lenend[i]] = false; + } else { + lenend2_obj[lenend[i]] = true; + } + } + + var rightOption = { + backgroundColor:'#fff', + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'shadow' , + textStyle: { + color: '#fff', + fontSize: '26' + }, + } + }, + legend: { + top:'0%', + data: lenend, + selected:lenend2_obj, + textStyle:{ + fontSize:12, + color:'#808080' + }, + icon:'rect' + }, + grid: { + top:60, + left:60, + right:0, + bottom:50 + }, + xAxis: [{ + type: 'category', + axisLabel:{ + color:'#4D4D4D', + fontSize:14, + fontWeight:'bold' + }, + data: [xAxixName], + }], + color:['#4fa8f9', '#6ec71e', '#f56e6a', '#fc8b40', '#818af8', '#31c9d7', '#f35e7a', '#ab7aee', + '#14d68b', '#cde5ff'], + yAxis: [{ + type: 'value', + axisLine: { + show: false, + }, + axisTick: { + show: false + }, + splitNumber:4, //y轴分割线数量 + axisLabel:{ + color:'#8C8C8C' + }, + splitLine:{ + lineStyle:{ + type:'dashed' + } + } + }], + series: serData + } + + + rightEc.setOption(rightOption); + + var oop = lenend.slice(0, (is_compare?3:5)); + rightEc.on('legendselectchanged', function (params) { + var legend_option = this.getOption(),newAxisName = []; + $.each(legend_option['xAxis'][0]['data'],function(index,item){ + newAxisName.push(item.replace(/\([^\)]*\)/g,"")) + }) + legend_option['xAxis'][0]['data'] = newAxisName; + + var num = 0; + for(var e in params.selected){ + if(params.selected.hasOwnProperty(e)){ + params.selected[e]? num++ : ''; + } + } + if(num > (is_compare?3:5)){ + oop.push(params.name) + } + if (num > (is_compare?3:5)) { + var hah = oop.slice(oop.length - (is_compare?4:6), oop.length - (is_compare?3:4))[0] + ''; + legend_option.legend[0].selected[hah] = false; + } + if (num < 1){ + legend_option.legend[0].selected[params.name] = true; + } + this.setOption(legend_option) + }); + }); +} + + +function wsClientStat(){ +//////////////////////////////////////////////////////////////////////////////////////////////////////// +var randstr = getRandomString(10); + +var html = '
\ +
\ + 网站: \ + \ + 时间: \ +
\ +
\ + \ + \ + \ + \ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ +
'; +$(".soft-man-con").html(html); + +//日期范围 +laydate.render({ + elem: '#time_choose', + value:'', + range:true, + done:function(value, startDate, endDate){ + if(!value){ + return false; + } + + $('#search_time button').each(function(){ + $(this).removeClass('cur'); + }); + + var timeA = value.split('-') + var start = $.trim(timeA[0]+'-'+timeA[1]+'-'+timeA[2]) + var end = $.trim(timeA[3]+'-'+timeA[4]+'-'+timeA[5]) + query_txt = toUnixTime(start + " 00:00:00") + "-"+ toUnixTime(end + " 00:00:00") + + $('#time_choose').attr("data-name",query_txt); + $('#time_choose').addClass("cur"); + + wsClientStatLogRequest(1); + }, +}); + +$('#search_time button:eq(0)').addClass('cur'); +$('#search_time button').click(function(){ + $('#search_time button').each(function(){ + if ($(this).hasClass('cur')){ + $(this).removeClass('cur'); + } + }); + $('#time_choose').attr("data-name",''); + $('#time_choose').removeClass("cur"); + + $(this).addClass('cur'); + + wsClientStatLogRequest(1); +}); + + +$('select[name="status_code"]').change(function(){ + wsClientStatLogRequest(1); +}); + +wsPost('get_default_site','',{},function(rdata){ + $('select[name="site"]').html(''); + + var rdata = $.parseJSON(rdata.data); + var rdata = rdata.data; + var default_site = rdata["default"]; + var select = ''; + for (var i = 0; i < rdata["list"].length; i++) { + if (default_site == rdata["list"][i]){ + select += ''; + } else{ + select += ''; + } + } + $('select[name="site"]').html(select); + wsClientStatLogRequest(1); + + $('select[name="site"]').change(function(){ + wsClientStatLogRequest(1); + }); +}); + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +} + + + + +function wsTableErrorLogRequest(page){ + + var args = {}; + args['page'] = page; + args['page_size'] = 10; + + args['site'] = $('select[name="site"]').val(); + args['status_code'] = $('select[name="status_code"]').val(); + + var query_date = 'today'; + if ($('#time_choose').attr("data-name") != ''){ + query_date = $('#time_choose').attr("data-name"); + } else { + query_date = $('#search_time button.cur').attr("data-name"); + } + args['query_date'] = query_date; + + args['tojs'] = 'wsTableErrorLogRequest'; + wsPost('get_logs_error_list', '' ,args, function(rdata){ + var rdata = $.parseJSON(rdata.data); + var list = ''; + var data = rdata.data.data; + if (data.length > 0){ + for(i in data){ + list += ''; + list += '' + getLocalTime(data[i]['time'])+''; + list += '' + data[i]['domain'] +''; + list += '' + data[i]['ip'] +''; + list += '' + toSize(data[i]['body_length']) +''; + list += '' + data[i]['request_time'] +'ms'; + list += '' + data[i]['uri'] +''; + list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; + list += '详情'; + list += ''; + } + } else{ + list += '网站日志为空'; + } + + var table = '
\ \ \ \ @@ -197,76 +609,163 @@ function wsSitesErrorLog(){ \ \ \ - \ + \ \ \ \ '+ list +'\
时间IP响应耗时URLURL状态/类型操作
\
\ -
\ -
'; - - var html = '
\ -
\ - 网站: \ - \ - 时间: \ -
\ -
\ - \ - \ - \ - \ -
\ - \ -
\ -
\ -
\ - 请求类型: \ - \ - 状态码: \ - \ - 蜘蛛过滤: \ - \ - URL过滤: \ -
\ - \ -
\ - \ -
\ -
\ -
\ - '+table+'\ -
'; - $(".soft-man-con").html(html); +
'; + $('#ws_table').html(table); $('#wsPage').html(rdata.data.page); + + + $(".tablescroll .details").click(function(){ + var index = $(this).attr('data-id'); + var res = data[index]; + layer.open({ + type: 1, + title: "【"+res.domain + "】详情信息", + area: '600px', + closeBtn: 2, + shadeClose: false, + content: '
\ +
\ + \ + \ + \\ +
时间' + getLocalTime(res.time) + '真实IP' + res.ip + '客户端端口'+(res.client_port>0 && res.client_port != ''?res.client_port:'')+'
类型' + res.method + '状态' + res.status_code + '响应大小' + toSize(res.body_length) + '
\ +
协议
\ +
' + res.protocol + '
\ +
URL
\ +
' + $('
').text(res.uri).html() + '
\ +
完整IP列表
\ +
' + $('
').text(res.ip_list).html() + '
\ +
来路
\ +
' + $('
').text(res.referer == null ?'None':res.referer).html() + '
\ +
User-Agent
\ +
' + $('
').text(res.user_agent).html() + '
\ +
处理耗时
\ +
' +res.request_time + ' ms
\ +
', + }); + }); }); } +function wsSitesErrorLog(){ +//////////////////////////////////////////////////////////////////////////////////////////////////////// +var randstr = getRandomString(10); + +var html = '
\ +
\ + 网站: \ + \ + 状态码: \ + \ + 时间: \ +
\ +
\ + \ + \ + \ + \ +
\ + \ +
\ +
\ +
\ +
'; +$(".soft-man-con").html(html); + +//日期范围 +laydate.render({ + elem: '#time_choose', + value:'', + range:true, + done:function(value, startDate, endDate){ + if(!value){ + return false; + } + + $('#search_time button').each(function(){ + $(this).removeClass('cur'); + }); + + var timeA = value.split('-') + var start = $.trim(timeA[0]+'-'+timeA[1]+'-'+timeA[2]) + var end = $.trim(timeA[3]+'-'+timeA[4]+'-'+timeA[5]) + query_txt = toUnixTime(start + " 00:00:00") + "-"+ toUnixTime(end + " 00:00:00") + + $('#time_choose').attr("data-name",query_txt); + $('#time_choose').addClass("cur"); + + wsTableErrorLogRequest(1); + }, +}); + +$('#search_time button:eq(0)').addClass('cur'); +$('#search_time button').click(function(){ + $('#search_time button').each(function(){ + if ($(this).hasClass('cur')){ + $(this).removeClass('cur'); + } + }); + $('#time_choose').attr("data-name",''); + $('#time_choose').removeClass("cur"); + + $(this).addClass('cur'); + + wsTableErrorLogRequest(1); +}); + + +$('select[name="status_code"]').change(function(){ + wsTableErrorLogRequest(1); +}); + +wsPost('get_default_site','',{},function(rdata){ + $('select[name="site"]').html(''); + + var rdata = $.parseJSON(rdata.data); + var rdata = rdata.data; + var default_site = rdata["default"]; + var select = ''; + for (var i = 0; i < rdata["list"].length; i++) { + if (default_site == rdata["list"][i]){ + select += ''; + } else{ + select += ''; + } + } + $('select[name="site"]').html(select); + wsTableErrorLogRequest(1); + + $('select[name="site"]').change(function(){ + wsTableErrorLogRequest(1); + }); +}); + +//////////////////////////////////////////////////////////////////////////////////////////////////////// +} + + function wsTableLogRequest(page){ - + var args = {}; args['page'] = page; args['page_size'] = 10; @@ -292,7 +791,6 @@ function wsTableLogRequest(page){ args['tojs'] = 'wsTableLogRequest'; wsPost('get_logs_list', '' ,args, function(rdata){ var rdata = $.parseJSON(rdata.data); - console.log(rdata); var list = ''; var data = rdata.data.data; if (data.length > 0){ @@ -305,7 +803,7 @@ function wsTableLogRequest(page){ list += '' + data[i]['request_time'] +'ms'; list += '' + data[i]['uri'] +''; list += '' + data[i]['status_code']+'/' + data[i]['method'] +''; - list += '详情'; + list += '详情'; list += ''; } } else{ @@ -330,6 +828,38 @@ function wsTableLogRequest(page){
'; $('#ws_table').html(table); $('#wsPage').html(rdata.data.page); + + + $(".tablescroll .details").click(function(){ + var index = $(this).attr('data-id'); + var res = data[index]; + layer.open({ + type: 1, + title: "【"+res.domain + "】详情信息", + area: '600px', + closeBtn: 2, + shadeClose: false, + content: '
\ +
\ + \ + \ + \\ +
时间' + getLocalTime(res.time) + '真实IP' + res.ip + '客户端端口'+(res.client_port>0 && res.client_port != ''?res.client_port:'')+'
类型' + res.method + '状态' + res.status_code + '响应大小' + toSize(res.body_length) + '
\ +
协议
\ +
' + res.protocol + '
\ +
URL
\ +
' + $('
').text(res.uri).html() + '
\ +
完整IP列表
\ +
' + $('
').text(res.ip_list).html() + '
\ +
来路
\ +
' + $('
').text(res.referer == null ?'None':res.referer).html() + '
\ +
User-Agent
\ +
' + $('
').text(res.user_agent).html() + '
\ +
处理耗时
\ +
' +res.request_time + ' ms
\ +
', + }); + }); }); } @@ -482,9 +1012,6 @@ wsPost('get_default_site','',{},function(rdata){ }); }); - - - //////////////////////////////////////////////////////////////////////////////////////////////////////// }