コード例 #1
0
        public static HealthChecksUiSettings AddHealthCheckEndpoints(this HealthChecksUiSettings settings, AcuWebSites websites)
        {
            foreach (var website in websites ?? new AcuWebSites())
            {
                settings.AddHealthCheckEndpoint(website.Name, website.EndpointUrl);
            }

            return(settings);
        }
コード例 #2
0
        public static HealthChecksUiSettings AddWebhookNotifications(this HealthChecksUiSettings settings, Webhooks webhooks)
        {
            foreach (var webhook in webhooks ?? new Webhooks())
            {
                settings.AddWebhookNotification(webhook.Name, webhook.Url, webhook.FailurePayload,
                                                webhook.RestorePayload, webhook.ShouldNotifyFunc, webhook.CustomMessageFunc,
                                                webhook.CustomDescriptionFunc);
            }

            return(settings);
        }
コード例 #3
0
 public static void AddHealthCheckEndpointIfExists(this HealthChecks.UI.Configuration.Settings setup, string name, string uri)
 {
     if (!string.IsNullOrEmpty(uri))
     {
         try
         {
             setup.AddHealthCheckEndpoint(name, uri);
         }
         catch (Exception)
         {
         }
     }
 }
コード例 #4
0
 public static void AddWebHookIfExists(this HealthChecks.UI.Configuration.Settings setup, string name, string uri, string watchdogUri)
 {
     if (!string.IsNullOrEmpty(uri))
     {
         try
         {
             setup.AddWebhookNotification(name, uri,
                                          "{\r\n  \"@context\": \"http://schema.org/extensions\",\r\n  \"@type\": \"MessageCard\",\r\n  \"themeColor\": \"0072C6\",\r\n  \"title\": \"Watchdog Alert: [[LIVENESS]] has failed!\",\r\n  \"text\": \"[[FAILURE]] Click **Learn More** to go to the Watchdog Service\",\r\n  \"potentialAction\": [\r\n    {\r\n      \"@type\": \"OpenUri\",\r\n      \"name\": \"Learn More\",\r\n      \"targets\": [\r\n        { \"os\": \"default\", \"uri\": \"" + watchdogUri + "\" }\r\n      ]\r\n    }\r\n  ]\r\n}",
                                          "{\"text\":\"Watchdog Alert: The HealthCheck [[LIVENESS]] is recovered. All is up and running\",\"channel\":\"#general\",\"link_names\": 1,\"username\":\"monkey-bot\",\"icon_emoji\":\":monkey_face\" }"
                                          );
         }
         catch (Exception)
         {
         }
     }
 }
コード例 #5
0
        internal static HealthChecks.UI.Configuration.Settings AddIoTSharpHealthCheckEndpoint(this HealthChecks.UI.Configuration.Settings setup)
        {
            var urls = Environment.GetEnvironmentVariable("ASPNETCORE_URLS")?.Split(';');
            var uris = urls?.Select(url => Regex.Replace(url, @"^(?<scheme>https?):\/\/((\+)|(\*)|(0.0.0.0))(?=[\:\/]|$)", "${scheme}://localhost"))
                       .Select(uri => new Uri(uri, UriKind.Absolute)).ToArray();
            var httpEndpoint  = uris?.FirstOrDefault(uri => uri.Scheme == "http");
            var httpsEndpoint = uris?.FirstOrDefault(uri => uri.Scheme == "https");

            if (httpEndpoint != null) // Create an HTTP healthcheck endpoint
            {
                setup.AddHealthCheckEndpoint("IoTSharp", new UriBuilder(httpEndpoint.Scheme, httpEndpoint.Host, httpEndpoint.Port, "/healthz").ToString());
            }
            else if (httpsEndpoint != null) // Create an HTTPS healthcheck endpoint
            {
                setup.AddHealthCheckEndpoint("IoTSharp", new UriBuilder(httpsEndpoint.Scheme, httpsEndpoint.Host, httpsEndpoint.Port, "/healthz").ToString());
            }
            else
            {
                //One endpoint is configured in appsettings, let's add another one programatically
                setup.AddHealthCheckEndpoint("IoTSharp", "/healthz");
            }
            return(setup);
        }