public static HealthBlock GetHealth()
        {
            HealthBlock block = new HealthBlock()
            {
                Name = "Processor"
            };

            try
            {
                var infos = _instance.GetProcessorPerfInfo();
                block.AddMatrix("Count", infos.Length);

                foreach (var info in infos)
                {
                    HealthBlock b = new HealthBlock();
                    b.Name = info.Name;
                    b.AddMatrix(nameof(info.LoadTotalCurrent), info.LoadTotalCurrent);
                    b.AddMatrix(nameof(info.LoadUsageCurrent), info.LoadUsageCurrent);
                    b.AddMatrix(nameof(info.SpeedCurrent), info.SpeedCurrent);

                    block.AddNested(b);
                }
            }
            catch (Exception e)
            {
                block.AddMatrix("Error", e.Message);
            }
            return(block);
        }
        public static HealthBlock GetHealth()
        {
            HealthBlock block = new HealthBlock()
            {
                Name = "Disk"
            };

            try
            {
                var infos = GetDiskPerfInfo();
                block.AddMatrix("Count", infos.Length);

                foreach (var info in infos)
                {
                    HealthBlock b = new HealthBlock();
                    b.Name = info.Root;
                    b.AddMatrix(nameof(info.SizeTotalFree), info.SizeTotalFree);
                    b.AddMatrix(nameof(info.SizeUsageCurrent), info.SizeUsageCurrent);

                    block.AddNested(b);
                }
            }
            catch (Exception e)
            {
                block.AddMatrix("Error", e.Message);
            }
            return(block);
        }
示例#3
0
        public static void AddNested(this HealthBlock block, HealthBlock nestedBlock)
        {
            if (block.Details == null)
            {
                block.Details = new List <HealthBlock>();
            }

            block.Details.Add(nestedBlock);
        }
示例#4
0
        private void PublishHealth(HealthMessage health)
        {
            Logger.Trace($"HealthCheck '{nameof(TaskProducerWorker)}' Start");
            HealthBlock block = new HealthBlock()
            {
                Name = "TaskProducer"
            };

            block.AddMatrix("IsActive", IsActive);

            health.Add(block);
            Logger.Trace($"HealthCheck '{nameof(TaskProducerWorker)}' End");
        }
示例#5
0
        private void PublishHealth(HealthMessage health)
        {
            _logger.Trace($"HealthCheck '{nameof(PubSubWatchDog)}' Start");
            HealthBlock block = new HealthBlock()
            {
                Name = "PubSubWatchDog"
            };

            block.AddMatrix("IsActive", !IsDisposed);

            health.Add(block);
            _logger.Trace($"HealthCheck '{nameof(PubSubWatchDog)}' End");
        }
示例#6
0
        private void PublishHealth(HealthMessage health)
        {
            Logger.Trace($"HealthCheck '{nameof(ProcessWatchDog)}' Start");
            HealthBlock block = new HealthBlock()
            {
                Name = "ProcessWatchDog"
            };

            block.AddMatrix("IsActive", !IsDisposed && !Interrupter.IsCancellationRequested);

            health.Add(block);
            Logger.Trace($"HealthCheck '{nameof(ProcessWatchDog)}' End");
        }
示例#7
0
        public static HealthBlock GetHealth()
        {
            HealthBlock block = new HealthBlock()
            {
                Name = "OS"
            };

            try
            {
                var info = GetOsInfo();
                block.AddMatrix("Name", info.name);
                block.AddMatrix("Version", info.version);
            }
            catch (Exception e)
            {
                block.AddMatrix("Error", e.Message);
            }
            return(block);
        }
示例#8
0
        private void PublishHealth(HealthMessage health)
        {
            Logger.Trace($"HealthCheck '{nameof(PublishHealth)}' Start");

            HealthBlock block = new HealthBlock()
            {
                Name = "TaskExecutorPool"
            };

            block.AddMatrix("ActiveProcessConsumersCount", _processConsumer.Count);
            foreach (var pair in _processConsumer)
            {
                HealthBlock taskExecutorHealth = new HealthBlock();
                taskExecutorHealth.AddMatrix("ProcessId", pair.Key);
                pair.Value.UpdateHealthStatus(taskExecutorHealth);

                block.AddMatrix($"Process_{pair.Key}", taskExecutorHealth);
            }
            health.Add(block);
            Logger.Trace($"HealthCheck '{nameof(PublishHealth)}' End");
        }
示例#9
0
        public static HealthBlock GetHealth()
        {
            HealthBlock block = new HealthBlock()
            {
                Name = "Memory"
            };

            try
            {
                var total     = GetTotalMemory();
                var available = GetAvailableMemory();

                block.AddMatrix("Total", total);
                block.AddMatrix("Available", available);
                block.AddMatrix("Remaining", total - available);
            }
            catch (Exception e)
            {
                block.AddMatrix("Error", e.Message);
            }
            return(block);
        }
            public override EquipmentBlock ReadJson(
                JsonReader reader,
                Type objectType,
                EquipmentBlock existingValue,
                bool hasExistingValue,
                JsonSerializer serializer)
            {
                var obj  = JObject.Load(reader);
                var type = obj[nameof(EquipmentBlock.Type)].ToObject <EquipmentType>();

                EquipmentBlock equipmentBlock;

                switch (type)
                {
                case EquipmentType.Energy:
                    equipmentBlock = new EnergyBlock();
                    break;

                case EquipmentType.Gun:
                    equipmentBlock = new GunBlock();
                    break;

                case EquipmentType.Engine:
                    equipmentBlock = new EngineBlock();
                    break;

                case EquipmentType.Health:
                    equipmentBlock = new HealthBlock();
                    break;

                default:
                    throw new NotSupportedException($"Unknown equipment {obj}");
                }

                serializer.Populate(obj.CreateReader(), equipmentBlock);
                return(equipmentBlock);
            }
示例#11
0
 public static void Add(this HealthMessage health, HealthBlock block)
 {
     health.Matrix.Add(block);
 }
示例#12
0
 public static void AddMatrix(this HealthBlock health, string matrix, object val)
 {
     health.Matrix.Add(new KeyValuePair <string, object>(matrix, val));
 }