ServiceCenterController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Linq;
  3. using Sers.Core.Module.Rpc;
  4. using Sers.Gover.Base;
  5. using Sers.Hardware.Process;
  6. using Sers.Hardware.Usage;
  7. using Sers.SersLoader;
  8. using Sers.SersLoader.ApiDesc.Attribute.Valid;
  9. using Vit.Core.Module.Log;
  10. using Vit.Core.Util.ComponentModel.Api;
  11. using Vit.Core.Util.ComponentModel.Data;
  12. using Vit.Core.Util.ComponentModel.Model;
  13. namespace Sers.Gover.Controllers.ApiControllers
  14. {
  15. [SsStationName("_gover_")]
  16. public class ServerCenterController : IApiController
  17. {
  18. #region HealthInfo
  19. [SsRoute("serviceCenter/healthInfo")]
  20. [SsCallerSource(ECallerSource.Internal)]
  21. //[CallFromGover]
  22. [SsName("获取服务中心健康数据")]
  23. public ApiReturn<HealthInfoData> HealthInfo()
  24. {
  25. var info = new HealthInfoData();
  26. //(x.1) usageStatus
  27. info.usageStatus = UsageHelp.GetUsageInfo();
  28. //(x.2) Process信息
  29. info.Process = ProcessInfo.GetCurrentProcessInfo();
  30. return info;
  31. }
  32. public class HealthInfoData
  33. {
  34. public UsageStatus usageStatus;
  35. public ProcessInfo Process;
  36. }
  37. #endregion
  38. #region Statistics
  39. [SsRoute("serviceCenter/statistics")]
  40. [SsCallerSource(ECallerSource.Internal)]
  41. //[CallFromGover]
  42. [SsName("获取服务中心统计信息")]
  43. public ApiReturn<StatisticsInfo> Statistics()
  44. {
  45. var info = new StatisticsInfo();
  46. //(x.1) qps
  47. try
  48. {
  49. var qps = GoverApiCenterService.Instance.ApiStation_GetAll().Sum(m => m.qps);
  50. info.qps = qps;
  51. }
  52. catch (Exception ex)
  53. {
  54. Logger.Error(ex);
  55. }
  56. return info;
  57. }
  58. public class StatisticsInfo
  59. {
  60. /// <summary>
  61. /// 总qps
  62. /// </summary>
  63. public float qps;
  64. }
  65. #endregion
  66. }
  67. }