Le modèle d’alerte peut être personnalisé en incluant les variables dynamiques qui sont tournées vers les valeurs système actuelles lors de l’envoi d’une alerte.
Syntaxe des modèles dynamiques
Dotcom-Monitor prend en charge les modèles dynamiques construits sur le moteur razor parsing de Microsoft.
Introduction à la syntaxe Razor peut être trouvé ici.
Dotcom-Monitor ObjectModel
Recherchez le diagramme de classes ObjectModel Dotcom-Monitor avec le code source des classes ci-dessous. Utilisez les attributs comme variables dynamiques dans le script De modèle d’alerte.
-
Dotcom-Monitor ObjectModel
-
MVTemplateModel (Plate-forme MetricsView)
// MetricsView Platform namespace Dotcom.Server.Notification.Templating { public class MVTemplateModel { public Response[] SessionResponses { get; } public string HTMLPageSnapshotLink { get ;} public string TraceLink { get ;} public string ScreenLink { get ;} public string WaterFallLink { get ;} public string OnlineReportLink { get ;} public string DMUserLink { get ;} public NotificationType Type { get; } public string AlertName { get { switch (Type) { case NotificationType.Error : return "ALERT"; case NotificationType.Uptime: return "ALL CLEAR"; case NotificationType.Test : return "TEST"; } return "Notification alert"; } } public NotificationType AlertType { get; } public DateTime ServerNotificationTime { get; } public DateTime MinResponseTime { get; } public DateTime MaxResponseTime { get; } public string Site_Name { get; } public string Contact_Full_Name { get; } public string Contact_Org_Name { get; } public string Contact_Title_Name { get; } public string Contact_Email_Addr { get; } public string UID { get; } public string OnlineReportCUID { get; } public DateTime Monitor_DateTime { get;} public DateTime Now { get; } public DateTime StartMonitorDowntime { get; } public DateTime StartMonitorUptime { get; } public TimeSpan DownTimeDuration { get ; } public string DownTimeDurationWellFomratted { get; } public Response FirstErrorResponse { get; }//FirstResponse public Response DownStateResponse { get; } public Response[] LastXResponses { get; } public bool HasTraceRoute(Response response) { } public string GetTraceLinkParam(long duration, int monitorId, DateTime startTime, string address) { } } }
-
SVTemplateModel (Plateforme ServerView)
// ServerView and WebView Platforms namespace Dotcom.Server.Notification.Templating { public class SVTemplateModel { public Response RootResponse { get; } public virtual long Response_Seq_IDForWaterfallLink { get { return RootResponse.ID; } } public string HTMLPageSnapshotLink { get ;} public string TraceLink { get ;} public string ScreenLink { get ;} public string WaterFallLink { get ;} public string OnlineReportLink { get ;} public string DMUserLink { get ;} public NotificationType Type { get; } public string AlertName { get { switch (Type) { case NotificationType.Error : return "ALERT"; case NotificationType.Uptime: return "ALL CLEAR"; case NotificationType.Test : return "TEST"; } return "Notification alert"; } } public NotificationType AlertType { get; } public DateTime ServerNotificationTime { get; } public DateTime MinResponseTime { get; } public DateTime MaxResponseTime { get; } public string Site_Name { get; } public string Contact_Full_Name { get; } public string Contact_Org_Name { get; } public string Contact_Title_Name { get; } public string Contact_Email_Addr { get; } public string UID { get; } public string OnlineReportCUID { get; } public DateTime Monitor_DateTime { get;} public DateTime Now { get; } public DateTime StartMonitorDowntime { get; } public DateTime StartMonitorUptime { get; } public TimeSpan DownTimeDuration { get ; } public string DownTimeDurationWellFomratted { get; } public Response FirstErrorResponse { get; }//FirstResponse public Response DownStateResponse { get; } public Response[] LastXResponses { get; } public bool HasTraceRoute(Response response) { } public string GetTraceLinkParam(long duration, int monitorId, DateTime startTime, string address) { } } }
-
UVTemplateModel (Plateforme UserView/BrowserView)
//UserView and BrowserView Platforms namespace Dotcom.Server.Notification.Templating { public class UVTemplateModel { public Response RootResponse { get; } public virtual long Response_Seq_IDForWaterfallLink { get { return RootResponse.ID; } } public string HTMLPageSnapshotLink { get ;} public string TraceLink { get ;} public string ScreenLink { get ;} public string WaterFallLink { get ;} public string OnlineReportLink { get ;} public string DMUserLink { get ;} public NotificationType Type { get; } public string AlertName { get { switch (Type) { case NotificationType.Error : return "ALERT"; case NotificationType.Uptime: return "ALL CLEAR"; case NotificationType.Test : return "TEST"; } return "Notification alert"; } } public NotificationType AlertType { get; } public DateTime ServerNotificationTime { get; } public DateTime MinResponseTime { get; } public DateTime MaxResponseTime { get; } public string Site_Name { get; } public string Contact_Full_Name { get; } public string Contact_Org_Name { get; } public string Contact_Title_Name { get; } public string Contact_Email_Addr { get; } public string UID { get; } public string OnlineReportCUID { get; } public DateTime Monitor_DateTime { get;} public DateTime Now { get; } public DateTime StartMonitorDowntime { get; } public DateTime StartMonitorUptime { get; } public TimeSpan DownTimeDuration { get ; } public string DownTimeDurationWellFomratted { get; } public Response FirstErrorResponse { get; }//FirstResponse public Response DownStateResponse { get; } public Response[] LastXResponses { get; } public bool HasTraceRoute(Response response) { } public string GetTraceLinkParam(long duration, int monitorId, DateTime startTime, string address) { } } }
-
réponse
namespace Dotcom.Reporting.Common { [Serializable] [System.Diagnostics.DebuggerDisplay("ID={ID};UUID={UUID};Level={Level};ParentID={ParentID};HasChild={HasChild};Start={Start,yyyy-MM-dd HH:mm:ss.fff}")] public class Response { public long ID; public long ParentID; public long UUID; public int Level; public const int SUMMARY = 1; public const int TASK = 2; public const int SMART_USER_STEP = 3; public const int SMART_USER_ACTION = 4; public const int SMART_CHANNEL = 5; public Device Device; public Task Task; public Monitor Monitor; public long[] OwnErrorCodes; public long[] ChildErrorCodes; public Error_v2[] OwnErrors; public Error_v2[] ChildErrors; public Error_v2[] AllErrors { get { return ReferenceEquals(OwnErrors,null)? ChildErrors: OwnErrors.Concat(ReferenceEquals(ChildErrors, null)?new Error_v2[0]:ChildErrors).ToArray(); } } public DateTime Start; public bool HasTrace; public bool HasTraceV2; public bool HasDnsTrace; public bool HasBody; public bool HasChild; public bool HasNotShadowChild; public bool HasVideo; public bool IsShadow; public string Uri; public string ContentType; public IEnumerable<Response> Children { get { } } public bool IsFail { get { return (!ReferenceEquals(OwnErrorCodes, null) && OwnErrorCodes.Length > 0) || (!ReferenceEquals(ChildErrorCodes, null) && ChildErrorCodes.Length > 0); } } public int Size; public int SV_DurationMS; public float MV_AggregatedValue;// MV_AvgLoadTime; public long MV_HitCount; public int UV_StepID; public int DnsTime; public int SSLTime; public int ConnectTime; public int RequestTime; public int FirstByteTime; public int ResponseTime; public IEnumerable<KeyValuePair<Dotcom.DetailTypes, string>> DetailInfoKeyed() { } public IEnumerable<Tuple<Dotcom.DetailTypes, string, bool>> DetailInfoXmlKeyed(DetailTypes[] baseType) { } public IEnumerable<KeyValuePair<Dotcom.DetailTypes, string>> DetailInfoKeyed(DetailTypes[] baseType) { } public IEnumerable<string> DetailInfo() { } public IEnumerable<string> DetailInfo(DetailTypes[] baseType) { } public bool IsPresentHitDetail(DetailTypes baseType) { } public object Tag; public virtual string Name { get { } } public string UVText { get { } } } }
-
appareil
namespace Dotcom.Reporting.Common { public enum PlatformType : byte { None = 0, ServerView = 1, LoadView =2 , MetrixView=3, UserView =4 , PrivateAgent=5, BrowserView=7 , MetricsCollector = 8, WebView = 12 } public enum DeviceState : byte { Active = 0, Postpone = 1, Deleted, CancelUpgrade, NoTasks, NotCompleted } [Serializable] public sealed class Device { public Device(int id) : base(id) { } public string Name { get; } public int ID { get; } public IList<Task> Tasks { get; } public PlatformType PlatformType { get; } public PlatformType PlatformTypeByTask { get; } public DeviceState DeviceState { get; } public string PackageName { get; } } }
-
Moniteur
namespace Dotcom.Reporting.Common { [Serializable] public class Monitor { public Monitor(int id) :base( id ){} public string Name { get; } public int ID { get; } } }
-
tâche
namespace Dotcom.Reporting.Common { public enum TaskState : byte { Active = 0, Deleted } public enum TaskTypes : byte { Unknown, TEMPTRAX, // obsolete, not supported HTTP, HTTPS, POP3, SMTP, Mail, // Email Round Trip Task FTP, Ping, DNS, Connection, // TelNet Task SOAP, Script, // Custom Script Task UDP, DNSBL, MEDIA, // Streaming Media Task SIP, SFTP, MV_HitCounter, // obsolete, not supported TraceRoute, Smart, // UserView Task Browser // BrowserView Task MV_PerformanceCounter, // MetricsView Windows Task Aggregated, // reserved, not supported yet ActiveSync, MV_ExtAPI, // MetricsView Custom Metrics Task MV_WinAPI, // obsolete, not supported MV_SmnpAPI, // MetricsView SNMP Collector Task MV_Import, // reserved, not supported MV_LinuxAPI // MetricsView Linux Task } [Serializable] public sealed class Task { public Task(int id) : base(id) { } public string Name { get; } public int ID { get; } public Device Device { get; } public string TaskType_Name { get; } public TaskTypes ClassTaskType { get; } public string ClassType { get { return ClassTaskType.ToString(); } } public TaskState TaskState { get; } public int TaskTimeout { get; } public int TimeOutUnit { get; } public IDictionary<string, object> AllParams { get; } public string GetParameterValue(string propertyName) { if (ReferenceEquals(AllParams, null) || !AllParams.ContainsKey(propertyName)) return string.Empty; object res = AllParams[propertyName]; return ReferenceEquals(res, null) ? string.Empty : res.ToString(); } public IEnumerable<string> Targets { get { switch(ClassTaskType) { case TaskTypes.Mail: yield return GetParameterValue("UrlPOP3"); yield return GetParameterValue("Url"); yield break; case TaskTypes.Script: yield return GetParameterValue("File"); yield break; case TaskTypes.ActiveSync: yield return GetParameterValue("Server"); yield break; case TaskTypes.DNS: yield return GetParameterValue("CheckUrl"); yield break; } yield return GetParameterValue("Url"); } } } }
Exemples de modèles d’alerte
Par exemple, créons un échantillon d’un modèle d’alerte de base :
{ "devicename" : "@Model.Site_Name", "taskName" : "@Model.FirstErrorResponse.Task.Name", "error" : "Error Type:@Model.FirstErrorResponse.AllErrors[0].ErrorType;Error Code:@Model.FirstErrorResponse.AllErrors[0].ErrorCode;Reason:@Model.FirstErrorResponse.AllErrors[0].Reason", "StartMonitorDowntime" : @(((long)Model.StartMonitorDowntime.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds)) }
Dans ce cas, l’alerte résultante aura la disposition suivante :
Subject: DOTCOM-MONITOR: Problem found in bbc.com device { "devicename" : "bbc.com", "taskName" : "http://bbc.com", "error" : "Error Type:Validation;Error Code:300;Reason:Task maximum timeout expired. Configured Timeout: 0.010 sec. Actual Response: 13.125 sec.", "StartMonitorDowntime" : 1558991488950 }
Vous trouverez ci-dessous d’autres exemples de tâches des différentes plateformes de surveillance.
-
UserView/BrowserView Device
. Modèle d’alerte TXT
Notification Type : @Model.AlertName Location : @Model.FirstErrorResponse.Monitor.Name StartMonitorDowntime : @Model.StartMonitorDowntime Time : @Model.RootResponse.Start Platform Type : @Model.RootResponse.Device.PlatformType Browser Type : @Model.RootResponse.Device.Tasks[0].GetParameterValue("BrowserEngine") Device Name : @Model.RootResponse.Device.Name Device State : @Model.RootResponse.Device.DeviceState View Online Report : @(Model.DMUserLink)/OnlineReporting.aspx?CUID=@Model.OnlineReportCUID View Waterfall Report : @(Model.DMUserLink)/DetailView.aspx?id=@Model.RootResponse.ID&Tab=TimeWaterChart&CUID=@Model.OnlineReportCUID View Video : @(Model.DMUserLink)/DetailView.aspx?id=@Model.RootResponse.ID&Tab=TimeVideoChart&CUID=@Model.OnlineReportCUID @if (Model.RootResponse.Device.PlatformType == Dotcom.Reporting.Common.PlatformType.BrowserView) { @:Url(target) : @Model.RootResponse.Device.Tasks[0].GetParameterValue("Url") } @{ Stack<Dotcom.Reporting.Common.Response> stack = new Stack<Dotcom.Reporting.Common.Response>(); stack.Push(Model.RootResponse); Dotcom.Reporting.Common.Response currentStepResp = null; } ERROR DETAILS @while (stack.Count > 0) { var current = stack.Pop(); if (current.Level == Dotcom.Reporting.Common.Response.SMART_USER_STEP) { currentStepResp=current; } if (current.HasChild) { foreach (var r in current.Children.Reverse()) { stack.Push(r); } } if (current.Level == 3) { continue; } if (current.OwnErrors != null) { if (Model.RootResponse.Device.PlatformType == Dotcom.Reporting.Common.PlatformType.UserView && currentStepResp!=null) { @:Step ID : @currentStepResp.UV_StepID } @:Element : @current.Name if (current.IsPresentHitDetail(Dotcom.DetailTypes.Content) || current.IsPresentHitDetail(Dotcom.DetailTypes.HtmlBody)) { @:Html Body Url : @(Model.DMUserLink)/site-traceroute.aspx?hitdetail=Content&id=@current.ID } @:Trace Url : @(Model.DMUserLink)/TraceRouteHistory.aspx?FP=@Uri.EscapeDataString(Model.GetTraceLinkParam(current.SV_DurationMS, current.Monitor.ID, current.Start, current.Uri)) if (current.OwnErrors.Any(error => error.ErrorType == Dotcom.ErrorTypes.DNS)) { @:DNS Trace Url : @(Model.DMUserLink)/DnsTree.aspx?id=@current.ID } @:Details: foreach (var error in current.OwnErrors) { @: @error.ErrorType (@error.ErrorCode): @Raw(error.Reason) } } }
alerte. Txt
Notification Type : ALERT Location : monitor 4_rum StartMonitorDowntime : 5/31/2019 3:59:50 PM Time : 5/31/2019 6:46:05 PM Platform Type : UserView Browser Type : Chrome Device Name : 3tasks Device State : Active View Online Report : https://user.dotcom-monitor.com/OnlineReporting.aspx?CUID=AAAAAAEAAABtYwAAALjVAzHl1ghghmHv+OXWCAAAAAB5BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= View Waterfall Report : https://user.dotcom-monitor.com/DetailView.aspx?id=1086785086&Tab=TimeWaterChart&CUID=AAAAAAEAAABtYwAAALjVAzHl1ghghmHv+OXWCAAAAAB5BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= View Video : https://user.dotcom-monitor.com/DetailView.aspx?id=1086785086&Tab=TimeVideoChart&CUID=AAAAAAEAAABtYwAAALjVAzHl1ghghmHv+OXWCAAAAAB5BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= ERROR DETAILS Step ID : 1 Element : http://www.tutrtret.by/ Trace Url : https://user.dotcom-monitor.com/TraceRouteHistory.aspx?FP=0AAAAAAAAAAEAAAAcDDDOPjl1ggPd3d3LnR1dHJ0cmV0LmJ5cNaHbvjl1ggBAAAABAAAAAAAAAA%3D DNS Trace Url : https://user.dotcom-monitor.com/DnsTree.aspx?id=1086785089 Details: DNS (12007): The host name 'www.tutrtret.by' could not be resolved.
-
Dispositif ServerView
. Modèle d’alerte TXT
Notification Type : @Model.AlertName Location : @Model.FirstErrorResponse.Monitor.Name StartMonitorDowntime : @Model.StartMonitorDowntime Time : @Model.RootResponse.Start Platform Type : @Model.RootResponse.Device.PlatformType Device Name : @Model.RootResponse.Device.Name Device State : @Model.RootResponse.Device.DeviceState View Online Report : @(Model.DMUserLink)/OnlineReporting.aspx?CUID=@Model.OnlineReportCUID View Waterfall Report : @(Model.DMUserLink)/DetailView.aspx?id=@Model.RootResponse.ID&Tab=TimeWaterChart&CUID=@Model.OnlineReportCUID @{ Stack<Dotcom.Reporting.Common.Response> stack = new Stack<Dotcom.Reporting.Common.Response>(); stack.Push(Model.RootResponse); } ERROR DETAILS @while (stack.Count > 0) { var current = stack.Pop(); if (current.HasChild) { foreach (var r in current.Children.Reverse()) { stack.Push(r); } } if (current.Level == Dotcom.Reporting.Common.Response.TASK) { @:Task Name : @current.Task.Name @:Task Type : @current.Task.ClassType @:Url(target) : @string.Join(";",current.Task.Targets) } if (current.OwnErrors != null) { @:Element : @current.Name if (current.IsPresentHitDetail(Dotcom.DetailTypes.Content) || current.IsPresentHitDetail(Dotcom.DetailTypes.HtmlBody)) { @:Html Body Url : @(Model.DMUserLink)/site-traceroute.aspx?hitdetail=Content&id=@current.ID } @:Trace Url : @(Model.DMUserLink)/TraceRouteHistory.aspx?FP=@Uri.EscapeDataString(Model.GetTraceLinkParam(current.SV_DurationMS, current.Monitor.ID, current.Start, current.Uri)) if (current.OwnErrors.Any(error => error.ErrorType == Dotcom.ErrorTypes.DNS)) { @:DNS Trace Url : @(Model.DMUserLink)/DnsTree.aspx?id=@current.ID } @:Details: foreach (var error in current.OwnErrors) { @: @error.ErrorType (@error.ErrorCode): @Raw(error.Reason) } } }
alerte. Txt
Notification Type : ALERT Location : monitor 1_muskat StartMonitorDowntime : 6/3/2019 1:14:26 PM Time : 6/3/2019 3:01:15 PM Platform Type : WebView Device Name : Dynamic_get Device State : Active View Online Report : https://user.dotcom-monitor.com/OnlineReporting.aspx?CUID=AQAAAO4zAAAAAAAAAMDFXXPn1giQPlYGNejWCAAAAAB5BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= View Waterfall Report : https://user.dotcom-monitor.com/DetailView.aspx?id=-158664977&Tab=TimeWaterChart&CUID=AQAAAO4zAAAAAAAAAMDFXXPn1giQPlYGNejWCAAAAAB5BwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= ERROR DETAILS Task Name : http://user.dotcom-monitor.com/Wizard Task Type : HTTPS Url(target) : http://user.dotcom-monitor.com/Wizard?pid=sss Element : http://user.dotcom-monitor.com/Wizard Html Body Url : https://user.dotcom-monitor.com/site-traceroute.aspx?hitdetail=Content&id=1087506754 Trace Url : https://user.dotcom-monitor.com/TraceRouteHistory.aspx?FP=AgAAAAAAAAABAAAAkD2kQTTo1ggXdXNlci5kb3Rjb20tbW9uaXRvci5jb22wdEl3NOjWCAEAAAABAAAAAAAAAA%3D%3D Details: HTTP (404): Not Found.
-
Dispositif MetricsView
. Modèle d’alerte TXT
Notification Type : @Model.AlertName StartMonitorDowntime : @Model.StartMonitorDowntime Time : @Model.SessionResponses[0].Start Platform Type : @Model.SessionResponses[0].Device.PlatformType Device Name : @Model.SessionResponses[0].Device.Name Device State : @Model.SessionResponses[0].Device.DeviceState View Online Report : @(Model.DMUserLink)/OnlineReporting.aspx?CUID=@Model.OnlineReportCUID ERROR DETAILS @foreach(var current in Model.SessionResponses) { @:Task Name : @current.Task.Name @:Task Type : @current.Task.ClassType @:Element : @current.Name if (current.Task.ClassTaskType == Dotcom.Reporting.Common.TaskTypes.MV_PerfomanceCounter) { @:Category : @current.Task.GetParameterValue("Category") @:Instance : @current.Task.GetParameterValue("Instance") @:CounterName : @current.Task.GetParameterValue("CounterName") @:Machine : @current.Task.GetParameterValue("Machine") @:MachineAddress : @current.Task.GetParameterValue("MachineAddress") } if (current.OwnErrors != null) { @:Details: foreach (var error in current.OwnErrors) { @: @error.ErrorType (@error.ErrorCode): @Raw(error.Reason) } } }
alerte. Txt
Notification Type : ALERT StartMonitorDowntime : 6/3/2019 3:16:23 PM Time : 6/3/2019 3:48:54 PM Platform Type : MetrixView Device Name : 12. test_mv_207.250.235.79 Device State : Active View Online Report : https://user.dotcom-monitor.com/OnlineReporting.aspx?CUID=AQAAANEiAAAAAAAAAMDFXXPn1gjgUiWuO+jWCAAAAABtBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtMYXN0MjRIb3VycwAAAAA= ERROR DETAILS Task Name : System - Local, Avg, 50_100 Task Type : MV_PerfomanceCounter Element : System - Local, Avg, 50_100 Category : System Instance : CounterName : Processes Machine : Remote MachineAddress : localhost Details: Validation (112): Maximum threshold is reached.
Pour plus d’exemples ou de questions réelles, créez un billet.