Ejemplo n.º 1
0
        public override void Run(List <AntminerStatus> antminerStatuses)
        {
            foreach (var ant in antminerStatuses.Where(x => x.Status.Equals("Alive") && x.AsicStatus.Contains("x") && !AlertedAntIds.Contains(x.Id)))
            {
                var restartMessage = "Miner was successfully restarted. You will be notified if restart removes Xs.";
                try
                {
                    AntminerConnector.Restart(IPAddress.Parse(ant.IpAddress));
                }
                catch (Exception ex)
                {
                    restartMessage = string.Format("An error occured while attempting to restart miner: {0}", ex.Message);
                }

                EmailService.SendAlertEmail(string.Format(EmailSubject, ant.Name, ant.IpAddress),
                                            string.Format(EmailMessage, ant.Name, ant.IpAddress, DateTime.Now.ToString("h:mm:ss tt"), restartMessage));
                AlertedAntIds.Add(ant.Id);
            }

            foreach (var ant in antminerStatuses.Where(ant => ant.Status.Equals("Alive") && AlertedAntIds.Contains(ant.Id) && !ant.AsicStatus.Contains("x")))
            {
                EmailService.SendAlertEmail(string.Format(UpEmailSubject, ant.Name, ant.IpAddress), string.Format(UpEmailMessage, ant.Name, ant.IpAddress, DateTime.Now.ToString("h:mm:ss tt")));
                AlertedAntIds.Remove(ant.Id);
            }
        }
Ejemplo n.º 2
0
        public override void Run(List <AntminerStatus> antminerStatuses)
        {
            foreach (var ant in antminerStatuses.Where(x => !AlertedAntIds.Contains(x.Id) && x.HighestTemp > OverTempature))
            {
                EmailService.SendAlertEmail(string.Format(EmailSubject, ant.Name, ant.IpAddress), string.Format(EmailMessage, ant.Name, ant.IpAddress, ant.HighestTemp, DateTime.Now.ToString("h:mm:ss tt")));
                AlertedAntIds.Add(ant.Id);
            }

            foreach (var id in (from antId in AlertedAntIds
                                let ant = antminerStatuses.SingleOrDefault(x => x.Id.Equals(antId))
                                          where ant != null
                                          where ant.HighestTemp <= OverTempature
                                          select antId).ToList())
            {
                AlertedAntIds.Remove(id);
            }
        }