LinuxMachine.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #ifndef HEADER_LinuxMachine
  2. #define HEADER_LinuxMachine
  3. /*
  4. htop - LinuxMachine.h
  5. (C) 2014 Hisham H. Muhammad
  6. Released under the GNU GPLv2+, see the COPYING file
  7. in the source distribution for its full text.
  8. */
  9. #include <stdbool.h>
  10. #include "Machine.h"
  11. #include "linux/ZramStats.h"
  12. #include "linux/ZswapStats.h"
  13. #include "zfs/ZfsArcStats.h"
  14. #define HTOP_HUGEPAGE_BASE_SHIFT 16
  15. #define HTOP_HUGEPAGE_COUNT 24
  16. typedef struct CPUData_ {
  17. unsigned long long int totalTime;
  18. unsigned long long int userTime;
  19. unsigned long long int systemTime;
  20. unsigned long long int systemAllTime;
  21. unsigned long long int idleAllTime;
  22. unsigned long long int idleTime;
  23. unsigned long long int niceTime;
  24. unsigned long long int ioWaitTime;
  25. unsigned long long int irqTime;
  26. unsigned long long int softIrqTime;
  27. unsigned long long int stealTime;
  28. unsigned long long int guestTime;
  29. unsigned long long int totalPeriod;
  30. unsigned long long int userPeriod;
  31. unsigned long long int systemPeriod;
  32. unsigned long long int systemAllPeriod;
  33. unsigned long long int idleAllPeriod;
  34. unsigned long long int idlePeriod;
  35. unsigned long long int nicePeriod;
  36. unsigned long long int ioWaitPeriod;
  37. unsigned long long int irqPeriod;
  38. unsigned long long int softIrqPeriod;
  39. unsigned long long int stealPeriod;
  40. unsigned long long int guestPeriod;
  41. double frequency;
  42. #ifdef HAVE_SENSORS_SENSORS_H
  43. double temperature;
  44. int physicalID; /* different for each CPU socket */
  45. int coreID; /* same for hyperthreading */
  46. int ccdID; /* same for each AMD chiplet */
  47. #endif
  48. bool online;
  49. } CPUData;
  50. typedef struct GPUEngineData_ {
  51. unsigned long long int prevTime, curTime; /* absolute GPU time in nano seconds */
  52. char* key; /* engine name */
  53. struct GPUEngineData_* next;
  54. } GPUEngineData;
  55. typedef struct LinuxMachine_ {
  56. Machine super;
  57. long jiffies;
  58. int pageSize;
  59. int pageSizeKB;
  60. /* see Linux kernel source for further detail, fs/proc/stat.c */
  61. unsigned int runningTasks; /* procs_running from /proc/stat */
  62. long long boottime; /* btime field from /proc/stat */
  63. double period;
  64. CPUData* cpuData;
  65. #ifdef HAVE_SENSORS_SENSORS_H
  66. int maxPhysicalID;
  67. int maxCoreID;
  68. #endif
  69. memory_t totalHugePageMem;
  70. memory_t usedHugePageMem[HTOP_HUGEPAGE_COUNT];
  71. memory_t availableMem;
  72. unsigned long long int prevGpuTime, curGpuTime; /* total absolute GPU time in nano seconds */
  73. GPUEngineData* gpuEngineData;
  74. ZfsArcStats zfs;
  75. ZramStats zram;
  76. ZswapStats zswap;
  77. } LinuxMachine;
  78. #ifndef PROCDIR
  79. #define PROCDIR "/proc"
  80. #endif
  81. #ifndef PROCCPUINFOFILE
  82. #define PROCCPUINFOFILE PROCDIR "/cpuinfo"
  83. #endif
  84. #ifndef PROCSTATFILE
  85. #define PROCSTATFILE PROCDIR "/stat"
  86. #endif
  87. #ifndef PROCMEMINFOFILE
  88. #define PROCMEMINFOFILE PROCDIR "/meminfo"
  89. #endif
  90. #ifndef PROCARCSTATSFILE
  91. #define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats"
  92. #endif
  93. #ifndef PROCTTYDRIVERSFILE
  94. #define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers"
  95. #endif
  96. #ifndef PROC_LINE_LENGTH
  97. #define PROC_LINE_LENGTH 4096
  98. #endif
  99. #endif