Exemplo n.º 1
0
        public ServerTile(
            DrawingElement drawing,
            ServerNode server,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Server",
                server.Healthy == false ? "server_unhealthy" : "server_healthy",
                server.Disabled,
                2,
                server.Name)
        {
            var ipAddresses = server.IpAddresses;

            LinkUrl = "/ui/node?name=" + server.Name;

            var details = new List <string>();

            if (server.Healthy.HasValue)
            {
                if (server.Healthy.Value)
                {
                    details.Add("Health check passed");
                }
                else
                {
                    details.Add("Health check failed");
                    AddUnhealthyReason(server.UnhealthyReason, details);
                }
            }

            details.Add("Host " + (server.DomainName ?? string.Empty));
            details.Add("Port " + (server.Port.HasValue ? server.Port.Value.ToString() :  "pass-through"));
            details.Add("Connection timeout " + server.ConnectionTimeout + (server.ReuseConnections ? " then reuse" : ""));
            details.Add("Response timeout " + server.ResponseTimeout);
            details.Add("Read timeout " + server.ReadTimeoutMs + "ms");
            details.Add("Health check " +
                        server.HealthCheckMethod + (server.HealthCheckPort == 443 ? " https": " http") + "://" +
                        (server.HealthCheckHost ?? server.DomainName) +
                        ((server.HealthCheckPort == 80 || server.HealthCheckPort == 443) ? "" : ":" + server.HealthCheckPort) +
                        server.HealthCheckPath + " returns " + string.Join(" or ", server.HealthCheckCodes));

            AddDetails(details, null, server.Disabled ? "disabled" : string.Empty);

            if (ipAddresses != null)
            {
                _ipAddressDrawings = new IpAddressDrawing[ipAddresses.Length];

                for (var i = 0; i < ipAddresses.Length; i++)
                {
                    var ipAddress = ipAddresses[i];
                    _ipAddressDrawings[i] = new IpAddressDrawing(drawing, ipAddress);
                }

                foreach (var outputDrawing in _ipAddressDrawings)
                {
                    AddChild(outputDrawing);
                }
            }
        }
Exemplo n.º 2
0
        public RouterTile(
            DrawingElement drawing,
            RoutingNode router,
            DashboardConfiguration.NodeConfiguration nodeConfiguration,
            TrafficIndicatorConfiguration trafficIndicatorConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Router",
                "router",
                router.Offline,
                2,
                router.Name)
        {
            _drawing = drawing;
            _router  = router;
            _trafficIndicatorThresholds = trafficIndicatorConfiguration.Thresholds;

            LinkUrl = "/ui/node?name=" + router.Name;

            var details = new List <string>();

            if (router.Outputs != null)
            {
                _outputDrawings = router.Outputs
                                  .Select(o => new RouterOutputDrawing(drawing, o, o.RouteTo, null, router.Offline || o.Disabled))
                                  .ToArray();

                foreach (var outputDrawing in _outputDrawings)
                {
                    AddChild(outputDrawing);
                }
            }

            AddDetails(details, null, router.Offline ? "disabled" : string.Empty);
        }
Exemplo n.º 3
0
 public LeastConnectionsStats(
     DrawingElement drawing,
     LeastConnectionsNode leastConnections,
     DashboardConfiguration dashboardConfiguration,
     DashboardConfiguration.NodeConfiguration nodeConfiguration)
     : base(
         drawing,
         leastConnections,
         dashboardConfiguration,
         new[] { new LeastConnectionsTile(drawing, leastConnections, nodeConfiguration, dashboardConfiguration.TrafficIndicator) })
 {
 }
Exemplo n.º 4
0
 public StickySessionStats(
     DrawingElement drawing,
     StickySessionNode stickySession,
     DashboardConfiguration dashboardConfiguration,
     DashboardConfiguration.NodeConfiguration nodeConfiguration)
     : base(
         drawing,
         stickySession,
         dashboardConfiguration,
         new[] { new StickySessionTile(drawing, stickySession, nodeConfiguration, dashboardConfiguration.TrafficIndicator) })
 {
 }
Exemplo n.º 5
0
 public RoundRobinStats(
     DrawingElement drawing,
     RoundRobinNode roundRobin,
     DashboardConfiguration dashboardConfiguration,
     DashboardConfiguration.NodeConfiguration nodeConfiguration)
     : base(
         drawing,
         roundRobin,
         dashboardConfiguration,
         new[] { new RoundRobinTile(drawing, roundRobin, nodeConfiguration, dashboardConfiguration.TrafficIndicator) })
 {
 }
Exemplo n.º 6
0
 public InternalRequestTile(
     DrawingElement drawing,
     InternalNode internalRequest,
     DashboardConfiguration.NodeConfiguration nodeConfiguration)
     : base(
         drawing,
         nodeConfiguration?.Title ?? "Internal",
         "public",
         internalRequest.Offline,
         2,
         internalRequest.Name)
 {
     LinkUrl = "/ui/node?name=" + internalRequest.Name;
 }
