Ejemplo n.º 1
0
        public ActionResult <ServerInfo> GetServerInfo(string key)
        {
            if (string.Compare(key, statsKey) != 0)
            {
                return(BadRequest());
            }
            var ret  = new ServerInfo();
            var file = new FileInfo(typeof(StateController).Assembly.Location);

            ret.BuiltTime         = file.LastWriteTime;
            file                  = new FileInfo(typeof(Aspose.ThreeD.Scene).Assembly.Location);
            ret.Aspose3DBuiltTime = file.LastWriteTime;

            var process = Process.GetCurrentProcess();

            ret.ServerTime  = DateTime.Now;
            ret.StartupTime = process.StartTime;
            ret.Uptime      = (ret.ServerTime - ret.StartupTime).ToString();
            ret.WorkingSet  = process.WorkingSet64 / 1024.0 / 1024.0;
            List <OperationInfo> activeTasks = new List <OperationInfo>();
            var measurements = measurementService.GetMeasurements();

            foreach (var measurement in measurements)
            {
                var ops = measurement.GetActiveOperations();
                for (int i = 0; i < ops.Length; i++)
                {
                    activeTasks.Add(OperationInfo.From(ops[i]));
                }
            }
            ret.ActiveTasks = activeTasks.ToArray();
            return(new ActionResult <ServerInfo>(ret));
        }
Ejemplo n.º 2
0
        private OperationInfo[] ToOperationInfos(AppOperation[] ops)
        {
            var ret = new OperationInfo[ops.Length];

            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = OperationInfo.From(ops[i]);
            }
            return(ret);
        }
Ejemplo n.º 3
0
        public ActionResult <MeasurementInfo> GetMeasurement(string appName, string key)
        {
            if (string.Compare(key, statsKey) != 0)
            {
                return(BadRequest());
            }
            var ret = new MeasurementInfo();
            var app = ParseApp(appName);

            if (app == null)
            {
                return(NotFound());
            }
            var measurement = measurementService.GetMeasurement(app.Value);

            if (measurement == null)
            {
                return(NotFound());
            }
            var active = measurement.GetActiveOperations();
            var error  = measurement.GetErrorOperations();

            ret.Successed         = measurement.SuccessedOperations;
            ret.Failed            = measurement.FailedOperations;
            ret.ActiveOperations  = ToOperationInfos(active);
            ret.ErrorOperations   = ToOperationInfos(error);
            ret.ProlongOperations = ToOperationInfos(measurement.GetProlongOperations());
            ret.LastOperation     = OperationInfo.From(measurement.LastOperation);
            ret.Counters          = new Dictionary <string, int>();

            foreach (var kind in measurement.GetOperationKinds())
            {
                ret.Counters[kind.ToString()] = kind.Counter;
            }


            return(new ActionResult <MeasurementInfo>(ret));
        }