/// <summary>
        /// 重载基类算法,查看队列服务是否正常
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var mqAddress  = JobParamsDoc.Text("MQAddress");
            var mqPassWord = JobParamsDoc.Text("MQAuthorization");

            //http://192.168.185.173:15672/api/queues
            Core.HttpHelper http = new Core.HttpHelper();
            HttpItem        item = new HttpItem()
            {
                URL       = mqAddress,
                Accept    = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36",
            };

            item.Header.Add("Authorization", "Basic YW50YXBvczphbnRhcG9z");
            var result = http.GetHtml(item);

            if (result.StatusCode != System.Net.HttpStatusCode.OK)
            {
                var messageInfo = new PushMessageInfo()
                {
                    content        = "RabbitMQ服务停止预警",
                    approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                    errorMessage   = $"{mqAddress}rabbitMQ队列服务出错",
                    customerCode   = SysAppConfig.CustomerCode,
                    logType        = "1"
                };
                return(messageInfo.ToJson());
            }
            return(string.Empty);
        }
        /// <summary>
        /// 重载基类算法
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var start    = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}"); //统计当天时间
            var end      = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day + 1}").AddSeconds(-1);
            var startStr = DateTime.Now.ToString("yyyyMMdd000000");                                        //统计当天时间
            var endStr   = end.ToString("yyyyMMddHHmmss");
            var week     = DateTime.Now.DayOfWeek;

            if (week == DayOfWeek.Saturday || week == DayOfWeek.Sunday)//周末跳过
            {
                return(string.Empty);
            }
            //获取当前登录状态
            List <BsonDocument> loginList = dataOp.FindAllByQuery("SysBehaviorLog", Query.And(Query.GTE("timeSort", startStr), Query.LTE("timeSort", endStr))).ToList();

            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            JobLogger.Info($"登陆统计个数:{loginList.Count()}");
            if (loginList.Any())
            {
                return(string.Empty);
            }
            var errorMessage =
                $"截止{start.ToString()}至{end.ToString()} {DateTime.Now:ddd} 系统目前无任何用户登录进行操作请注意";

            var messageInfo = new PushMessageInfo()
            {
                content        = "系统登录预警",
                approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                errorMessage   = errorMessage,
                customerCode   = SysAppConfig.CustomerCode,
                logType        = "1"
            };

            return(messageInfo.ToJson());
        }
        /// <summary>
        /// 重载基类算法,注意如果重复读取可能发生数据重复发送邮件
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var rabbitQueueMessageType = JobParamsDoc.Text("MQMessageType");
            var rabbitMQVirtualHost    = JobParamsDoc.Text("MQVirtualHost");
            var RetryCount             = JobParamsDoc.Text("RetryCount");
            var tableName = $"{rabbitQueueMessageType}_{rabbitMQVirtualHost}_{DateTime.Now.ToString("yyyy-MM")}";

            var week           = DateTime.Now.DayOfWeek;
            var retryTimeQuery = Query.And(Query.NE("DeQueueStage", 1), Query.GTE("EnQueueStage", 3)); //重试入队多次
            var query          = Query.Or(retryTimeQuery, Query.Exists("errorMsgs", true));            //有错误消息
            var limit          = 20;
            //获取当前登录状态
            var recordCount    = dataOp.FindCount(tableName, query);
            var topRecoredList = dataOp.FindLimitFieldsByQuery(tableName, query, new MongoDB.Driver.SortByDocument()
            {
            }, 0, limit, new string[] { "messageID", "errorMsgs", "MessageRouter", "MessageBody", "EnQueueStage" }).ToList();

            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            if (!topRecoredList.Any())
            {
                return(string.Empty);
            }
            JobLogger.Info($"队列执行错误个数:{recordCount}");
            var errorMessage = new StringBuilder();

            errorMessage.AppendLine($"{DateTime.Now.ToString("yyyy-MM")}捕获到队列执行异常数据${recordCount}条.前{limit}内容如下:\n\r");
            topRecoredList.ForEach(doc =>
            {
                errorMessage.AppendLine($"{doc.ToJson()}");
            });
            var approvalUserId = this.JobParamsDoc.Text("approvalUserId");

            var messageInfo = new PushMessageInfo()
            {
                content        = $"小票上传重试错误预警,失败条数:{recordCount}",
                approvalUserId = approvalUserId,
                errorMessage   = errorMessage.ToString(),
                customerCode   = SysAppConfig.CustomerCode,
                logType        = "1"
            };

            return(messageInfo.ToJson());
        }
        /// <summary>
        /// 从数据库中调用EUR_DEADLOCK_DETAIL
        /// TimePoint  statement_parameter_k statement_k statement_parameter [statement] waitresource_k waitresource
        /// isolationlevel_k isolationlevel waittime_k waittime
        ///clientapp_k clientapp hostname_k hostname
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            //获取异常数据的接口地址通过pos站点数据
            var posUrl = JobParamsDoc.Text("PosUrl");
            var result = GetHtml(posUrl);

            if (result.StatusCode == System.Net.HttpStatusCode.OK)
            {
                try
                {
                    var resultDoc = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(result.Html);
                    if (!resultDoc.ContainsColumn("data") || string.IsNullOrEmpty(resultDoc.Text("data")))
                    {
                        return(string.Empty);
                    }
                    var detailDetailInfo = string.Empty;
                    var deadLockList     = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <List <BsonDocument> >(resultDoc.Text("data"));
                    if (deadLockList.Count() > 0)
                    {
                        //返回解析后的内容字符串
                        detailDetailInfo  = GetDetailFromJson(deadLockList);
                        detailDetailInfo += "详情请通过exec EUR_DEADLOCK_DETAIL 进行查询";
                        var messageInfo = new PushMessageInfo()
                        {
                            content        = "数据库死锁预警",
                            approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                            errorMessage   = detailDetailInfo,
                            customerCode   = SysAppConfig.CustomerCode,
                            logType        = "1"
                        };
                        return(messageInfo.ToJson());
                    }
                } catch (Exception ex)
                {
                }
            }
            return(string.Empty);
        }
