public override async Task Execute()
        {
            var now = DateTime.UtcNow;

            var record = new MonitoringRecord
            {
                DateTime    = now,
                ServiceName = MOnitoringServiceNames.EmailSenderBridge,
                Version     = Microsoft.Extensions.PlatformAbstractions.PlatformServices.Default.Application.ApplicationVersion
            };

            await _serviceMonitoringRepository.UpdateOrCreate(record);
        }
Example #2
0
        private async Task CheckHost(HostToCheck host)
        {
            try
            {
                var result = await HttpRequestClient.GetRequestAsync(host.Url);

                string version = null;
                try
                {
                    var model = result.DeserializeJson <AmIAliveModel>();
                    version = model?.Version;

                    if (!string.IsNullOrEmpty(model?.Error))
                    {
                        await SendNotification(
                            SlackMonitorChannel, $":exclamation: {_appName} {_appVersion}: {host.ServiceName}: {model.Error}");
                    }
                }
                catch
                {
                    // ignored
                    //not all system support version yet
                }

                await _serviceMonitoringRepository.UpdateOrCreate(
                    MonitoringRecord.Create(host.ServiceName, DateTime.UtcNow, version));
            }
            catch (WebException ex)
            {
                using (var receiveStream = ex.Response.GetResponseStream())
                {
                    using (var sr = new StreamReader(receiveStream))
                    {
                        var content = await sr.ReadToEndAsync();

                        await _log.WriteErrorAsync("CheckAllServices", "CheckHost", content, ex);
                    }
                }
            }
        }
Example #3
0
 public async Task SendMonitorRecord()
 {
     await
     _serviceMonitoringRepository.UpdateOrCreate(MonitoringRecord.Create("TelegramBot", DateTime.UtcNow,
                                                                         ReflectionUtils.GetAssemblyVersion()));
 }