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) }); }); }