feat(api): StatRabbitMqController GetConnectionStats добавлен параметр ThresholdConnections, вынесен в настройки
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
namespace PARR.API.Contracts.V1.Responses.Statistics
|
||||||
|
{
|
||||||
|
public class StatRabbitMqConnectionsResponse
|
||||||
|
{
|
||||||
|
public StatRabbitMqConnectionsMonitoringSettings MonitoringSettings { get; set; }
|
||||||
|
|
||||||
|
public object? MqData { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StatRabbitMqConnectionsMonitoringSettings
|
||||||
|
{
|
||||||
|
public int ThresholdConnections { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using PARR.API.Contracts.V1;
|
using PARR.API.Contracts.V1;
|
||||||
using PARR.API.Contracts.V1.Responses.Base;
|
using PARR.API.Contracts.V1.Responses.Base;
|
||||||
|
using PARR.API.Contracts.V1.Responses.Statistics;
|
||||||
using PARR.API.Controllers.V1.Base;
|
using PARR.API.Controllers.V1.Base;
|
||||||
using PARR.API.Settings;
|
using PARR.API.Settings;
|
||||||
using PARR.BLL.Services.Interfaces;
|
using PARR.BLL.Services.Interfaces;
|
||||||
@@ -19,13 +20,21 @@ namespace PARR.API.Controllers.V1.Statistics
|
|||||||
private readonly MqSettings mqSettings;
|
private readonly MqSettings mqSettings;
|
||||||
private readonly ILogger<StatRabbitMqController> logger;
|
private readonly ILogger<StatRabbitMqController> logger;
|
||||||
private readonly IMqAdminService mqAdminService;
|
private readonly IMqAdminService mqAdminService;
|
||||||
|
private readonly MonitoringSettings monitoringSettings;
|
||||||
|
|
||||||
public StatRabbitMqController(IMqService mqService, MqSettings mqSettings, ILogger<StatRabbitMqController> logger, IMqAdminService mqAdminService)
|
public StatRabbitMqController(
|
||||||
|
IMqService mqService,
|
||||||
|
MqSettings mqSettings,
|
||||||
|
ILogger<StatRabbitMqController> logger,
|
||||||
|
IMqAdminService mqAdminService,
|
||||||
|
MonitoringSettings monitoringSettings
|
||||||
|
)
|
||||||
{
|
{
|
||||||
this.mqService = mqService;
|
this.mqService = mqService;
|
||||||
this.mqSettings = mqSettings;
|
this.mqSettings = mqSettings;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mqAdminService = mqAdminService;
|
this.mqAdminService = mqAdminService;
|
||||||
|
this.monitoringSettings = monitoringSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -42,6 +51,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
|||||||
|
|
||||||
return Ok(new Response<object?>(result.Response, true));
|
return Ok(new Response<object?>(result.Response, true));
|
||||||
|
|
||||||
|
#region comments
|
||||||
//var response = new List<StatRabbitMqQueueResponse>();
|
//var response = new List<StatRabbitMqQueueResponse>();
|
||||||
|
|
||||||
//// список очередей
|
//// список очередей
|
||||||
@@ -59,6 +69,7 @@ namespace PARR.API.Controllers.V1.Statistics
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
//return Ok(new Response<List<StatRabbitMqQueueResponse>>(response.OrderBy(t => t.Name).ToList(), true));
|
//return Ok(new Response<List<StatRabbitMqQueueResponse>>(response.OrderBy(t => t.Name).ToList(), true));
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,7 +85,16 @@ namespace PARR.API.Controllers.V1.Statistics
|
|||||||
if (!result.IsSuccess)
|
if (!result.IsSuccess)
|
||||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при получении статистики из RabbitMQ." } }));
|
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Ошибка при получении статистики из RabbitMQ." } }));
|
||||||
|
|
||||||
return Ok(new Response<object?>(result.Response, true));
|
var response = new StatRabbitMqConnectionsResponse
|
||||||
|
{
|
||||||
|
MqData = result.Response,
|
||||||
|
MonitoringSettings = new StatRabbitMqConnectionsMonitoringSettings
|
||||||
|
{
|
||||||
|
ThresholdConnections = monitoringSettings.RabbitMq?.ThresholdConnections ?? 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return Ok(new Response<StatRabbitMqConnectionsResponse>(response, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
public class MonitoringSettings
|
public class MonitoringSettings
|
||||||
{
|
{
|
||||||
public List<MonitoringRobotSettings> Robots { get; set; } = new List<MonitoringRobotSettings>();
|
public List<MonitoringRobotSettings> Robots { get; set; } = new List<MonitoringRobotSettings>();
|
||||||
|
|
||||||
|
public MonitoringRabbitMq? RabbitMq { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MonitoringRobotSettings
|
public class MonitoringRobotSettings
|
||||||
@@ -11,4 +13,12 @@
|
|||||||
|
|
||||||
public TimeSpan InaccessibilityTime { get; set; }
|
public TimeSpan InaccessibilityTime { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class MonitoringRabbitMq
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Кол-во подключений к RabbitMq, если меньше, то алярм
|
||||||
|
/// </summary>
|
||||||
|
public int ThresholdConnections { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,9 @@
|
|||||||
"Name": "ScheduleExport",
|
"Name": "ScheduleExport",
|
||||||
"InaccessibilityTime": "01:20:00"
|
"InaccessibilityTime": "01:20:00"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"RabbitMq": {
|
||||||
|
"ThresholdConnections": 18
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user