Exemple #1
0
        internal static void SendAlert(string url, PerfMonSettings settings, params MonitorFailure[] failures)
        {
            var body = $"SharePoint Performance Monitor detected performance issues\n\n{string.Join("\n\n\n", failures.Select(FormatFailure))}\n\nSee log output for details.";

            SendEmail(
                settings,
                $"[Alert] SharePoint performance issues detected on {url}",
                body
                );
        }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                var settings = PerfMonSettings.LoadSettings();

                if (args.Any(a => a.Equals("--testemail", StringComparison.InvariantCultureIgnoreCase)))
                {
                    TestEmail(settings);
                    return;
                }

                Parallel.ForEach(settings.Endpoints, (endpoint) => RunMonitor(settings, endpoint));
            }
            catch (Exception e)
            {
                LogWriter.WriteError($"Catastrophic failure: {e.Message} {e.StackTrace}");
            }
        }
Exemple #3
0
        internal static void SendEmail(PerfMonSettings settings, string title, string message)
        {
            try
            {
                var client = new SmtpClient();

                var msg = new MailMessage()
                {
                    IsBodyHtml = false,
                    Subject    = title,
                    Body       = message,
                    To         = { settings.NotificationRecipients },
                };

                client.Send(msg);
            }
            catch (Exception e)
            {
                LogWriter.WriteError($"Encountered error while sending e-mail: {e.Message}");
            }
        }
Exemple #4
0
        public FailureTracker(PerfMonSettings settings)
        {
            Settings = settings;

            NotificationInterval = new TimeSpan(0, 0, settings.NotificationIntervalSeconds);
        }
Exemple #5
0
 public PerfMonitor(PerfMonSettings settings, Endpoint endpoint)
 {
     Settings = settings;
     Tracker  = new FailureTracker(settings);
     Endpoint = endpoint;
 }
Exemple #6
0
 static void RunMonitor(PerfMonSettings settings, Endpoint endpoint) => new PerfMonitor(settings, endpoint).RunMonitor();
Exemple #7
0
        private static void TestEmail(PerfMonSettings settings)
        {
            Console.WriteLine("Testing e-mail settings...");

            EmailSender.SendEmail(settings, "Email Test", "It Works!\nIt Works!");
        }