示例#1
0
        string GetMonitorChartDataFromAPI(string range, string userid)
        {
            LogMonitorVM servers = GetMonitorChartDataVMFromAPI(range, userid);
            var          str     = JsonConvert.SerializeObject(servers);

            return(str);
        }
示例#2
0
        //获取各个服务器指定范围内的数据,用于曲线显示
        public ActionResult GetMonitorChartData(string range, long userId)
        {
            LogMonitorVM vm = _logMonitorService.GetMonitorChartData(range, userId);

            return(AbpJson(vm, null, null, JsonRequestBehavior.AllowGet, true, false));
        }
示例#3
0
        /// <summary>
        /// 获取各个服务器指定范围内的数据,用于曲线显示
        /// </summary>
        /// <param name="range"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public LogMonitorVM GetMonitorChartData(string range, long userId)
        {
            int    limit = 1;
            string startT = "", endT = "";
            string other       = "";
            var    ttt         = AbpSession.UserId;
            string timeFormate = "";

            if (!string.IsNullOrEmpty(range))
            {
                //range格式 :模式[_数值1][_数值2]_点数_时间格式,最后两个为点数和时间格式。例如  3_100_100_M:d H:m:s
                //模式0:自定义时段,两个数值为时间点
                //模式1:当天
                //模式2:最近xx小时
                //模式3:最新xx点
                var temp = range.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries);
                timeFormate = temp[temp.Length - 1];//时间格式
                other       = timeFormate;
                if (temp.Length != 1)
                {
                    limit = (int)(Convert.ToDouble(temp[temp.Length - 2]));
                    var mode = temp[0];

                    if (mode == "0")
                    {
                        startT = temp[1];
                        endT   = temp[2];
                    }
                    else if (mode == "1")
                    {
                        startT = DateTime.Now.ToString("yyyy-MM-dd");
                        endT   = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
                    }
                    else if (mode == "2")
                    {
                        startT = DateTime.Now.AddHours(-1 * Convert.ToDouble(temp[1])).ToString("yyyy-M-d H:m:s");
                        endT   = DateTime.Now.ToString();
                    }
                    else if (mode == "3")
                    {
                        other += ";" + temp[1];
                    }
                }
                else  //只获取最新的一条数据
                {
                }
            }
            var enumList = GetUserSysCategoryAccordingRoleID(userId);
            GetLogMonitorInput monitorIn = new GetLogMonitorInput()
            {
                MaxResultCount = limit,
                SkipCount      = 0,//searchePara.offset,
                Sorting        = "LogTime",
                IsDesc         = true,
                StartT         = string.IsNullOrEmpty(startT) ? new DateTime() : Convert.ToDateTime(startT),
                EndT           = string.IsNullOrEmpty(endT) ? new DateTime() : Convert.ToDateTime(endT),
                Express        = null,
                ServerHost     = "", //应为空,V-WEBAPI为测试
                ServerIP       = "",
                SystemID       = enumList,
                Other          = other
            };
            List <ServersViewDto> sers = GetLogMonitorsEveryServer(monitorIn);
            //if (limit == 1) //测试增加一点的情况,改写数据便于看的清除
            //{
            //    sers = sers.Select(a => { a.Monitors = a.Monitors.Select(m => { m.Time = DateTime.Now.ToString(timeFormate); m.CpuUsage += 5; m.MemoryUsage += 6; m.CurProcThreadNum += 7; m.OnlineCnt += 8; return m; }).ToList(); return a; }).ToList();//测试
            //}
            LogMonitorVM vm = new LogMonitorVM()
            {
                ServerData = sers,
                WebSites   = enumList.Select(a => Configuration.SysNameMap.GetMySystemName(a)).ToList(),
                Servers    = GetAllServerList(),
                LogNum     = GetTodayMonitorLogNum(enumList),
                LogTime    = DateTime.Now.ToString("yyyy-M-d H:m:s")
            };

            return(vm);
        }