private void RedisListenerCommand(string channel, string msg) { if (Contexts.Count == 0) { return; } try { DebugHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者心跳接收到redis消息开始处理"); foreach (var context in Contexts.CopyToList()) { var command = new XXF.Serialization.JsonHelper().Deserialize <BusinessMQNetCommand>(msg); if ((command.CommandReceiver == EnumCommandReceiver.All || command.CommandReceiver == EnumCommandReceiver.Producter) && command.MqPath.ToLower() == context.ProducterProvider.MQPath.ToLower()) { if (command.CommandType == EnumCommandType.Register) { context.IsNeedReload = true; CheckMqPathUpdate(context); } } } DebugHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者心跳接收到redis消息处理完毕"); } catch (Exception exp) { ErrorLogHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者Redis命令监听出错", exp); } }
// // GET: /Cluster/MonitorInfo/ public ActionResult Index(string keyword, string serverid, string monitorjsonkeyword, string ifrefreash, int pageindex = 1, int pagesize = 10) { ViewBag.keyword = keyword; ViewBag.monitorjsonkeyword = monitorjsonkeyword; ViewBag.ifrefreash = ifrefreash; PagedList <tb_cluster_monitorinfo_model> pageList = null; int count = 0; List <tb_cluster_monitorinfo_model> List = new List <tb_cluster_monitorinfo_model>(); using (DbConn PubConn = DbConfig.CreateConn(Config.ClusterConnectString)) { PubConn.Open(); ViewBag.SqlTimeNow = PubConn.GetServerDate(); tb_cluster_monitorinfo_dal dal = new tb_cluster_monitorinfo_dal(); List = dal.GetList(PubConn, keyword, serverid, monitorjsonkeyword, pagesize, pageindex, out count); } pageList = new PagedList <tb_cluster_monitorinfo_model>(List, pageindex, pagesize, count); Dictionary <int, List <Dyd.BaseService.Monitor.Core.CollectConfig> > ServerConfigDic = new Dictionary <int, List <Dyd.BaseService.Monitor.Core.CollectConfig> >(); SqlHelper.ExcuteSql(Config.PlatformManageConnectString, (c) => { tb_cluster_dal dal = new tb_cluster_dal(); var list = dal.GetListInIds(c, List.Select(o => o.serverid).ToList()); foreach (var o in list) { var config = new XXF.Serialization.JsonHelper().Deserialize <List <Dyd.BaseService.Monitor.Core.CollectConfig> >(o.monitorcollectconfigjson); ServerConfigDic.Add(o.id, config); } }); ViewBag.ServerConfigDic = ServerConfigDic; if (Request.IsAjaxRequest()) { return(PartialView("List", pageList)); } return(View(pageList)); }
private string GetWarnningInfo(CollectConfig config, tb_cluster_monitorinfo_model model, tb_cluster_model cluster) { string msg = ""; var monitorinfos = new XXF.Serialization.JsonHelper().Deserialize <List <ClusterMonitorInfo> >(model.monitorinfojson); foreach (var info in monitorinfos) { if (info.Name == config.CollectName) { if (config.EqualWarningValue != null && config.EqualWarningValue.IsWarning == true && config.EqualWarningValue.Value == info.MonitorValue) { msg += string.Format("【id:{2},{4}】检测项【{0}】等于预警值{3},当前值为{1}\r\n", config.CollectName, info.MonitorValue, model.serverid, config.EqualWarningValue.Value, cluster.servername); } if (config.LessThanWarningValue != null && config.LessThanWarningValue.IsWarning == true && config.LessThanWarningValue.Value > info.MonitorValue) { msg += string.Format("【id:{2},{4}】检测项【{0}】小于预警值{3},当前值为{1}\r\n", config.CollectName, info.MonitorValue, model.serverid, config.LessThanWarningValue.Value, cluster.servername); } if (config.MoreThanWarningValue != null && config.MoreThanWarningValue.IsWarning == true && config.MoreThanWarningValue.Value < info.MonitorValue) { msg += string.Format("【id:{2},{4}】检测项【{0}】大于预警值{3},当前值为{1}\r\n", config.CollectName, info.MonitorValue, model.serverid, config.MoreThanWarningValue.Value, cluster.servername); } } } return(msg); }
public override void Start() { #region test //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("cpu", "Processor", "% Processor Time", "_Total"))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("内存", "Memory", "Available MBytes", ""))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("网络发送/s", "Network Interface", "Bytes Sent/sec", "本地连接* 14"))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("网络下载/s", "Network Interface", "Bytes Received/sec", "本地连接* 14"))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("物理磁盘读字节/s", "PhysicalDisk", "Disk Read Bytes/sec", "_Total"))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("物理磁盘写字节/s", "PhysicalDisk", "Disk Write Bytes/sec", "_Total"))); //pcounts.Add(new PerformanceCounterCollectTask(new CollectConfig("IIS请求/s", "Web Service", "Current Connections", "_Total"))); #endregion try { this.TimeSleep = GlobalConfig.PerformanceCollectBackgroundTaskSleepTime * 1000; if (!string.IsNullOrWhiteSpace(GlobalConfig.ClusterModel.performancecollectconfigjson)) { var collectconfigs = new XXF.Serialization.JsonHelper().Deserialize <List <Core.CollectConfig> >(GlobalConfig.ClusterModel.performancecollectconfigjson); foreach (var config in collectconfigs) { pcounts.Add(new PerformanceCounterCollectTask(config)); } } base.Start(); } catch (Exception exp) { LogHelper.Error("PerformanceCollectBackgroundTask 初始化错误", exp); } }
public override void TestRun() { this.AppConfig = new XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo(); this.AppConfig.Add("MonitorPlatformManageConnectString", "server=192.168.17.201;Initial Catalog=dyd_bs_monitor_platform_manage;User ID=sa;Password=Xx~!@#;"); this.AppConfig.Add("EveryGrowErrorNum", "20"); string json = new XXF.Serialization.JsonHelper().Serializer(this.AppConfig); base.TestRun(); }
private void button1_Click(object sender, EventArgs e) { //var o = new CryptoHelper().Encrypt("cofnig"); //var m = new CryptoHelper().Decrypt(o); //var a = 1; //CompressHelper.UnCompress(@"E:\111.zip",@"E:\111"); //SqlHelper.ExcuteSql("server=192.168.17.201;Initial Catalog=dyd_bs_task;User ID=sa;Password=Xx~!@#;", (c) => //{ // Domain.Dal.tb_version_dal versiondal = new Domain.Dal.tb_version_dal(); // versiondal.Edit(c, new tb_version_model() // { // id = 6, // taskid = 8, // version = 1, // versioncreatetime = DateTime.Now, // zipfile = System.IO.File.ReadAllBytes(@"E:\8.rar"), // zipfilename = "8.rar" // }); //}); XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo tai = new XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo(); tai.Add("ConfigConnectString", @"server=10.4.11.12;Initial Catalog=ky_monitor;User ID=dev;Password=dev201404"); string o = new XXF.Serialization.JsonHelper().Serializer(tai); NodeTaskRuntimeInfo taskruntimeinfo = new NodeTaskRuntimeInfo(); var dlltask = new AppDomainLoader <BaseDllTask>().Load(AppDomain.CurrentDomain.BaseDirectory + @"a\debug\EPlatformServer.exe", "EPlatformServer.Task.CenterProviderManagerTask", out taskruntimeinfo.Domain); dlltask.TryRun(); MessageBox.Show("ok"); //int a = 1; //EmailHelper email = new EmailHelper(); //email.mailFrom = "*****@*****.**"; //email.mailPwd = "472790378@"; //email.mailSubject = "11"; //email.mailBody = "111"; //email.isbodyHtml = true; //是否是HTML //email.host = "smtp.163.com";//如果是QQ邮箱则:smtp:qq.com,依次类推 //email.mailToArray = new string[] { "*****@*****.**" };//接收者邮件集合 //email.mailCcArray = new string[] { };//抄送者邮件集合 //if (email.Send()) //{ //} //else //{ //} }
public override void TestRun() { this.AppConfig = new XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo(); this.AppConfig.Add("MonitorPlatformManageConnectString", "server=192.168.17.201;Initial Catalog=dyd_bs_monitor_platform_manage;User ID=sa;Password=Xx~!@#;"); this.AppConfig.Add("sendmailhost", "smtp.163.com"); this.AppConfig.Add("sendmailname", "*****@*****.**"); this.AppConfig.Add("password", "472790378@"); this.AppConfig.Add("moreEmailSubject", "测试环境"); string json = new XXF.Serialization.JsonHelper().Serializer(this.AppConfig); base.TestRun(); }
private void button1_Click(object sender, EventArgs e) { //var o = new CryptoHelper().Encrypt("cofnig"); //var m = new CryptoHelper().Decrypt(o); //var a = 1; //CompressHelper.UnCompress(@"E:\111.zip",@"E:\111"); //SqlHelper.ExcuteSql("server=192.168.17.201;Initial Catalog=dyd_bs_task;User ID=sa;Password=Xx~!@#;", (c) => //{ // Domain.Dal.tb_version_dal versiondal = new Domain.Dal.tb_version_dal(); // versiondal.Edit(c, new tb_version_model() // { // id = 6, // taskid = 8, // version = 1, // versioncreatetime = DateTime.Now, // zipfile = System.IO.File.ReadAllBytes(@"E:\8.rar"), // zipfilename = "8.rar" // }); //}); XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo tai = new XXF.BaseService.TaskManager.SystemRuntime.TaskAppConfigInfo(); tai.Add("ConfigConnectString", @"server=192.168.17.205;Initial Catalog=dyd_new_config;User ID=sa;Password=Xx~!@#; "); string o = new XXF.Serialization.JsonHelper().Serializer(tai); //int a = 1; //EmailHelper email = new EmailHelper(); //email.mailFrom = "*****@*****.**"; //email.mailPwd = "472790378@"; //email.mailSubject = "11"; //email.mailBody = "111"; //email.isbodyHtml = true; //是否是HTML //email.host = "smtp.163.com";//如果是QQ邮箱则:smtp:qq.com,依次类推 //email.mailToArray = new string[] { "*****@*****.**" };//接收者邮件集合 //email.mailCcArray = new string[] { };//抄送者邮件集合 //if (email.Send()) //{ //} //else //{ //} }
// // GET: /Cluster/MonitorinfoSnapshot/ public ActionResult Index(string keyword, string serverid, string timebegin, string timeend, string monitorjsonkeyword, int pageindex = 1, int pagesize = 10) { if (string.IsNullOrWhiteSpace(timebegin)) { timebegin = DateTime.Now.AddHours(-24).ToString("yyyy-MM-dd HH:mm:ss"); } if (string.IsNullOrWhiteSpace(timeend)) { timeend = DateTime.Now.AddHours(1).ToString("yyyy-MM-dd HH:mm:ss"); } ViewBag.keyword = keyword; ViewBag.serverid = serverid; ViewBag.timebegin = timebegin; ViewBag.timeend = timeend; ViewBag.monitorjsonkeyword = monitorjsonkeyword; PagedList <tb_cluster_monitorinfo_snapshot_model> pageList = null; int count = 0; List <tb_cluster_monitorinfo_snapshot_model> List = new List <tb_cluster_monitorinfo_snapshot_model>(); using (DbConn PubConn = DbConfig.CreateConn(Config.ClusterConnectString)) { PubConn.Open(); ViewBag.SqlTimeNow = PubConn.GetServerDate(); tb_cluster_monitorinfo_snapshot_dal dal = new tb_cluster_monitorinfo_snapshot_dal(); List = dal.GetList(PubConn, keyword, serverid, timebegin, timeend, monitorjsonkeyword, pagesize, pageindex, out count); } pageList = new PagedList <tb_cluster_monitorinfo_snapshot_model>(List, pageindex, pagesize, count); Dictionary <int, List <Dyd.BaseService.Monitor.Core.CollectConfig> > ServerConfigDic = new Dictionary <int, List <Dyd.BaseService.Monitor.Core.CollectConfig> >(); SqlHelper.ExcuteSql(Config.PlatformManageConnectString, (c) => { tb_cluster_dal dal = new tb_cluster_dal(); var list = dal.GetListInIds(c, List.Select(o => o.serverid).ToList()); foreach (var o in list) { var config = new XXF.Serialization.JsonHelper().Deserialize <List <Dyd.BaseService.Monitor.Core.CollectConfig> >(o.monitorcollectconfigjson); ServerConfigDic.Add(o.id, config); } }); ViewBag.ServerConfigDic = ServerConfigDic; if (Request.IsAjaxRequest()) { return(PartialView("List", pageList)); } return(View(pageList)); }
/// <summary> /// 检查监控信息的预警 /// </summary> private void CheckMonitorInfoWarning() { try { string waringmsg = ""; List <tb_cluster_model> clusters = new List <tb_cluster_model>(); SqlHelper.ExcuteSql(GlobalConfig.MonitorPlatformManageConnectString, (c) => { tb_cluster_dal dal = new tb_cluster_dal(); clusters = dal.GetAllList(c); }); clusters.ForEach(o => { if (o.ifmonitor == true) { tb_cluster_monitorinfo_model monitorinfo = null; SqlHelper.ExcuteSql(MonitorClusterConnectString, (c) => { tb_cluster_monitorinfo_dal dal = new tb_cluster_monitorinfo_dal(); monitorinfo = dal.GetByServerId(c, o.id); }); if (monitorinfo != null) { var collectconfigs = new XXF.Serialization.JsonHelper().Deserialize <List <CollectConfig> >(o.monitorcollectconfigjson); foreach (var config in collectconfigs) { waringmsg += GetWarnningInfo(config, monitorinfo, o); } } } }); if (waringmsg != "") { TaskLogHelper.Error("检查监控信息的预警", "服务器性能检查(预警值检查)" + "\r\n" + waringmsg, "集群性能预警任务"); } } catch (Exception exp) { this.OpenOperator.Error("【集群性能预警任务】检查监控信息的预警", exp); } }
private void RedisListenerCommand(string channel, string msg) { try { if (!cancelSource.IsCancellationRequested) { DebugHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ConsumerHeartbeatProtect-RedisListenerCommand", "检测到redis消息,msg:" + msg.NullToEmpty()); var command = new XXF.Serialization.JsonHelper().Deserialize <BusinessMQNetCommand>(msg); if ((command.CommandReceiver == EnumCommandReceiver.All || command.CommandReceiver == EnumCommandReceiver.Consumer) && command.MqPath.ToLower() == Context.ConsumerProvider.MQPath.ToLower()) { if (command.CommandType == EnumCommandType.Register) { DebugHelper.WriteLine(Context.GetMQPathID(), Context.GetMQPath(), "ConsumerHeartbeatProtect-RedisListenerCommand", "检测到redis消息:" + EnumCommandType.Register.Tostring()); Context.IsNeedReload = true; HeartBeatTask(); } } } } catch (Exception exp) { ErrorLogHelper.WriteLine(Context.ConsumerInfo.MQPathModel.id, Context.ConsumerInfo.MQPathModel.mqpath, "RedisListenerCommand", "消费者Redis注册监听", exp); } }
private void RedisListenerCommand(string channel, string msg) { if (Contexts.Count == 0) return; try { DebugHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者心跳接收到redis消息开始处理"); foreach (var context in Contexts.CopyToList()) { var command = new XXF.Serialization.JsonHelper().Deserialize<BusinessMQNetCommand>(msg); if ((command.CommandReceiver == EnumCommandReceiver.All || command.CommandReceiver == EnumCommandReceiver.Producter) && command.MqPath.ToLower() == context.ProducterProvider.MQPath.ToLower()) { if (command.CommandType == EnumCommandType.Register) { context.IsNeedReload = true; CheckMqPathUpdate(context); } } } DebugHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者心跳接收到redis消息处理完毕"); } catch (Exception exp) { ErrorLogHelper.WriteLine(-1, "", "RedisListenerCommand", "生产者Redis命令监听出错", exp); } }