process_stats.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include "defs.h"
  3. #include "actor.h"
  4. #include <library/cpp/monlib/dynamic_counters/counters.h>
  5. namespace NMonitoring {
  6. class TMetricRegistry;
  7. }
  8. namespace NActors {
  9. struct TProcStat {
  10. ui64 Rss;
  11. ui64 VolCtxSwtch;
  12. ui64 NonvolCtxSwtch;
  13. int Pid;
  14. char State;
  15. int Ppid;
  16. int Pgrp;
  17. int Session;
  18. int TtyNr;
  19. int TPgid;
  20. unsigned Flags;
  21. unsigned long MinFlt;
  22. unsigned long CMinFlt;
  23. unsigned long MajFlt;
  24. unsigned long CMajFlt;
  25. unsigned long Utime;
  26. unsigned long Stime;
  27. long CUtime;
  28. long CStime;
  29. long Priority;
  30. long Nice;
  31. long NumThreads;
  32. long ItRealValue;
  33. // StartTime is measured from system boot
  34. unsigned long long StartTime;
  35. unsigned long Vsize;
  36. long RssPages;
  37. unsigned long RssLim;
  38. ui64 FileRss;
  39. ui64 AnonRss;
  40. ui64 CGroupMemLim = 0;
  41. TDuration Uptime;
  42. TDuration SystemUptime;
  43. // ...
  44. TProcStat() {
  45. Zero(*this);
  46. Y_UNUSED(PageSize);
  47. }
  48. bool Fill(pid_t pid);
  49. private:
  50. long PageSize = 0;
  51. long ObtainPageSize();
  52. };
  53. IActor* CreateProcStatCollector(ui32 intervalSec, NMonitoring::TDynamicCounterPtr counters);
  54. IActor* CreateProcStatCollector(TDuration interval, NMonitoring::TMetricRegistry& registry);
  55. IActor* CreateProcStatCollector(TDuration interval, std::weak_ptr<NMonitoring::TMetricRegistry> registry);
  56. }