Exemplo n.º 7
0
 public RoundRobinTile(
     DrawingElement drawing,
     RoundRobinNode roundRobin,
     DashboardConfiguration.NodeConfiguration nodeConfiguration,
     TrafficIndicatorConfiguration trafficIndicatorConfiguration)
     : base(
         drawing,
         roundRobin,
         trafficIndicatorConfiguration,
         nodeConfiguration?.Title ?? "Round robin",
         "round_robin",
         null,
         false,
         false,
         true)
 {
 }
Exemplo n.º 8
0
        public CustomLogTile(
            DrawingElement drawing,
            CustomLogNode customLog,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Custom log",
                "logging",
                customLog.Offline,
                2,
                customLog.Name)
        {
            _drawing   = drawing;
            _customLog = customLog;

            LinkUrl = "/ui/node?name=" + customLog.Name;

            var details = new List <string>
            {
                $"Path {customLog.Directory}{customLog.FileNamePrefix}*.txt",
                $"Keep for {customLog.MaximumLogFileAge}",
                $"Format {customLog.ContentType}",
            };

            details.Add(customLog.Detailed ? "Multiple lines" : "Single line");

            if (customLog.Methods != null && customLog.Methods.Length > 0)
            {
                details.AddRange(customLog.Methods.Select(m => "Log " + m + " requests"));
            }
            else
            {
                details.Add("Log all requests");
            }

            if (customLog.StatusCodes != null && customLog.StatusCodes.Length > 0)
            {
                details.AddRange(customLog.StatusCodes.Select(s => "Log " + s + " responses"));
            }
            else
            {
                details.Add("Log all responses");
            }

            AddDetails(details, null, customLog.Offline ? "disabled" : string.Empty);
        }
Exemplo n.º 9
0
 public LeastConnectionsTile(
     DrawingElement drawing,
     LeastConnectionsNode leastConnections,
     DashboardConfiguration.NodeConfiguration nodeConfiguration,
     TrafficIndicatorConfiguration trafficIndicatorConfiguration)
     : base(
         drawing,
         leastConnections,
         trafficIndicatorConfiguration,
         nodeConfiguration?.Title ?? "Least connections",
         "least_connections",
         null,
         true,
         false,
         true)
 {
 }
Exemplo n.º 10
0
        public CorsTile(
            DrawingElement drawing,
            CorsNode corsNode,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "CORS/CORB",
                "cors",
                corsNode.Offline,
                2,
                corsNode.Name)
        {
            _drawing  = drawing;
            _corsNode = corsNode;

            LinkUrl = "/ui/node?name=" + corsNode.Name;

            var details = new List <string>();

            details.Add("For " + (corsNode.WebsiteOrigin ?? string.Empty));
            details.Add("Allow " + (corsNode.AllowedOrigins ?? string.Empty));

            if (!string.IsNullOrEmpty(corsNode.AllowedMethods))
            {
                details.Add("Allow " + corsNode.AllowedMethods);
            }

            if (!string.IsNullOrEmpty(corsNode.AllowedHeaders))
            {
                details.Add("Allow " + corsNode.AllowedHeaders);
            }

            if (corsNode.AllowCredentials)
            {
                details.Add("Allow credentials");
            }

            if (!string.IsNullOrEmpty(corsNode.ExposedHeaders))
            {
                details.Add("Expose " + corsNode.ExposedHeaders);
            }

            AddDetails(details, null, _corsNode.Offline ? "disabled" : string.Empty);
        }
Exemplo n.º 11
0
 public StickySessionTile(
     DrawingElement drawing,
     StickySessionNode stickySession,
     DashboardConfiguration.NodeConfiguration nodeConfiguration,
     TrafficIndicatorConfiguration trafficIndicatorConfiguration)
     : base(
         drawing,
         stickySession,
         trafficIndicatorConfiguration,
         nodeConfiguration?.Title ?? "Sticky session",
         "sticky_session",
         new List <string>
 {
     "Cookie: " + stickySession.SessionCookie,
     "Lifetime: " + stickySession.SessionDuration
 },
         true,
         true,
         true)
 {
 }
Exemplo n.º 12
0
        public TransformTile(
            DrawingElement drawing,
            TransformNode transform,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Transform",
                "transform",
                transform.Offline,
                2,
                transform.Name)
        {
            _drawing   = drawing;
            _transform = transform;

            LinkUrl = "/ui/node?name=" + transform.Name;

            if (!string.IsNullOrEmpty(transform.Description))
            {
                var details = transform.Description.Split('\n').ToList();
                AddDetails(details, null, transform.Offline ? "disabled" : string.Empty);
            }
        }
