LinuxMachine.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. #endif
  45. bool online;
  46. } CPUData;
  47. typedef struct GPUEngineData_ {
  48. unsigned long long int prevTime, curTime; /* absolute GPU time in nano seconds */
  49. char* key; /* engine name */
  50. struct GPUEngineData_* next;
  51. } GPUEngineData;
  52. typedef struct LinuxMachine_ {
  53. Machine super;
  54. long jiffies;
  55. int pageSize;
  56. int pageSizeKB;
  57. /* see Linux kernel source for further detail, fs/proc/stat.c */
  58. unsigned int runningTasks; /* procs_running from /proc/stat */
  59. long long boottime; /* btime field from /proc/stat */
  60. double period;
  61. CPUData* cpuData;
  62. memory_t totalHugePageMem;
  63. memory_t usedHugePageMem[HTOP_HUGEPAGE_COUNT];
  64. memory_t availableMem;
  65. unsigned long long int prevGpuTime, curGpuTime; /* total absolute GPU time in nano seconds */
  66. GPUEngineData* gpuEngineData;
  67. ZfsArcStats zfs;
  68. ZramStats zram;
  69. ZswapStats zswap;
  70. } LinuxMachine;
  71. #ifndef PROCDIR
  72. #define PROCDIR "/proc"
  73. #endif
  74. #ifndef PROCCPUINFOFILE
  75. #define PROCCPUINFOFILE PROCDIR "/cpuinfo"
  76. #endif
  77. #ifndef PROCSTATFILE
  78. #define PROCSTATFILE PROCDIR "/stat"
  79. #endif
  80. #ifndef PROCMEMINFOFILE
  81. #define PROCMEMINFOFILE PROCDIR "/meminfo"
  82. #endif
  83. #ifndef PROCARCSTATSFILE
  84. #define PROCARCSTATSFILE PROCDIR "/spl/kstat/zfs/arcstats"
  85. #endif
  86. #ifndef PROCTTYDRIVERSFILE
  87. #define PROCTTYDRIVERSFILE PROCDIR "/tty/drivers"
  88. #endif
  89. #ifndef PROC_LINE_LENGTH
  90. #define PROC_LINE_LENGTH 4096
  91. #endif
  92. #endif