LinuxProcess.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef HEADER_LinuxProcess
  2. #define HEADER_LinuxProcess
  3. /*
  4. htop - LinuxProcess.h
  5. (C) 2014 Hisham H. Muhammad
  6. (C) 2020 Red Hat, Inc. All Rights Reserved.
  7. Released under the GNU GPLv2+, see the COPYING file
  8. in the source distribution for its full text.
  9. */
  10. #include <stdbool.h>
  11. #include "Machine.h"
  12. #include "Object.h"
  13. #include "Process.h"
  14. #include "Row.h"
  15. #include "linux/IOPriority.h"
  16. #define PROCESS_FLAG_LINUX_IOPRIO 0x00000100
  17. #define PROCESS_FLAG_LINUX_OPENVZ 0x00000200
  18. #define PROCESS_FLAG_LINUX_VSERVER 0x00000400
  19. #define PROCESS_FLAG_LINUX_CGROUP 0x00000800
  20. #define PROCESS_FLAG_LINUX_OOM 0x00001000
  21. #define PROCESS_FLAG_LINUX_SMAPS 0x00002000
  22. #define PROCESS_FLAG_LINUX_CTXT 0x00004000
  23. #define PROCESS_FLAG_LINUX_SECATTR 0x00008000
  24. #define PROCESS_FLAG_LINUX_LRS_FIX 0x00010000
  25. #define PROCESS_FLAG_LINUX_DELAYACCT 0x00040000
  26. #define PROCESS_FLAG_LINUX_AUTOGROUP 0x00080000
  27. #define PROCESS_FLAG_LINUX_GPU 0x00100000
  28. #define PROCESS_FLAG_LINUX_CONTAINER 0x00200000
  29. typedef struct LinuxProcess_ {
  30. Process super;
  31. IOPriority ioPriority;
  32. unsigned long int cminflt;
  33. unsigned long int cmajflt;
  34. unsigned long long int utime;
  35. unsigned long long int stime;
  36. unsigned long long int cutime;
  37. unsigned long long int cstime;
  38. long m_share;
  39. long m_priv;
  40. long m_pss;
  41. long m_swap;
  42. long m_psswp;
  43. long m_trs;
  44. long m_drs;
  45. long m_lrs;
  46. /* Process flags */
  47. unsigned long int flags;
  48. /* Data read (in bytes) */
  49. unsigned long long io_rchar;
  50. /* Data written (in bytes) */
  51. unsigned long long io_wchar;
  52. /* Number of read(2) syscalls */
  53. unsigned long long io_syscr;
  54. /* Number of write(2) syscalls */
  55. unsigned long long io_syscw;
  56. /* Storage data read (in bytes) */
  57. unsigned long long io_read_bytes;
  58. /* Storage data written (in bytes) */
  59. unsigned long long io_write_bytes;
  60. /* Storage data cancelled (in bytes) */
  61. unsigned long long io_cancelled_write_bytes;
  62. /* Point in time of last io scan (in milliseconds elapsed since the Epoch) */
  63. unsigned long long io_last_scan_time_ms;
  64. /* Storage data read (in bytes per second) */
  65. double io_rate_read_bps;
  66. /* Storage data written (in bytes per second) */
  67. double io_rate_write_bps;
  68. #ifdef HAVE_OPENVZ
  69. char* ctid;
  70. pid_t vpid;
  71. #endif
  72. #ifdef HAVE_VSERVER
  73. unsigned int vxid;
  74. #endif
  75. char* cgroup;
  76. char* cgroup_short;
  77. char* container_short;
  78. unsigned int oom;
  79. #ifdef HAVE_DELAYACCT
  80. unsigned long long int delay_read_time;
  81. unsigned long long cpu_delay_total;
  82. unsigned long long blkio_delay_total;
  83. unsigned long long swapin_delay_total;
  84. float cpu_delay_percent;
  85. float blkio_delay_percent;
  86. float swapin_delay_percent;
  87. #endif
  88. unsigned long ctxt_total;
  89. unsigned long ctxt_diff;
  90. char* secattr;
  91. unsigned long long int last_mlrs_calctime;
  92. /* Total GPU time used in nano seconds */
  93. unsigned long long int gpu_time;
  94. /* GPU utilization in percent */
  95. float gpu_percent;
  96. /* Activity of GPU: 0 if active, otherwise time of last scan in milliseconds */
  97. uint64_t gpu_activityMs;
  98. /* Autogroup scheduling (CFS) information */
  99. long int autogroup_id;
  100. int autogroup_nice;
  101. } LinuxProcess;
  102. extern int pageSize;
  103. extern int pageSizeKB;
  104. extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD];
  105. extern const ProcessClass LinuxProcess_class;
  106. Process* LinuxProcess_new(const Machine* host);
  107. void Process_delete(Object* cast);
  108. IOPriority LinuxProcess_updateIOPriority(Process* proc);
  109. bool LinuxProcess_rowSetIOPriority(Row* super, Arg ioprio);
  110. bool LinuxProcess_isAutogroupEnabled(void);
  111. bool LinuxProcess_rowChangeAutogroupPriorityBy(Row* super, Arg delta);
  112. bool Process_isThread(const Process* this);
  113. #endif