コード例 #1
0
        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
            }));
        }
コード例 #2
0
        public async Task <ActionResult> ControlService(string node, string name, NodeService.Action serviceAction)
        {
            var n      = DashboardModule.GetNodeByName(node);
            var s      = n.GetService(name);
            var result = Json(await s.Update(serviceAction).ConfigureAwait(false));
            await n.DataProvider.PollAsync(true).ConfigureAwait(false);

            return(result);
        }
コード例 #3
0
        public ActionResult Node([DefaultValue(CurrentStatusTypes.Stats)] CurrentStatusTypes view, string node = null)
        {
            var vd = new NodeModel
            {
                CurrentNode       = DashboardModule.GetNodeByName(node),
                CurrentStatusType = view
            };

            return(View("Node", vd));
        }
コード例 #4
0
        public ActionResult InstanceSummary(string node, string type)
        {
            var n = DashboardModule.GetNodeByName(node);

            switch (type)
            {
            case "hardware":
                return(View("Node.Hardware", n));

            case "network":
                return(View("Node.Network", n));

            default:
                return(ContentNotFound("Unknown summary view requested"));
            }
        }