예제 #1
0
        public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token)
        {
            var client = _clientFactory.Create(miner);

            await client.RestartMinerAsync();

            return(AlertActionResult.Complete(actionDefinition.Name, $"Restarting miner {miner.Name}"));
        }
        public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token)
        {
            var action = (WebHookAlertActionDefinition)actionDefinition;
            var client = _clientFactory();

            if (action.Body == null)
            {
                await client.PostAsync(action.Url, null, token);
            }
            else
            {
                await client.PostAsync(action.Url, new StringContent(action.Body, Encoding.UTF8, "application/json"), token);
            }

            return(AlertActionResult.Complete(actionDefinition.Name, "Sent Web Hook"));
        }
예제 #3
0
        public async Task <AlertActionResult> ExecuteActionAsync(AlertActionDefinition actionDefinition, AlertDefinition alertDefinition, Miner miner, AlertMetadata metadata, CancellationToken token)
        {
            var action = (DisableGpuAlertActionDefinition)actionDefinition;
            var client = _clientFactory.Create(miner);

            if (action.DisableAll)
            {
                await client.SetGpuModeAsync(GpuMode.Disabled);

                return(AlertActionResult.Complete(action.Name, $"Sent control message to disabled GPUs on miner {miner.Name}"));
            }
            if (action.DisableAffected && metadata?.GpuIndex != null)
            {
                await client.SetGpuModeAsync((int)metadata.GpuIndex, GpuMode.Disabled);

                return(AlertActionResult.Complete(action.Name, $"Sent control message to disable GPU {metadata.GpuIndex + 1} on miner {miner.Name}"));
            }
            return(AlertActionResult.Skip(action.Name, "Unable to determine which GPU to disable"));
        }
예제 #4
0
 public bool ShouldExecute(AlertActionDefinition actionDefinition, Miner miner)
 {
     return(miner.CollectorId == null && actionDefinition.Type == AlertActionType.DisableGpu);
 }
 public bool ShouldExecute(AlertActionDefinition actionDefinition, Miner miner)
 {
     return(actionDefinition.Type == AlertActionType.WebHook);
 }