Exemplo n.º 13
0
        public ChangeLogFilterTile(
            DrawingElement drawing,
            ChangeLogFilterNode changeLogFilter,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Log level",
                "logging",
                changeLogFilter.Offline,
                2,
                changeLogFilter.Name)
        {
            _drawing         = drawing;
            _changeLogFilter = changeLogFilter;

            LinkUrl = "/ui/node?name=" + changeLogFilter.Name;

            var details = new List <string>();

            if (changeLogFilter.MaximumLogLevel == 0)
            {
                details.Add("Disable logging");
            }
            else
            {
                details.Add($"Log level {changeLogFilter.MaximumLogLevel}");
                if (changeLogFilter.LogTypes == null || changeLogFilter.LogTypes.Length == 0)
                {
                    details.Add("All message types");
                }
                else
                {
                    details.AddRange(changeLogFilter.LogTypes.Select(t => "Log " + t.ToString()));
                }
            }
            AddDetails(details, null, changeLogFilter.Offline ? "disabled" : string.Empty);
        }
Exemplo n.º 14
0
        public ResponseTile(
            DrawingElement drawing,
            ResponseNode response,
            DashboardConfiguration.NodeConfiguration nodeConfiguration)
            : base(
                drawing,
                nodeConfiguration?.Title ?? "Response",
                "responder",
                response.Offline,
                2,
                response.Name)
        {
            LinkUrl = "/ui/node?name=" + response.Name;

            var details = new List <string>();

            details.Add(response.StatusCode + " " + response.ReasonPhrase);

            if (response.HeaderNames != null)
            {
                for (var i = 0; i < response.HeaderNames.Length; i++)
                {
                    details.Add(response.HeaderNames[i] + ": " + response.HeaderValues[i]);
                }
            }

            if (!string.IsNullOrEmpty(response.ContentFile))
            {
                details.Add("[" + response.ContentFile + "]");
            }
            else if (!string.IsNullOrWhiteSpace(response.Content))
            {
                details.Add(response.Content);
            }

            AddDetails(details, null, response.Offline ? "disabled" : string.Empty);
        }
Exemplo n.º 15
0
        public DashboardNodeDrawing(
            DashboardConfiguration dashboardConfiguration,
            DashboardConfiguration.NodeConfiguration nodeDrawingConfig,
            INode node)
            : base(null, nodeDrawingConfig?.Title ?? (node.Name + " Node"), "drawing", node.Disabled, 1)
        {
            LeftMargin   = 20;
            RightMargin  = 20;
            TopMargin    = 20;
            BottomMargin = 20;

            DrawingElement nodeDrawing;

            var internalRequest  = node as InternalNode;
            var response         = node as ResponseNode;
            var roundRobin       = node as RoundRobinNode;
            var router           = node as RoutingNode;
            var server           = node as ServerNode;
            var stickySession    = node as StickySessionNode;
            var transform        = node as TransformNode;
            var leastConnections = node as LeastConnectionsNode;
            var cors             = node as CorsNode;
            var changeLogFilter  = node as ChangeLogFilterNode;
            var customLog        = node as CustomLogNode;

            if (internalRequest != null)
            {
                nodeDrawing = new InternalRequestTile(this, internalRequest, nodeDrawingConfig);
            }
            else if (response != null)
            {
                nodeDrawing = new ResponseTile(this, response, nodeDrawingConfig);
            }
            else if (roundRobin != null)
            {
                nodeDrawing = new RoundRobinStats(this, roundRobin, dashboardConfiguration, nodeDrawingConfig);
            }
            else if (router != null)
            {
                nodeDrawing = new RouterStats(this, router, dashboardConfiguration);
            }
            else if (server != null)
            {
                nodeDrawing = new ServerStats(this, server, dashboardConfiguration);
            }
            else if (stickySession != null)
            {
                nodeDrawing = new StickySessionStats(this, stickySession, dashboardConfiguration, nodeDrawingConfig);
            }
            else if (transform != null)
            {
                nodeDrawing = new TransformTile(this, transform, nodeDrawingConfig);
            }
            else if (leastConnections != null)
            {
                nodeDrawing = new LeastConnectionsStats(this, leastConnections, dashboardConfiguration, nodeDrawingConfig);
            }
            else if (cors != null)
            {
                nodeDrawing = new CorsTile(this, cors, nodeDrawingConfig);
            }
            else if (changeLogFilter != null)
            {
                nodeDrawing = new ChangeLogFilterTile(this, changeLogFilter, nodeDrawingConfig);
            }
            else if (customLog != null)
            {
                nodeDrawing = new CustomLogTile(this, customLog, nodeDrawingConfig);
            }
            else
            {
                nodeDrawing = new NodeTile(this, node.Name, "", true);
            }

            nodeDrawing.Left = 10;
            nodeDrawing.Top  = 30;

            AddChild(nodeDrawing);
        }