protected override IEnumerable <NodeData> Search(Pager p) { PageSetting.EnableAdd = false; var nodeId = p["nodeId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); if (nodeId > 0) { // 最近10小时 if (p.PageSize == 20 && nodeId > 0) { p.PageSize = 24 * 60; } PageSetting.EnableNavbar = false; } if (p.Sort.IsNullOrEmpty()) { p.OrderBy = _.ID.Desc(); } var list = NodeData.Search(nodeId, start, end, p["Q"], p); if (list.Count > 0) { // 绘制日期曲线图 var node = Node.FindByID(nodeId); if (nodeId >= 0 && node != null) { var list2 = list.OrderBy(e => e.ID).ToList(); var chart = new ECharts { Title = new ChartTitle { Text = node.Name }, Height = 400, }; chart.SetX(list2, _.LocalTime, e => e.LocalTime.ToString("HH:mm")); chart.SetY("指标"); chart.AddLine(list2, _.CpuRate, e => (Int32)(e.CpuRate * 100), true); chart.Add(list2, _.AvailableMemory, "line", e => node.Memory == 0 ? 0 : (e.AvailableMemory * 100 / node.Memory)); chart.Add(list2, _.AvailableFreeSpace, "line", e => node.TotalSize == 0 ? 0 : (e.AvailableFreeSpace * 100 / node.TotalSize)); chart.Add(list2, _.TcpConnections); chart.Add(list2, _.TcpTimeWait); chart.Add(list2, _.TcpCloseWait); chart.Add(list2, _.Temperature); chart.Add(list2, _.Delay); chart.Add(list2, _.Offset); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } } return(list); }
/// <summary>搜索数据集</summary> /// <param name="p"></param> /// <returns></returns> protected override IEnumerable <VisitStat> Search(Pager p) { var model = new VisitStatModel(); model.Fill(p.Params, StatLevels.Day); model.Page = p["p"]; p.RetrieveState = true; var list = VisitStat.Search(model, p["dtStart"].ToDateTime(), p["dtEnd"].ToDateTime(), p); if (list.Count > 0) { var chart = new ECharts(); chart.SetX(list, _.Time, e => e.Time.ToString("yyyy-MM-dd")); chart.SetY(_.Times); chart.AddLine(list, _.Times, null, true); chart.Add(list, _.Users); chart.Add(list, _.IPs); chart.Add(list, _.Error); chart.SetTooltip(); var chart2 = new ECharts(); chart2.AddPie(list, _.Times, e => new { name = e.Time.ToString("yyyy-MM-dd"), value = e.Times }); ViewBag.Charts = new[] { chart }; ViewBag.Charts2 = new[] { chart2 }; } return(list); }
protected override IEnumerable <AppDayStat> Search(Pager p) { var appId = p["appId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 默认排序 if (appId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { start = DateTime.Today.AddDays(-30); p["dtStart"] = start.ToString("yyyy-MM-dd"); p.Sort = __.StatDate; p.Desc = false; p.PageSize = 100; } p.RetrieveState = true; var list = AppDayStat.Search(appId, start, end, p["Q"], p); if (list.Count > 0) { // 绘制日期曲线图 var ar = AppTracer.FindByID(appId); if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("调用次数"); chart.AddLine(list, _.Total, null, true); chart.Add(list, _.Errors); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("耗时"); chart.AddLine(list, _.Cost, null, true); chart.Add(list, _.MaxCost); chart.Add(list, _.MinCost); chart.SetTooltip(); ViewBag.Charts2 = new[] { chart }; } } return(list); }
protected override IEnumerable <RedisData> Search(Pager p) { PageSetting.EnableAdd = false; var redisId = p["redisId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); if (redisId > 0) { // 最近10小时 if (p.PageSize == 20 && redisId > 0) { p.PageSize = 24 * 60; } PageSetting.EnableNavbar = false; } if (p.Sort.IsNullOrEmpty()) { p.OrderBy = _.Id.Desc(); } var list = RedisData.Search(redisId, start, end, p["Q"], p); if (list.Count > 0) { // 绘制日期曲线图 var node = RedisNode.FindById(redisId); if (redisId >= 0 && node != null) { var list2 = list.OrderBy(e => e.Id).ToList(); var chart = new ECharts { Title = new ChartTitle { Text = node.Name }, Height = 400, }; chart.SetX(list2, _.CreateTime, e => e.CreateTime.ToString("HH:mm")); chart.SetY("指标"); chart.AddLine(list2, _.Speed, null, true); chart.Add(list2, _.InputKbps); chart.Add(list2, _.OutputKbps); chart.Add(list2, _.ConnectedClients); chart.Add(list2, _.UsedMemory); chart.Add(list2, _.Keys); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } } return(list); }
protected override IEnumerable <TraceDayStat> Search(Pager p) { var appId = p["appId"].ToInt(-1); var name = p["name"]; var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 默认排序 if (appId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { start = DateTime.Today.AddDays(-30); p["dtStart"] = start.ToString("yyyy-MM-dd"); p.Sort = TraceDayStat.__.StatDate; p.Desc = false; p.PageSize = 100; } var list = TraceDayStat.Search(appId, name, start, end, p["Q"], p); if (list.Count > 0) { var hasDate = start.Year > 2000 || end.Year > 2000; // 绘制日期曲线图 var ar = AppTracer.FindByID(appId); if (appId >= 0) { var chart = new ECharts { Title = new ChartTitle { Text = ar + "" }, Height = 400, }; chart.SetX(list, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("数量"); chart.AddLine(list, _.Total, null, true); chart.Add(list, _.Total); chart.Add(list, _.Errors); chart.Add(list, _.Cost); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } } return(list); }
protected override IEnumerable <TraceDayStat> Search(Pager p) { var appId = p["appId"].ToInt(-1); var name = p["name"]; var type = p["type"]; var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); var date = p["date"].ToDateTime(); if (start.Year < 2000 && end.Year < 2000) { start = end = date; } // 选了应用,没有选时间,按照统计日期升序 if (appId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { p.Sort = __.StatDate; p.Desc = true; p.PageSize = 90; } // 选了应用和时间,按照接口调用次数降序 else if (appId >= 0 && start.Year > 2000 && p.Sort.IsNullOrEmpty()) { p.Sort = __.Total; p.Desc = true; p.PageSize = 100; } p.RetrieveState = true; var list = TraceDayStat.Search(appId, name, type, start, end, p["Q"], p); if (list.Count > 0 && appId >= 0 && !name.IsNullOrEmpty()) { var list2 = list.OrderBy(e => e.StatDate).ToList(); // 绘制日期曲线图 if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("调用次数"); chart.AddLine(list2, _.Total, null, true); chart.Add(list2, _.Errors); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("耗时"); chart.AddLine(list2, _.Cost, null, true); chart.Add(list2, _.MaxCost); chart.Add(list2, _.MinCost); chart.SetTooltip(); ViewBag.Charts2 = new[] { chart }; } } var ar = AppTracer.FindByID(appId); if (ar != null) { ViewBag.Title = $"{ar}每日统计"; } return(list); }
protected override IEnumerable <AppMinuteStat> Search(Pager p) { var appId = p["appId"].ToInt(-1); var minError = p["minError"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 选了应用,没有选时间,按照统计日期升序 if (appId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { p.Sort = __.StatTime; p.Desc = true; p.PageSize = 2 * 60 / 5; } // 选了应用和时间,按照接口调用次数降序 else if (appId >= 0 && start.Year > 2000 && p.Sort.IsNullOrEmpty()) { p.Sort = __.Total; p.Desc = true; p.PageSize = 24 * 60 / 5; } // 监控视图,没有选应用 else if (appId < 0 && p["t"] == "dash") { // 最近一段时间,5~10分钟 if (start.Year < 2000) { var time = DateTime.Now; var minute = time.Date.AddHours(time.Hour).AddMinutes(time.Minute / 5 * 5); start = minute.AddMinutes(-5); } p.OrderBy = $"{__.Errors} desc, {__.Total} desc"; p.PageSize = 20; PageSetting.EnableNavbar = false; PageSetting.EnableAdd = false; PageSetting.EnableKey = false; PageSetting.EnableSelect = false; } p.RetrieveState = true; var list = AppMinuteStat.Search(appId, minError, start, end, p["Q"], p); if (list.Count > 0 && appId >= 0) { var list2 = list.OrderBy(e => e.StatTime).ToList(); // 绘制日期曲线图 if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatTime, e => e.StatTime.ToString("HH:mm")); chart.SetY("调用次数"); chart.AddLine(list2, _.Total, null, true); chart.Add(list2, _.Errors); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatTime, e => e.StatTime.ToString("HH:mm")); chart.SetY("耗时"); chart.AddLine(list2, _.Cost, null, true); chart.Add(list2, _.MaxCost); chart.Add(list2, _.MinCost); chart.SetTooltip(); ViewBag.Charts2 = new[] { chart }; } } else if (list.Count > 0 && appId < 0 && p["t"] == "dash") { var list2 = new List <AppMinuteStat>(); foreach (var item in list) { var st = list2.FirstOrDefault(e => e.AppId == item.AppId); if (st == null) { list2.Add(st = new AppMinuteStat { AppId = item.AppId }); } st.Total += item.Total; st.Errors += item.Errors; } list2 = list2.OrderBy(e => e.Errors).ThenBy(e => e.Total).ToList(); // 绘制柱状图 var chart = new ECharts { Height = 800, }; chart.SetTooltip("axis", "shadow"); chart.Legend = new { data = new[] { "总数", "错误数" } }; chart["grid"] = new { left = "3%", right = "4%", bottom = "3%", containLabel = true }; chart.XAxis = new[] { new { type = "value" } }; chart.YAxis = new[] { new { type = "category", axisTick = new { show = false }, data = list2.Select(e => e.AppName).ToArray() } }; //chart.Add(list2, _.Total, "bar"); //chart.Add(list2, _.Errors, "bar"); chart.Add(new Series { Name = "错误数", Type = "bar", ["stack"] = "总量", ["label"] = new { show = true, position = "left" }, Data = list2.Select(e => - e.Errors).ToArray(), }); chart.Add(new Series { Name = "总数", Type = "bar", ["stack"] = "总量", ["label"] = new { show = true }, Data = list2.Select(e => e.Total).ToArray(), }); ViewBag.Charts = new[] { chart }; } var ar = AppTracer.FindByID(appId); if (ar != null) { ViewBag.Title = $"{ar}分钟统计"; } return(list); }
protected override IEnumerable <AppMeter> Search(Pager p) { PageSetting.EnableAdd = false; var appId = p["appId"].ToInt(-1); var clientId = p["clientId"]; var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); if (appId > 0) { // 最近24小时 if (p.PageSize == 20 && appId > 0) { p.PageSize = 1440; } // 自动客户端 if (clientId.IsNullOrEmpty()) { var clients = AppMeter.GetClientIds(appId); if (clients != null && clients.Count > 0) { clientId = clients.FirstOrDefault(e => e.Key != "null").Key; } } PageSetting.EnableNavbar = false; } if (p.Sort.IsNullOrEmpty()) { p.OrderBy = _.Id.Desc(); } var list = AppMeter.Search(appId, clientId, start, end, p["Q"], p); if (list.Count > 0 && !clientId.IsNullOrEmpty()) { // 绘制日期曲线图 var app = App.FindById(appId); if (appId >= 0 && app != null) { var list2 = list.OrderBy(e => e.Id).ToList(); var chart = new ECharts { Title = new ChartTitle { Text = app.Name + "#" + clientId }, Height = 400, }; chart.SetX(list2, _.CreateTime, e => e.CreateTime.ToString("HH:mm")); chart.SetY("指标"); chart.AddLine(list2, _.Memory, null, true); chart.Add(list2, _.Threads); chart.Add(list2, _.Handles); chart.Add(list2, _.Connections); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } } return(list); }
protected override IEnumerable <NodeStat> Search(Pager p) { var areaId = p["areaId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 默认排序 if (areaId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { start = DateTime.Today.AddDays(-30); p["dtStart"] = start.ToString("yyyy-MM-dd"); p.Sort = NodeStat.__.StatDate; p.Desc = false; p.PageSize = 100; //// 默认全国 //if (areaId < 0) areaId = 0; } var list = NodeStat.Search(areaId, start, end, p["Q"], p); if (list.Count > 0) { var hasDate = start.Year > 2000 || end.Year > 2000; // 绘制日期曲线图 var ar = Area.FindByID(areaId); if (areaId >= 0) { var chart = new ECharts { Title = new ChartTitle { Text = ar + "" }, Height = 400, }; chart.SetX(list, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("数量"); chart.AddLine(list, _.Total, null, true); chart.Add(list, _.Actives); chart.Add(list, _.T7Actives); chart.Add(list, _.T30Actives); chart.Add(list, _.News); chart.Add(list, _.T7News); chart.Add(list, _.T30News); chart.Add(list, _.Registers); chart.Add(list, _.MaxOnline); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } // 指定日期后,绘制饼图 if (hasDate && areaId < 0) { var w = 400; var h = 300; var chart0 = new ECharts { Width = w, Height = h }; chart0.Add(list, _.Total, "pie", e => new { name = e.ProvinceName, value = e.Total }); var chart1 = new ECharts { Width = w, Height = h }; chart1.Add(list, _.Actives, "pie", e => new { name = e.ProvinceName, value = e.Actives }); var chart2 = new ECharts { Width = w, Height = h }; chart2.Add(list, _.News, "pie", e => new { name = e.ProvinceName, value = e.News }); var chart3 = new ECharts { Width = w, Height = h }; chart3.Add(list, _.Registers, "pie", e => new { name = e.ProvinceName, value = e.Registers }); var chart4 = new ECharts { Width = w, Height = h }; chart4.Add(list, _.MaxOnline, "pie", e => new { name = e.ProvinceName, value = e.MaxOnline }); ViewBag.Charts2 = new[] { chart0, chart1, chart2, chart3, chart4 }; } } return(list); }
protected override IEnumerable <AppDayStat> Search(Pager p) { var appId = p["appId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 默认排序 if (appId >= 0 && start.Year < 2000 && p.Sort.IsNullOrEmpty()) { p.Sort = __.StatDate; p.Desc = true; p.PageSize = 100; } p.RetrieveState = true; var list = AppDayStat.Search(appId, start, end, p["Q"], p); if (list.Count > 0 && appId > 0) { var list2 = list.OrderBy(e => e.StatDate).ToList(); // 绘制日期曲线图 if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("调用次数"); chart.AddLine(list2, _.Total, null, true); chart.Add(list2, _.Errors); chart.Add(list2, _.Apis); chart.Add(list2, _.Https); chart.Add(list2, _.Dbs); chart.Add(list2, _.Mqs); chart.Add(list2, _.Redis); chart.Add(list2, _.Others); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } if (appId >= 0) { var chart = new ECharts { Height = 400, }; chart.SetX(list2, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("耗时"); chart.AddLine(list2, _.Cost, null, true); chart.Add(list2, _.MaxCost); chart.Add(list2, _.MinCost); chart.SetTooltip(); ViewBag.Charts2 = new[] { chart }; } } var ar = AppTracer.FindByID(appId); if (ar != null) { ViewBag.Title = $"{ar}每日统计"; } return(list); }
protected override IEnumerable <DeviceStat> Search(Pager p) { var productId = p["productId"].ToInt(-1); var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); // 如果选择产品,但没有排序,默认升序 if (productId >= 0 && p.Sort.IsNullOrEmpty()) { p.Sort = __.ID; p.Desc = false; if (p.PageSize == 20 || p.PageSize == 0) { p.PageSize = 1000; } if (start.Year < 2000 && end.Year < 2000) { start = DateTime.Today.AddDays(-30); p["dtStart"] = start.ToString("yyyy-MM-dd"); } } var list = DeviceStat.Search(productId, start, end, p["Q"], p); if (list.Count > 0) { var hasDate = start.Year > 2000 || end.Year > 2000; // 指定产品后,绘制日期曲线图 var prd = Product.FindByID(productId); if (productId >= 0) { if (productId == 99) { var dic = list.GroupBy(e => e.StatDate).ToDictionary(e => e.Key, e => e.ToList()); var list2 = new List <DeviceStat>(); foreach (var item in dic) { var st = new DeviceStat { StatDate = item.Key }; st.Merge(item.Value); list2.Add(st); } list = list2; } var chart = new ECharts { Title = new ChartTitle { Text = prd + "设备统计" }, Height = 400, }; chart.SetX(list, _.StatDate, e => e.StatDate.ToString("MM-dd")); chart.SetY("台数"); var sr = chart.Add(list, _.Total, "line", null); sr.Smooth = true; chart.Add(list, _.Actives); chart.Add(list, _.News); chart.Add(list, _.T7Actives); chart.Add(list, _.T7News); chart.Add(list, _.T30Actives); chart.Add(list, _.T30News); chart.Add(list, _.Registers); chart.Add(list, _.MaxOnline); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } // 指定日期后,绘制饼图 if (hasDate && productId < 0) { var w = 400; var h = 300; // 去掉所有产品 list = list.Where(e => e.ProductId > 0).ToList(); var chart0 = new ECharts { Width = w, Height = h }; chart0.Add(list, _.Total, "pie", e => new { name = e.ProductName, value = e.Total }); var chart1 = new ECharts { Width = w, Height = h }; chart1.Add(list, _.Actives, "pie", e => new { name = e.ProductName, value = e.Actives }); var chart2 = new ECharts { Width = w, Height = h }; chart2.Add(list, _.News, "pie", e => new { name = e.ProductName, value = e.News }); var chart3 = new ECharts { Width = w, Height = h }; chart3.Add(list, _.Registers, "pie", e => new { name = e.ProductName, value = e.Registers }); var chart4 = new ECharts { Width = w, Height = h }; chart4.Add(list, _.MaxOnline, "pie", e => new { name = e.ProductName, value = e.MaxOnline }); ViewBag.Charts2 = new[] { chart0, chart1, chart2, chart3, chart4 }; } } return(list); }
protected override IEnumerable <TraceData> Search(Pager p) { var appId = p["appId"].ToInt(-1); var name = p["name"]; var start = p["dtStart"].ToDateTime(); var end = p["dtEnd"].ToDateTime(); var kind = p["kind"]; var date = p["date"].ToDateTime(); if (start.Year < 2000 && end.Year < 2000) { start = end = date; } var time = p["time"].ToDateTime(); if (start.Year < 2000 && end.Year < 2000) { start = end = time; } if (appId > 0 && p.PageSize == 20) { p.PageSize = 100; } if (p.Sort.IsNullOrEmpty()) { p.OrderBy = _.Id.Desc(); } var list = TraceData.Search(appId, name, kind, start, end, p["Q"], p); if (list.Count > 0 && appId > 0 && !name.IsNullOrEmpty()) { var list2 = list.OrderBy(e => e.Id).ToList(); // 绘制日期曲线图 var app = AppTracer.FindByID(appId); if (appId >= 0) { var chart = new ECharts { Title = new ChartTitle { Text = "调用次数" }, Height = 400, }; chart.SetX(list2, _.StartTime, e => e.StartTime.ToDateTime().ToLocalTime().ToString("HH:mm:ss")); chart.SetY("次数"); chart.AddLine(list2, _.Total, null, true); chart.Add(list2, _.Errors); chart.SetTooltip(); ViewBag.Charts = new[] { chart }; } if (appId >= 0) { var chart = new ECharts { Title = new ChartTitle { Text = "耗时" }, Height = 400, }; chart.SetX(list2, _.StartTime, e => e.StartTime.ToDateTime().ToLocalTime().ToString("HH:mm:ss")); chart.SetY("耗时"); chart.AddLine(list2, _.Cost, null, true); chart.Add(list2, _.MaxCost); chart.Add(list2, _.MinCost); chart.SetTooltip(); ViewBag.Charts2 = new[] { chart }; } } var ar = AppTracer.FindByID(appId); if (ar != null) { ViewBag.Title = $"{ar}跟踪"; } return(list); }