using HDLMonitorService.Entity;
|
using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace HDLMonitorService.Helper
|
{
|
public class AlarmHp
|
{
|
/// <summary>
|
/// 发送业务异常报警
|
/// </summary>
|
/// <param name="serviceName"></param>
|
/// <param name="alarmType"></param>
|
/// <param name="content"></param>
|
/// <param name="ip"></param>
|
public static void ApplicationAlarm(string serviceName, string alarmType, string content, string ip, string title)
|
{
|
var dto = new
|
{
|
alarmType = alarmType,
|
content = content,
|
serviceIp = ip,
|
serviceName = serviceName,
|
trace = Guid.NewGuid().ToString().Replace("-", string.Empty),
|
alarmLevel = "HIGH"
|
};
|
|
var data = HttpHp.GetSignRequestJson(dto);
|
|
var result = HttpHp.Post<ResponseData>(ConfigurationManager.AppSettings["ApplicationAlarm"].ToString(), data);
|
if (result != null && result.code == 0)
|
{
|
//WechatAlarm(serviceName, "CUSTOM_ALARM", content, ip, "HIGH", title);
|
}
|
}
|
|
public static void ServiceAlarm(string serviceName, string content, string ip, string title)
|
{
|
var dto = new
|
{
|
alarmType = "OFFLINE",
|
content = content,
|
serviceIp = ip,
|
serviceName = serviceName,
|
trace = Guid.NewGuid().ToString().Replace("-", string.Empty),
|
alarmLevel = "HIGH"
|
};
|
|
var data = HttpHp.GetSignRequestJson(dto);
|
|
var result = HttpHp.Post<ResponseData>(ConfigurationManager.AppSettings["ApplicationAlarm"].ToString(), data);
|
if (result != null && result.code == 0)
|
{
|
//WechatAlarm(serviceName, "SPRING_BOOT_ADMIN", content, ip, "HIGH", title);
|
}
|
}
|
|
//public static void WechatAlarm(string serviceName, string alarmType, string content, string ip, string alarmLevel, string subType)
|
//{
|
// var wechatDto = new
|
// {
|
// alarmType = alarmType,
|
// alarmLevel = alarmLevel,
|
// server = ip,
|
// application = serviceName,
|
// subType = subType,
|
// time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
// trace = Guid.NewGuid().ToString().Replace("-", string.Empty),
|
// content = content
|
// };
|
|
// var wechatResult = HttpHp.Post<ResponseData>(ConfigurationManager.AppSettings["WechatAlarm"], Newtonsoft.Json.JsonConvert.SerializeObject(wechatDto));
|
// if (wechatResult != null && wechatResult.code == 0)
|
// {
|
// //发送成功
|
// }
|
//}
|
}
|
}
|