예제 #5
0
        /// <summary>
        /// 重载基类算法
        /// </summary>
        /// <returns></returns>
        internal override string GenerateData()
        {
            var now = DateTime.Now;                                                                        //统一记录当前运行时刻

            var start    = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}"); //统计当天时间
            var end      = DateTime.Parse($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day + 1}").AddSeconds(-1);
            var startStr = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");                                   //统计当天时间
            var endStr   = end.ToString("yyyy-MM-dd-HH HH:mm:ss");
            var extArray = SysAppConfig.needCutThumbExtArray;

            var limitCondition = this.JobParamsDoc.Double("limitCondition");

            if (limitCondition <= 0)
            {
                limitCondition = 0.05;
            }
            //2015.4.13 新增错误日志发送到125.77.255.2:8023端口进行存储,后续迁移
            var serverDiskAlertLimit = SysAppConfig.ServerDiskAlertLimit;

            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
            var pushInfoStr    = new StringBuilder();
            var detaileContent = new StringBuilder();
            var needSend       = false;

            foreach (System.IO.DriveInfo drive in drives.Where(c => c.DriveType == DriveType.Fixed || c.DriveType == DriveType.Network))
            {
                try
                {
                    if (drive.IsReady)
                    {
                        long totalSize          = drive.TotalSize / 1024 / 1024 / 1024;          //MB//总大小
                        long availableFreeSpace = drive.AvailableFreeSpace / 1024 / 1024 / 1024; //MB//可用大小
                        var  usedSpace          = totalSize - availableFreeSpace;                //MB//
                        var  avaiablePercent    = double.Parse(availableFreeSpace.ToString()) / totalSize;

                        if (availableFreeSpace <= serverDiskAlertLimit || avaiablePercent <= limitCondition) //空间剩余5%报警
                        {
                            if (pushInfoStr.Length <= 0)
                            {
                                pushInfoStr.AppendFormat("磁盘空间提醒:", drive.Name);
                            }
                            pushInfoStr.AppendFormat("{0}空间不足 ", drive.Name);
                            detaileContent.AppendFormat("{0}总:{1}G 已用:{2}G 可用:{3}G\n\r", drive.Name, totalSize, usedSpace, availableFreeSpace);
                            needSend = true;
                        }
                    }
                }
                catch (System.IO.IOException ex)
                {
                    JobLogger.Info(ex.Message);
                }
                catch (Exception ex)
                {
                    JobLogger.Info(ex.Message);
                }
            }

            if (!needSend)
            {
                return(string.Empty);
            }
            JobLogger.Info("磁盘进入警告");
            var errorMessage = $"截止{start.ToString()}至{end.ToString()} {DateTime.Now:ddd} {pushInfoStr}";

            var messageInfo = new PushMessageInfo()
            {
                approvalUserId = this.JobParamsDoc.Text("approvalUserId"),
                errorMessage   = errorMessage,
                content        = detaileContent.ToString(),
                logType        = "4",
                customerCode   = SysAppConfig.CustomerCode,
                fileStatisDate = now.ToString("yyyy-MM-dd")
            };

            return(messageInfo.ToJson());
            //模拟发送post请求
        }