Merge pull request #202 from Azure/isaac/SimulationCheck
Check Simulation Status
This commit is contained in:
Коммит
398393f5f3
|
@ -75,7 +75,7 @@ namespace Microsoft.Azure.IoTSolutions.AsaManager.Services
|
|||
var storageResult = await alarmsCosmosDb.PingAsync();
|
||||
SetServiceStatus("Storage", storageResult, result, errors);
|
||||
|
||||
// Check access to Event
|
||||
// Check access to EventHub
|
||||
var eventHubResult = await this.PingEventHubAsync();
|
||||
SetServiceStatus("EventHub", eventHubResult, result, errors);
|
||||
|
||||
|
|
|
@ -53,7 +53,10 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.Services
|
|||
SetServiceStatus(deviceTelemetryName, deviceTelemetryResult, result, errors);
|
||||
|
||||
// Check access to DeviceSimulation
|
||||
var deviceSimulationResult = await this.PingServiceAsync(
|
||||
|
||||
/* TODO: Remove PingSimulationAsync and use PingServiceAsync once DeviceSimulation has started
|
||||
* using the new 'Status' model */
|
||||
var deviceSimulationResult = await this.PingSimulationAsync(
|
||||
deviceSimulationName,
|
||||
this.servicesConfig.DeviceSimulationApiUrl);
|
||||
SetServiceStatus(deviceSimulationName, deviceSimulationResult, result, errors);
|
||||
|
@ -125,6 +128,31 @@ namespace Microsoft.Azure.IoTSolutions.UIConfig.Services
|
|||
return result;
|
||||
}
|
||||
|
||||
private async Task<StatusResultServiceModel> PingSimulationAsync(string serviceName, string serviceURL)
|
||||
{
|
||||
var result = new StatusResultServiceModel(false, $"{serviceName} check failed");
|
||||
try
|
||||
{
|
||||
var response = await this.httpClient.GetAsync(this.PrepareRequest($"{serviceURL}/status"));
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
result.Message = $"Status code: {response.StatusCode}; Response: {response.Content}";
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content);
|
||||
result.Message = data["Status"].ToString();
|
||||
result.IsHealthy = data["Status"].ToString().StartsWith("OK:");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.log.Error(result.Message, () => new { e });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private HttpRequest PrepareRequest(string path)
|
||||
{
|
||||
var request = new HttpRequest();
|
||||
|
|
Загрузка…
Ссылка в новой задаче