protected override void Run() { SqlHelper.ExcuteSql(DbShardingHelper.GetDataBase(GlobalConfig.DataBaseConfigModels, DataBaseType.PlatformManage), (c) => { tb_cluster_dal dal = new tb_cluster_dal(); dal.UpdateOnLineTime(c, GlobalConfig.ServerIP); }); }
protected override void Run() { if (GlobalConfig.ClusterModel.ifmonitor == false) { return; } tb_performance_collect_model model = new tb_performance_collect_model(); foreach (var p in pcounts) { var c = p.Collect(); //Console.WriteLine(p.Name + ":" + c); if (p.Name.Contains("cpu")) { model.cpu = (decimal)c; } else if (p.Name.Contains("内存")) { model.memory = (decimal)c; } else if (p.Name.Contains("网络发送")) { model.networkupload = (decimal)c; } else if (p.Name.Contains("网络下载")) { model.networkdownload = (decimal)c; } else if (p.Name.Contains("物理磁盘读")) { model.ioread = (decimal)c; } else if (p.Name.Contains("物理磁盘写")) { model.iowrite = (decimal)c; } else if (p.Name.Contains("IIS请求")) { model.iisrequest = (decimal)c; } } model.serverid = GlobalConfig.ClusterModel.id; model.createtime = DateTime.Now; SqlHelper.ExcuteSql(DbShardingHelper.GetDataBase(GlobalConfig.DataBaseConfigModels, DataBaseType.Cluster), (c) => { model.createtime = c.GetServerDate(); tb_performance_collect_dal performancecollectdal = new tb_performance_collect_dal(); performancecollectdal.AddCollect(c, model); }); }
protected override void Run() { if (GlobalConfig.ClusterModel.ifmonitor == false) { return; } List <ClusterMonitorInfo> cmis = new List <ClusterMonitorInfo>(); foreach (var p in pcounts) { var c = p.Collect(); cmis.Add(new ClusterMonitorInfo(p.Name, c.ToString("F2"), (double)c)); } if (dct.IsCollect == true) { string msg = ""; double minfreespace = 1000000; foreach (var d in dct.Collect()) { minfreespace = Math.Min(minfreespace, d.FreeSpace); msg += string.Format("[{0}]:{1}(G)/{2}(G)\r\n", d.Name, d.FreeSpace.ToString("F2"), d.TotalSpace.ToString("F2")); } cmis.Add(new ClusterMonitorInfo(dct.Name, msg, minfreespace)); } if (mct.IsCollect == true) { var mper = mct.Collect(); cmis.Add(new ClusterMonitorInfo(mct.Name, string.Format("剩余/总量:{0}(M)/{1}(M) 已用:{2}%", ConvertHelper.ByteToM(mper.AvailablePhysicalMemory).ToString("F2"), ConvertHelper.ByteToM(mper.TotalPhysicalMemory).ToString("F2"), mper.UserdPercent), mper.UserdPercent)); } SqlHelper.ExcuteSql(DbShardingHelper.GetDataBase(GlobalConfig.DataBaseConfigModels.Select(c1 => (dynamic)c1).ToList(), DataBaseType.Cluster), (c) => { tb_cluster_monitorinfo_dal dal = new tb_cluster_monitorinfo_dal(); dal.AddOrUpdate(c, new tb_cluster_monitorinfo_model() { lastupdatetime = c.GetServerDate(), serverid = GlobalConfig.ClusterModel.id, monitorinfojson = new JsonHelper().Serializer(cmis) }); }); }