public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult result;
            BrokerConnectivitySnapshot data = snapshot as BrokerConnectivitySnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(null,
                                                      null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("ConnectionsCreated.Rate", data.ConnectionsCreated.Rate.ToString()),
                new ProbeDataImpl("HighConnectionCreationRateThreshold", _config.Probes.HighConnectionCreationRateThreshold.ToString())
            };

            if (data.ConnectionsCreated.Rate >= _config.Probes.HighConnectionCreationRateThreshold)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Warning, out var article);
                result = new WarningProbeResult(null,
                                                null,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(null,
                                                null,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #2
0
        public ProbeResult Execute <T>(T snapshot)
        {
            QueueSnapshot data = snapshot as QueueSnapshot;
            ProbeResult   result;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(null,
                                                      null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("Messages.Incoming.Total", data.Messages.Incoming.Total.ToString()),
                new ProbeDataImpl("QueueLowFlowThreshold", _config.Probes.QueueLowFlowThreshold.ToString())
            };

            if (data.Messages.Incoming.Total <= _config.Probes.QueueLowFlowThreshold)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.Node,
                                                  data.Identifier,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.Node,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #3
0
 static bool Validate(DiagnosticsConfig config) =>
 !config.IsNull() &&
 !config.Probes.IsNull() &&
 config.Probes.ConsumerUtilizationThreshold > 0 &&
 config.Probes.HighConnectionClosureRateThreshold > 0 &&
 config.Probes.HighConnectionCreationRateThreshold > 0 &&
 config.Probes.MessageRedeliveryThresholdCoefficient > 0 &&
 config.Probes.QueueHighFlowThreshold > 0 &&
 config.Probes.QueueLowFlowThreshold > 0 &&
 config.Probes.SocketUsageThresholdCoefficient > 0 &&
 config.Probes.FileDescriptorUsageThresholdCoefficient > 0 &&
 config.Probes.RuntimeProcessUsageThresholdCoefficient > 0;
        public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult             result;
            OperatingSystemSnapshot data = snapshot as OperatingSystemSnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(!data.IsNull() ? data.NodeIdentifier : null,
                                                      !data.IsNull() ? data.ProcessId : null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            ulong threshold = ComputeThreshold(data.FileDescriptors.Available);

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("FileDescriptors.Available", data.FileDescriptors.Available.ToString()),
                new ProbeDataImpl("FileDescriptors.Used", data.FileDescriptors.Used.ToString()),
                new ProbeDataImpl("FileDescriptorUsageThresholdCoefficient", _config.Probes.FileDescriptorUsageThresholdCoefficient.ToString()),
                new ProbeDataImpl("CalculatedThreshold", threshold.ToString())
            };

            if (data.FileDescriptors.Used < threshold && threshold < data.FileDescriptors.Available)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.NodeIdentifier,
                                                data.ProcessId,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else if (data.FileDescriptors.Used == data.FileDescriptors.Available)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.NodeIdentifier,
                                                  data.ProcessId,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Warning, out var article);
                result = new WarningProbeResult(data.NodeIdentifier,
                                                data.ProcessId,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #5
0
        public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult   result;
            QueueSnapshot data = snapshot as QueueSnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(data.IsNotNull() ? data.Node : null,
                                                      data.IsNotNull() ? data.Identifier : null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("ConsumerUtilization", data.ConsumerUtilization.ToString()),
                new ProbeDataImpl("ConsumerUtilizationThreshold", _config.Probes.ConsumerUtilizationThreshold.ToString())
            };

            if (data.ConsumerUtilization >= _config.Probes.ConsumerUtilizationThreshold &&
                data.ConsumerUtilization < 1.0M &&
                _config.Probes.ConsumerUtilizationThreshold <= 1.0M)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Warning, out var article);
                result = new WarningProbeResult(data.Node,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else if (data.ConsumerUtilization < _config.Probes.ConsumerUtilizationThreshold &&
                     _config.Probes.ConsumerUtilizationThreshold <= 1.0M)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.Node,
                                                  data.Identifier,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.Node,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #6
0
        public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult           result;
            BrokerRuntimeSnapshot data = snapshot as BrokerRuntimeSnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(null,
                                                      null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            ulong threshold = ComputeThreshold(data.Processes.Limit);

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("Processes.Limit", data.Processes.Limit.ToString()),
                new ProbeDataImpl("Processes.Used", data.Processes.Used.ToString()),
                new ProbeDataImpl("CalculatedThreshold", threshold.ToString())
            };

            if (data.Processes.Used >= data.Processes.Limit)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.ClusterIdentifier,
                                                  data.Identifier,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else if (data.Processes.Used >= threshold && threshold < data.Processes.Limit)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new WarningProbeResult(data.ClusterIdentifier,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.ClusterIdentifier,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #7
0
        public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult  result;
            NodeSnapshot data = snapshot as NodeSnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(!data.IsNull() ? data.ClusterIdentifier : null,
                                                      !data.IsNull() ? data.Identifier : null,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            ulong warningThreshold = ComputeThreshold(data.OS.SocketDescriptors.Available);

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("OS.Sockets.Available", data.OS.SocketDescriptors.Available.ToString()),
                new ProbeDataImpl("OS.Sockets.Used", data.OS.SocketDescriptors.Used.ToString()),
                new ProbeDataImpl("CalculatedThreshold", warningThreshold.ToString())
            };

            if (data.OS.SocketDescriptors.Used < warningThreshold && warningThreshold < data.OS.SocketDescriptors.Available)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.ClusterIdentifier,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else if (data.OS.SocketDescriptors.Used == data.OS.SocketDescriptors.Available)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.ClusterIdentifier,
                                                  data.Identifier,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Warning, out var article);
                result = new WarningProbeResult(data.ClusterIdentifier,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }
Exemple #8
0
        public ProbeResult Execute <T>(T snapshot)
        {
            ProbeResult   result;
            QueueSnapshot data = snapshot as QueueSnapshot;

            if (_config.IsNull() || _config.Probes.IsNull())
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.NA, out var article);
                result = new NotApplicableProbeResult(!data.IsNull() ? data.Node : string.Empty,
                                                      !data.IsNull() ? data.Identifier : string.Empty,
                                                      Metadata.Id,
                                                      Metadata.Name,
                                                      ComponentType,
                                                      article);

                NotifyObservers(result);

                return(result);
            }

            ulong warningThreshold = ComputeThreshold(data.Messages.Incoming.Total);

            var probeData = new List <ProbeData>
            {
                new ProbeDataImpl("Messages.Incoming.Total", data.Messages.Incoming.Total.ToString()),
                new ProbeDataImpl("Messages.Redelivered.Total", data.Messages.Redelivered.Total.ToString()),
                new ProbeDataImpl("MessageRedeliveryThresholdCoefficient", _config.Probes.MessageRedeliveryThresholdCoefficient.ToString()),
                new ProbeDataImpl("CalculatedThreshold", warningThreshold.ToString())
            };

            if (data.Messages.Redelivered.Total >= warningThreshold &&
                data.Messages.Redelivered.Total < data.Messages.Incoming.Total &&
                warningThreshold < data.Messages.Incoming.Total)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Warning, out var article);
                result = new WarningProbeResult(data.Node,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }
            else if (data.Messages.Redelivered.Total >= data.Messages.Incoming.Total)
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Unhealthy, out var article);
                result = new UnhealthyProbeResult(data.Node,
                                                  data.Identifier,
                                                  Metadata.Id,
                                                  Metadata.Name,
                                                  ComponentType,
                                                  probeData,
                                                  article);
            }
            else
            {
                _kb.TryGet(Metadata.Id, ProbeResultStatus.Healthy, out var article);
                result = new HealthyProbeResult(data.Node,
                                                data.Identifier,
                                                Metadata.Id,
                                                Metadata.Name,
                                                ComponentType,
                                                probeData,
                                                article);
            }

            NotifyObservers(result);

            return(result);
        }