public override void RecordMessage(AlertLevel alertLevel, string collectorType, string category, MonitorStates oldState, MonitorStates newState, CollectorMessage collectorMessage) { string lastStep = ""; try { //rssWriteMutex.WaitOne(); if (rssDocument == null) { LoadRSSDocument(); } string lineTitle = rssConfig.LineTitle .Replace("%DateTime%", DateTime.Now.ToString("F")) .Replace("%AlertLevel%", alertLevel.ToString()) .Replace("%PreviousState%", oldState.ToString()) .Replace("%CurrentState%", newState.ToString()) .Replace("%CollectorName%", category) .Replace("%CollectorType%", collectorType); string lineCategory = rssConfig.LineCategory .Replace("%DateTime%", DateTime.Now.ToString("F")) .Replace("%AlertLevel%", alertLevel.ToString()) .Replace("%PreviousState%", oldState.ToString()) .Replace("%CurrentState%", newState.ToString()) .Replace("%CollectorName%", category) .Replace("%CollectorType%", collectorType); string lineDetails = rssConfig.LineDescription .Replace("%Details%", collectorMessage.HtmlText) .Replace("%DateTime%", DateTime.Now.ToString("F")) .Replace("%AlertLevel%", alertLevel.ToString()) .Replace("%PreviousState%", oldState.ToString()) .Replace("%CurrentState%", newState.ToString()) .Replace("%CollectorName%", category) .Replace("%CollectorType%", collectorType); rssDocument.Lines.Add( new InMemoryRSSDocumentLine() { Title = lineTitle, PubDate = DateTime.Now, //GUID = Guid.NewGuid().ToString(), Category = lineCategory, Description = lineDetails //.Replace("\r\n", "<br/>") } ); rssDocument.SaveRssDocument(); } catch (Exception ex) { throw new Exception("Error recording message in rss notifier\r\nLast step: " + lastStep, ex); } finally { //rssWriteMutex.ReleaseMutex(); } }
public ConfirmDialog(AlertLevel alertLevel, string message) { InitializeComponent(); DialogTitle = EnumLoader.GetEnumDesc(typeof(AlertLevel), alertLevel.ToString()); Message = message; DataContext = this; }
public override string GetUIValue(bool pure) { if (Value == AlertLevel.None) { return(LocalizeValue("None")); } int value; if ((Value.ToString().Contains(",")) || (int.TryParse(Value.ToString(), out value))) { return(LocalizeValue("Custom")); } else { return(base.GetUIValue(pure)); } }
public static Task SendMessage(HttpClient client, AlertLevel alertLevel, string messageToSend) { var dataPost = new { alertLevel = alertLevel.ToString(), message = messageToSend, }; var content = new StringContent(JsonConvert.SerializeObject(dataPost), Encoding.UTF8, "application/json"); content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); return client.PostAsync(SlackAlerterUrl, content); }
public override string ToString() { var result = new StringBuilder(time.ToString(_logTimestampFormat)); result.Append(String.Format(_logLevelFormat, level.ToString())); result.Append(String.Format(_logGroupFormat, groupName)); result.Append(content); if ((level >= AlertLevel.FatalError) && (String.IsNullOrEmpty(stackTrace))) { result.Append(String.Format(_logStackTrackeFormat, stackTrace)); } result.Append("\n"); return(result.ToString()); }
public AlertDto( string name, AlertLevel level, string comments, string chartUrl, DateTime? timestamp, string dashboardUrl) { DashboardUrl = dashboardUrl; Timestamp = GetTimestampString(timestamp); ChartUrl = chartUrl; Comments = comments; Level = level.ToString(); Name = name; }
public override void RecordMessage(AlertLevel alertLevel, string collectorType, string category, MonitorStates oldState, MonitorStates newState, CollectorMessage collectorMessage) { string lastStep = ""; try { smtpWriteMutex.WaitOne(); if (mailSettings.HostServer.Length == 0) { throw new Exception("SMTP host server not specified!"); } lastStep = "Setting up SMTP client details"; using (SmtpClient smtpClient = new SmtpClient()) { smtpClient.Host = mailSettings.HostServer; smtpClient.UseDefaultCredentials = mailSettings.UseDefaultCredentials; smtpClient.Port = mailSettings.Port; if (!mailSettings.UseDefaultCredentials) { lastStep = "Setting up non default credentials"; System.Net.NetworkCredential cr = new System.Net.NetworkCredential(); cr.Domain = mailSettings.Domain; cr.UserName = mailSettings.UserName; cr.Password = mailSettings.Password; smtpClient.Credentials = cr; } if (mailSettings.UseTLS) { smtpClient.EnableSsl = true; } MailMessage mailMessage = new MailMessage(mailSettings.FromAddress, mailSettings.ToAddress); lastStep = "Setting up mail body"; string body = mailSettings.Body .Replace("%Details%", mailSettings.IsBodyHtml ? collectorMessage.HtmlText : collectorMessage.PlainText) .Replace("%DateTime%", DateTime.Now.ToString("F")) .Replace("%AlertLevel%", alertLevel.ToString()) .Replace("%PreviousState%", oldState.ToString()) .Replace("%CurrentState%", newState.ToString()) .Replace("%CollectorName%", category) .Replace("%CollectorType%", collectorType); string subject = mailSettings.Subject .Replace("%DateTime%", DateTime.Now.ToString("F")) .Replace("%AlertLevel%", alertLevel.ToString()) .Replace("%PreviousState%", oldState.ToString()) .Replace("%CurrentState%", newState.ToString()) .Replace("%CollectorName%", category) .Replace("%CollectorType%", collectorType); mailMessage.Priority = (MailPriority)mailSettings.MailPriority; if (mailSettings.SenderAddress.Length > 0) { mailMessage.Sender = new MailAddress(mailSettings.SenderAddress); } if (mailSettings.ReplyToAddress.Length > 0) { mailMessage.ReplyToList.Add(mailSettings.ReplyToAddress); } mailMessage.Body = body; mailMessage.IsBodyHtml = mailSettings.IsBodyHtml; mailMessage.Subject = subject; lastStep = "Sending SMTP mail"; smtpClient.Send(mailMessage); } } catch (Exception ex) { throw new Exception("Error recording message in SMTP notifier\r\nLast step: " + lastStep, ex); } finally { smtpWriteMutex.ReleaseMutex(); } }