Exemplo n.º 1
0
        public void Notify(List <Service> services)
        {
            var message = new StringBuilder("services down");

            message.AppendLine("");
            var shouldBeSend = false;

            services.ForEach(service =>
            {
                var isNewContainsService = IsCheckingService(service);

                if (isNewContainsService)
                {
                    message.AppendLine(service.ToString());
                    message.AppendLine("");

                    CheckingServices.Add(service);
                    shouldBeSend = true;
                }
            });

            if (shouldBeSend)
            {
                Log.Information(message.ToString());
                Log.Information(new string('-', 30));
                To.ForEach(to =>
                {
                    SendMail(to.Host, From.Mail, Password, to.Mail, to.Port, "monitoring service", message.ToString());
                });
            }
            else
            {
                CheckingServices.Clear();
            }
        }
Exemplo n.º 2
0
        private bool IsCheckingService(Service newService)
        {
            bool isNew = true;

            CheckingServices.ForEach(service =>
            {
                if (service.Type == newService.Type &&
                    service.Monitor == newService.Monitor &&
                    service.Host == newService.Host &&
                    service.Error == newService.Error &&
                    service.Up == newService.Up &&
                    service.TimeStamp.ToString() == newService.TimeStamp.ToString())
                {
                    isNew = false;
                }
            });

            return(isNew);
        }