public async Task <JsonResult> PollCPU(string id = null, string node = null)
        {
            var n = id.HasValue() ? DashboardModule.GetNodeById(id) : DashboardModule.GetNodeByName(node);

            if (n == null)
            {
                return(JsonNotFound());
            }

            var data = await n.GetCPUUtilization().ConfigureAwait(false);

            if (data?.Data == null)
            {
                return(JsonNotFound());
            }

            var total = data.Data.Find(c => c.Name == "Total");

            return(Json(new
            {
                duration = data.Duration.TotalMilliseconds,
                cores = data.Data.Where(c => c != total).Select(c => new
                {
                    name = c.Name,
                    utilization = c.Utilization
                }),
                total = total?.Utilization ?? 0
            }));
        }
Beispiel #2
0
        public async Task <ActionResult> NodeGraph(string nodeId, string type, string subId)
        {
            var n  = DashboardModule.GetNodeById(nodeId);
            var vd = new NodeGraphModel
            {
                Node = n,
                Type = type
            };

            if (n != null)
            {
                switch (type)
                {
                case NodeGraphModel.KnownTypes.Live:
                    await PopulateModel(vd, NodeGraphModel.KnownTypes.CPU, subId).ConfigureAwait(false);
                    await PopulateModel(vd, NodeGraphModel.KnownTypes.Memory, subId).ConfigureAwait(false);

                    //await PopulateModel(vd, NodeGraphModel.KnownTypes.Network, subId);
                    break;

                case NodeGraphModel.KnownTypes.CPU:
                case NodeGraphModel.KnownTypes.Memory:
                case NodeGraphModel.KnownTypes.Network:
                case NodeGraphModel.KnownTypes.Volume:
                case NodeGraphModel.KnownTypes.VolumePerformance:
                    await PopulateModel(vd, type, subId).ConfigureAwait(false);

                    break;
                }
            }

            return(View("Node.Graph", vd));
        }
Beispiel #3
0
        public async Task <ActionResult> VolumeSpark(string direction, string id, string iid)
        {
            MiniProfiler.Stop(true);
            var volume = DashboardModule.GetNodeById(id)?.GetVolume(iid);

            if (volume == null)
            {
                return(ContentNotFound());
            }
            var points = await volume.GetPerformanceUtilization(SparkStart, null, SparkPoints).ConfigureAwait(false);

            if (points.Count == 0)
            {
                return(EmptySparkSVG());
            }

            Func <DoubleGraphPoint, double> getter = p => p.Value.GetValueOrDefault(0);

            if (direction == "write")
            {
                getter = p => p.BottomValue.GetValueOrDefault(0);
            }

            return(SparkSVG(points, Convert.ToInt64(points.Max(getter)), p => getter(p)));
        }
        public async Task <ActionResult> NetworkSpark(string id)
        {
            var node = DashboardModule.GetNodeById(id);

            if (node == null)
            {
                return(ContentNotFound());
            }
            var points = await node.GetNetworkUtilization(SparkStart, null, SparkPoints).ConfigureAwait(false);

            return(points.Count == 0
                ? EmptySparkSVG()
                : SparkSVG(points, Convert.ToInt64(points.Max(p => p.Value + p.BottomValue).GetValueOrDefault()), p => (p.Value + p.BottomValue).GetValueOrDefault()));
        }
        public async Task <ActionResult> MemorySpark(string id)
        {
            var node = DashboardModule.GetNodeById(id);

            if (node?.TotalMemory == null)
            {
                return(ContentNotFound($"Could not determine total memory for '{id}'"));
            }
            var points = await node.GetMemoryUtilization(SparkStart, null, SparkPoints).ConfigureAwait(false);

            return(points.Count == 0
                ? EmptySparkSVG()
                : SparkSVG(points, Convert.ToInt64(node.TotalMemory.GetValueOrDefault()), p => p.Value.GetValueOrDefault()));
        }
        public async Task <ActionResult> CPUSparkSvg(string id)
        {
            var node = DashboardModule.GetNodeById(id);

            if (node == null)
            {
                return(ContentNotFound());
            }
            var points = await node.GetCPUUtilization(SparkStart, null, SparkPoints).ConfigureAwait(false);

            return(points.Count == 0
                ? EmptySparkSVG()
                : SparkSVG(points, 100, p => p.Value.GetValueOrDefault()));
        }
Beispiel #7
0
        public async Task <ActionResult> MemoryJson(string id, long?start = null, long?end = null, bool?summary = false)
        {
            var node = DashboardModule.GetNodeById(id);

            if (node == null)
            {
                return(JsonNotFound());
            }
            var data = await MemoryData(node, start, end, summary).ConfigureAwait(false);

            if (data == null)
            {
                return(JsonNotFound());
            }

            return(Json(data));
        }
Beispiel #8
0
        public async Task <ActionResult> VolumePerformanceJson(string id, string iid, long?start = null, long?end = null, bool?summary = false)
        {
            var iface = DashboardModule.GetNodeById(id)?.GetVolume(iid);

            if (iface == null)
            {
                return(JsonNotFound());
            }
            var data = await VolumePerformanceData(iface, start, end, summary).ConfigureAwait(false);

            if (data == null)
            {
                return(JsonNotFound());
            }

            return(Json(data));
        }
        public async Task <ActionResult> InterfaceSpark(string direction, string id, string iid)
        {
            var iface = DashboardModule.GetNodeById(id)?.GetInterface(iid);

            if (iface == null)
            {
                return(ContentNotFound());
            }
            var points = await iface.GetUtilization(SparkStart, null, SparkPoints).ConfigureAwait(false);

            if (points.Count == 0)
            {
                return(EmptySparkSVG());
            }

            Func <DoubleGraphPoint, double> getter = p => p.Value.GetValueOrDefault(0);

            if (direction == "out")
            {
                getter = p => p.BottomValue.GetValueOrDefault(0);
            }

            return(SparkSVG(points, Convert.ToInt64(points.Max(getter)), p => getter(p)));
        }