Example #1
0
        public async Task <ActionResult> CPUSpark(string id)
        {
            var chart      = GetSparkChart();
            var dataPoints = await DashboardData.GetCPUUtilization(id,
                                                                   start : DateTime.UtcNow.AddHours(-SparkHours),
                                                                   end : null,
                                                                   pointCount : (int)chart.Width.Value);

            if (dataPoints == null)
            {
                return(ContentNotFound());
            }

            var area   = GetSparkChartArea(100);
            var avgCPU = GetSparkSeries("Avg Load");

            chart.Series.Add(avgCPU);

            foreach (var mp in dataPoints)
            {
                if (mp.AvgLoad.HasValue)
                {
                    avgCPU.Points.Add(new DataPoint(mp.DateTime.ToOADate(), mp.AvgLoad.Value));
                }
            }

            chart.ChartAreas.Add(area);

            return(chart.ToResult());
        }
Example #2
0
        public async Task <ActionResult> CPUJson(string id, long start, long end, bool?summary = false)
        {
            var nodePoints = await DashboardData.GetCPUUtilization(id, start.ToDateTime(), end.ToDateTime(), 1000);

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

            return(Json(new
            {
                points = nodePoints.Select(p => new
                {
                    date = p.DateTime.ToEpochTime(true),
                    value = p.AvgLoad ?? 0
                }),
                summary = summary.GetValueOrDefault(false) ? (await DashboardData.GetCPUUtilization(id, null, null, 2000)).Select(p => new
                {
                    date = p.DateTime.ToEpochTime(true),
                    value = p.AvgLoad ?? 0
                }) : null,
                builds = !BuildStatus.HasCachePrimed ? null : GetBuilds(id, start, end).Select(b => new
                {
                    date = b.StartDate.ToEpochTime(true),
                    text = GetFlagTooltip(b),
                    link = b.WebUrl
                })
            }));
        }