public static void AddToMenu(Menu menu,
            string uniqueId,
            HealthCheckType checkType,
            HealthValueType valueType,
            string prefix = null,
            int value = 30,
            int minValue = 0,
            int maxValue = 100)
        {
            try
            {
                if (Menues.ContainsKey(uniqueId))
                {
                    throw new ArgumentException(
                        string.Format("HealthHealthger: UniqueID \"{0}\" already exist.", uniqueId));
                }

                menu.AddItem(
                    new MenuItem(
                        menu.Name + ".health-" + uniqueId,
                        (!string.IsNullOrEmpty(prefix) ? prefix + " " : string.Empty) +
                        (checkType == HealthCheckType.Minimum ? "Min. Health" : "Max. Health") +
                        (valueType == HealthValueType.Percent ? " %" : string.Empty)).SetValue(
                            new Slider(value, minValue, maxValue)));

                Menues[uniqueId] = new Tuple<Menu, HealthCheckType, HealthValueType>(menu, checkType, valueType);
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
Esempio n. 2
0
        public void Reload(dynamic jsonHealthCheck)
        {
            if (jsonHealthCheck.name is null)
            {
                _name = "default";
            }
            else
            {
                _name = jsonHealthCheck.name.Value;
            }

            if (jsonHealthCheck.type == null)
            {
                _type = HealthCheckType.Tcp;
            }
            else
            {
                _type = Enum.Parse <HealthCheckType>(jsonHealthCheck.type.Value, true);
            }

            if (jsonHealthCheck.interval is null)
            {
                _interval = 60000;
            }
            else
            {
                _interval = Convert.ToInt32(jsonHealthCheck.interval.Value) * 1000;
            }

            if (jsonHealthCheck.retries is null)
            {
                _retries = 3;
            }
            else
            {
                _retries = Convert.ToInt32(jsonHealthCheck.retries.Value);
            }

            if (jsonHealthCheck.timeout is null)
            {
                _timeout = 10000;
            }
            else
            {
                _timeout = Convert.ToInt32(jsonHealthCheck.timeout.Value) * 1000;
            }

            if (jsonHealthCheck.port is null)
            {
                _port = 80;
            }
            else
            {
                _port = Convert.ToInt32(jsonHealthCheck.port.Value);
            }

            if ((jsonHealthCheck.url is null) || (jsonHealthCheck.url.Value is null))
            {
                _url = null;
            }
Esempio n. 3
0
        public static void AddToMenu(Menu menu,
                                     string uniqueId,
                                     HealthCheckType checkType,
                                     HealthValueType valueType,
                                     string prefix = null,
                                     int value     = 30,
                                     int minValue  = 0,
                                     int maxValue  = 100)
        {
            try
            {
                if (Menues.ContainsKey(uniqueId))
                {
                    throw new ArgumentException(
                              string.Format("HealthHealthger: UniqueID \"{0}\" already exist.", uniqueId));
                }

                menu.AddItem(
                    new MenuItem(
                        menu.Name + ".health-" + uniqueId,
                        (!string.IsNullOrEmpty(prefix) ? prefix + " " : string.Empty) +
                        (checkType == HealthCheckType.Minimum ? "Min. Health" : "Max. Health") +
                        (valueType == HealthValueType.Percent ? " %" : string.Empty)).SetValue(
                        new Slider(value, minValue, maxValue)));

                Menues[uniqueId] = new Tuple <Menu, HealthCheckType, HealthValueType>(menu, checkType, valueType);
            }
            catch (Exception ex)
            {
                Global.Logger.AddItem(new LogItem(ex));
            }
        }
 public MachineHealthCheckPolicy()
 {
     PowerShellHealthCheckPolicy = new MachineScriptPolicy();
     BashHealthCheckPolicy       = new MachineScriptPolicy();
     HealthCheckInterval         = TimeSpan.FromHours(1);
     HealthCheckType             = HealthCheckType.RunScript;
 }
Esempio n. 5
0
 private void SetHealthCheckType(string healthCheckType)
 {
     if (healthCheckType == "None")
     {
         _healthCheckType = HealthCheckType.None;
     }
     else if (healthCheckType == "HttpRest")
     {
         _healthCheckType = HealthCheckType.HttpRest;
     }
 }
Esempio n. 6
0
 public void Type(HealthCheckType type) => CheckUpType = type;
Esempio n. 7
0
        public AutoScalingGroup HealthCheckType(HealthCheckType type)
        {
            this.Properties.HealthCheckType = Enum.GetName(typeof(HealthCheckType), type);

            return(this);
        }
Esempio n. 8
0
 public HealthCheckResultDto(HealthCheckType checkType, HealthStatusType statusType)
 {
     StatusType = statusType;
     CheckType  = checkType;
 }
Esempio n. 9
0
 public void Node(string name)
 {
     CheckUpType   = HealthCheckType.Node;
     RmqObjectName = name;
 }
Esempio n. 10
0
 public void VirtualHost(string name)
 {
     CheckUpType   = HealthCheckType.VirtualHost;
     RmqObjectName = name;
 }
Esempio n. 11
0
        public void Reload(dynamic jsonHealthCheck)
        {
            if (jsonHealthCheck.name is null)
            {
                _name = "default";
            }
            else
            {
                _name = jsonHealthCheck.name.Value;
            }

            if (jsonHealthCheck.type == null)
            {
                _type = HealthCheckType.Tcp;
            }
            else
            {
                _type = Enum.Parse <HealthCheckType>(jsonHealthCheck.type.Value, true);
            }

            if (jsonHealthCheck.interval is null)
            {
                _interval = 60000;
            }
            else
            {
                _interval = Convert.ToInt32(jsonHealthCheck.interval.Value) * 1000;
            }

            if (jsonHealthCheck.retries is null)
            {
                _retries = 3;
            }
            else
            {
                _retries = Convert.ToInt32(jsonHealthCheck.retries.Value);
            }

            if (jsonHealthCheck.timeout is null)
            {
                _timeout = 10000;
            }
            else
            {
                _timeout = Convert.ToInt32(jsonHealthCheck.timeout.Value) * 1000;
            }

            if (jsonHealthCheck.port is null)
            {
                _port = 80;
            }
            else
            {
                _port = Convert.ToInt32(jsonHealthCheck.port.Value);
            }

            if (jsonHealthCheck.url is null)
            {
                _url = null;
            }
            else
            {
                _url = new Uri(jsonHealthCheck.url.Value);
            }

            string emailAlertName;

            if (jsonHealthCheck.emailAlert is null)
            {
                emailAlertName = null;
            }
            else
            {
                emailAlertName = jsonHealthCheck.emailAlert.Value;
            }

            if ((emailAlertName is not null) && _service.EmailAlerts.TryGetValue(emailAlertName, out EmailAlert emailAlert))
            {
                _emailAlert = emailAlert;
            }
Esempio n. 12
0
        /// Inline form:
        ///   <hc-type> ';' <threshold> ';' <ip-addr> ';' <port> ';' <fqdn> ';' <res-path> ';' <search>
        Task <HealthCheckConfig> ParseInlineHealthCheck(string specTag)
        {
            var specParts = specTag.Split(";", 7);

            if (specParts.Length < 2)
            {
                throw new Exception("invalid INLINE R53 Health Check spec");
            }

            _logger.LogInformation($"Defining R53 Health Check per resolved INLINE spec: {specTag}");

            var hcTypeStr = specParts[0];
            var hcType    = HealthCheckType.FindValue(hcTypeStr);

            if (hcType == null)
            {
                throw new Exception("unknown Health Check type");
            }
            if (!HealthCheckInlineAllowedTypes.Contains(hcType))
            {
                throw new Exception("Health Check type is unsupported for INLINE spec");
            }

            var config = new HealthCheckConfig
            {
                Type = hcType,
                // RequestInterval = 30,
                // InsufficientDataHealthStatus = InsufficientDataHealthStatus.LastKnownStatus,
            };
            uint numVal;

            if (specParts.Length > 1 && !string.IsNullOrWhiteSpace(specParts[1]))
            {
                if (!uint.TryParse(specParts[1], out numVal))
                {
                    throw new Exception("invalid threshold value");
                }
                config.FailureThreshold = (int)numVal;
            }

            if (specParts.Length > 2 && !string.IsNullOrWhiteSpace(specParts[2]))
            {
                config.IPAddress = specParts[2].Trim();
            }

            if (specParts.Length > 3 && !string.IsNullOrWhiteSpace(specParts[3]))
            {
                if (!uint.TryParse(specParts[3], out numVal))
                {
                    throw new Exception("invalid port value");
                }
                config.Port = (int)numVal;
            }

            if (specParts.Length > 4 && !string.IsNullOrWhiteSpace(specParts[4]))
            {
                config.FullyQualifiedDomainName = specParts[4].Trim();
            }

            if (specParts.Length > 5 && !string.IsNullOrWhiteSpace(specParts[5]))
            {
                config.ResourcePath = specParts[5];
            }

            if (specParts.Length > 6 && !string.IsNullOrWhiteSpace(specParts[6]))
            {
                config.SearchString = specParts[6];
            }

            return(Task.FromResult(config));
        }
Esempio n. 13
0
 public void Node(string name)
 {
     CheckUpType  = HealthCheckType.Node;
     ResourceName = name;
 }
Esempio n. 14
0
 public void VirtualHost(string name)
 {
     CheckUpType  = HealthCheckType.VirtualHost;
     ResourceName = name;
 }