├── .editorconfig ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ ├── build_release.yml │ ├── ci.yml │ ├── codeql-analysis.yml │ └── htoprc ├── .gitignore ├── .travis.yml ├── AUTHORS ├── Action.c ├── Action.h ├── Affinity.c ├── Affinity.h ├── AffinityPanel.c ├── AffinityPanel.h ├── AvailableColumnsPanel.c ├── AvailableColumnsPanel.h ├── AvailableMetersPanel.c ├── AvailableMetersPanel.h ├── BatteryMeter.c ├── BatteryMeter.h ├── CONTRIBUTING.md ├── COPYING ├── CPUMeter.c ├── CPUMeter.h ├── CRT.c ├── CRT.h ├── CategoriesPanel.c ├── CategoriesPanel.h ├── ChangeLog ├── ClockMeter.c ├── ClockMeter.h ├── ColorsPanel.c ├── ColorsPanel.h ├── ColumnsPanel.c ├── ColumnsPanel.h ├── CommandLine.c ├── CommandLine.h ├── CommandScreen.c ├── CommandScreen.h ├── Compat.c ├── Compat.h ├── DateMeter.c ├── DateMeter.h ├── DateTimeMeter.c ├── DateTimeMeter.h ├── DiskIOMeter.c ├── DiskIOMeter.h ├── DisplayOptionsPanel.c ├── DisplayOptionsPanel.h ├── DynamicColumn.c ├── DynamicColumn.h ├── DynamicMeter.c ├── DynamicMeter.h ├── DynamicScreen.c ├── DynamicScreen.h ├── EnvScreen.c ├── EnvScreen.h ├── FileDescriptorMeter.c ├── FileDescriptorMeter.h ├── FunctionBar.c ├── FunctionBar.h ├── Hashtable.c ├── Hashtable.h ├── Header.c ├── Header.h ├── HeaderLayout.h ├── HeaderOptionsPanel.c ├── HeaderOptionsPanel.h ├── HostnameMeter.c ├── HostnameMeter.h ├── IncSet.c ├── IncSet.h ├── InfoScreen.c ├── InfoScreen.h ├── ListItem.c ├── ListItem.h ├── LoadAverageMeter.c ├── LoadAverageMeter.h ├── Machine.c ├── Machine.h ├── Macros.h ├── MainPanel.c ├── MainPanel.h ├── Makefile.am ├── MemoryMeter.c ├── MemoryMeter.h ├── MemorySwapMeter.c ├── MemorySwapMeter.h ├── Meter.c ├── Meter.h ├── MeterMode.h ├── MetersPanel.c ├── MetersPanel.h ├── NEWS ├── NetworkIOMeter.c ├── NetworkIOMeter.h ├── Object.c ├── Object.h ├── OpenFilesScreen.c ├── OpenFilesScreen.h ├── OptionItem.c ├── OptionItem.h ├── Panel.c ├── Panel.h ├── Process.c ├── Process.h ├── ProcessLocksScreen.c ├── ProcessLocksScreen.h ├── ProcessTable.c ├── ProcessTable.h ├── ProvideCurses.h ├── ProvideTerm.h ├── README ├── README.md ├── RichString.c ├── RichString.h ├── Row.c ├── Row.h ├── RowField.h ├── Scheduling.c ├── Scheduling.h ├── ScreenManager.c ├── ScreenManager.h ├── ScreenTabsPanel.c ├── ScreenTabsPanel.h ├── ScreensPanel.c ├── ScreensPanel.h ├── Settings.c ├── Settings.h ├── SignalsPanel.c ├── SignalsPanel.h ├── SwapMeter.c ├── SwapMeter.h ├── SysArchMeter.c ├── SysArchMeter.h ├── TESTPLAN ├── Table.c ├── Table.h ├── TasksMeter.c ├── TasksMeter.h ├── TraceScreen.c ├── TraceScreen.h ├── UptimeMeter.c ├── UptimeMeter.h ├── UsersTable.c ├── UsersTable.h ├── Vector.c ├── Vector.h ├── XUtils.c ├── XUtils.h ├── autogen.sh ├── build.sh ├── check-pcp-style.sh ├── clean.sh ├── configure.ac ├── darwin ├── DarwinMachine.c ├── DarwinMachine.h ├── DarwinProcess.c ├── DarwinProcess.h ├── DarwinProcessTable.c ├── DarwinProcessTable.h ├── Platform.c ├── Platform.h ├── PlatformHelpers.c ├── PlatformHelpers.h └── ProcessField.h ├── docs ├── images │ └── screenshot.png └── styleguide.md ├── dragonflybsd ├── DragonFlyBSDMachine.c ├── DragonFlyBSDMachine.h ├── DragonFlyBSDProcess.c ├── DragonFlyBSDProcess.h ├── DragonFlyBSDProcessTable.c ├── DragonFlyBSDProcessTable.h ├── Platform.c ├── Platform.h └── ProcessField.h ├── freebsd ├── FreeBSDMachine.c ├── FreeBSDMachine.h ├── FreeBSDProcess.c ├── FreeBSDProcess.h ├── FreeBSDProcessTable.c ├── FreeBSDProcessTable.h ├── Platform.c ├── Platform.h └── ProcessField.h ├── generic ├── fdstat_sysctl.c ├── fdstat_sysctl.h ├── gettime.c ├── gettime.h ├── hostname.c ├── hostname.h ├── openzfs_sysctl.c ├── openzfs_sysctl.h ├── uname.c └── uname.h ├── htop.1.in ├── htop.c ├── htop.desktop ├── htop.png ├── htop.svg ├── iwyu ├── htop.imp └── run_iwyu.sh ├── linux ├── CGroupUtils.c ├── CGroupUtils.h ├── GPU.c ├── GPU.h ├── GPUMeter.c ├── GPUMeter.h ├── HugePageMeter.c ├── HugePageMeter.h ├── IOPriority.h ├── IOPriorityPanel.c ├── IOPriorityPanel.h ├── LibNl.c ├── LibNl.h ├── LibSensors.c ├── LibSensors.h ├── LinuxMachine.c ├── LinuxMachine.h ├── LinuxProcess.c ├── LinuxProcess.h ├── LinuxProcessTable.c ├── LinuxProcessTable.h ├── Platform.c ├── Platform.h ├── PressureStallMeter.c ├── PressureStallMeter.h ├── ProcessField.h ├── SELinuxMeter.c ├── SELinuxMeter.h ├── SystemdMeter.c ├── SystemdMeter.h ├── ZramMeter.c ├── ZramMeter.h ├── ZramStats.h └── ZswapStats.h ├── netbsd ├── NetBSDMachine.c ├── NetBSDMachine.h ├── NetBSDProcess.c ├── NetBSDProcess.h ├── NetBSDProcessTable.c ├── NetBSDProcessTable.h ├── Platform.c ├── Platform.h ├── ProcessField.h └── README.md ├── openbsd ├── OpenBSDMachine.c ├── OpenBSDMachine.h ├── OpenBSDProcess.c ├── OpenBSDProcess.h ├── OpenBSDProcessTable.c ├── OpenBSDProcessTable.h ├── Platform.c ├── Platform.h └── ProcessField.h ├── pcp-htop.5.in ├── pcp-htop.c ├── pcp ├── InDomTable.c ├── InDomTable.h ├── Instance.c ├── Instance.h ├── Metric.c ├── Metric.h ├── PCPDynamicColumn.c ├── PCPDynamicColumn.h ├── PCPDynamicMeter.c ├── PCPDynamicMeter.h ├── PCPDynamicScreen.c ├── PCPDynamicScreen.h ├── PCPMachine.c ├── PCPMachine.h ├── PCPProcess.c ├── PCPProcess.h ├── PCPProcessTable.c ├── PCPProcessTable.h ├── Platform.c ├── Platform.h ├── ProcessField.h ├── columns │ ├── container │ ├── delayacct │ ├── fdcount │ ├── gpu_memory │ ├── guest │ ├── memory │ ├── sched │ ├── swap │ ├── tcp │ ├── udp │ └── wchan ├── meters │ ├── entropy │ ├── freespace │ ├── gpu │ ├── ipc │ ├── locks │ ├── memcache │ ├── mysql │ ├── postfix │ ├── redis │ └── tcp └── screens │ ├── biosnoop │ ├── cgroups │ ├── cgroupsio │ ├── cgroupsmem │ ├── devices │ ├── execsnoop │ ├── exitsnoop │ ├── filesystems │ └── opensnoop ├── scripts ├── htop_suppressions.valgrind └── run_valgrind.sh ├── solaris ├── Platform.c ├── Platform.h ├── ProcessField.h ├── SolarisMachine.c ├── SolarisMachine.h ├── SolarisProcess.c ├── SolarisProcess.h ├── SolarisProcessTable.c └── SolarisProcessTable.h ├── test_spec.lua ├── unsupported ├── Platform.c ├── Platform.h ├── ProcessField.h ├── UnsupportedMachine.c ├── UnsupportedMachine.h ├── UnsupportedProcess.c ├── UnsupportedProcess.h ├── UnsupportedProcessTable.c └── UnsupportedProcessTable.h └── zfs ├── ZfsArcMeter.c ├── ZfsArcMeter.h ├── ZfsArcStats.h ├── ZfsCompressedArcMeter.c └── ZfsCompressedArcMeter.h /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig configuration for htop 2 | # http://EditorConfig.org 3 | 4 | # top-most EditorConfig file 5 | root = true 6 | 7 | # Unix-style newlines with a newline ending every file, utf-8 charset 8 | [*] 9 | end_of_line = lf 10 | insert_final_newline = true 11 | charset = utf-8 12 | 13 | # match C source and header files, set indent to three spaces 14 | [*.{c,h}] 15 | indent_style = space 16 | indent_size = 3 17 | trim_trailing_whitespace = true 18 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: ["https://hcb.hackclub.com/donations/start/htop"] 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: 2 4 | 5 | updates: 6 | - package-ecosystem: github-actions 7 | directory: / 8 | schedule: 9 | interval: weekly 10 | -------------------------------------------------------------------------------- /.github/workflows/build_release.yml: -------------------------------------------------------------------------------- 1 | name: Build Source Release 2 | 3 | # Trigger whenever a release is created 4 | on: 5 | release: 6 | types: 7 | - created 8 | 9 | jobs: 10 | build: 11 | name: build 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | with: 16 | submodules: true 17 | 18 | - name: archive 19 | id: archive 20 | run: | 21 | VERSION=${{ github.event.release.tag_name }} 22 | PKGNAME="htop-$VERSION" 23 | SHASUM=$PKGNAME.tar.xz.sha256 24 | autoreconf -i 25 | mkdir -p /tmp/$PKGNAME 26 | mv * /tmp/$PKGNAME 27 | mv /tmp/$PKGNAME . 28 | TARBALL=$PKGNAME.tar.xz 29 | tar cJf $TARBALL $PKGNAME 30 | sha256sum $TARBALL > $SHASUM 31 | echo "::set-output name=tarball::$TARBALL" 32 | echo "::set-output name=shasum::$SHASUM" 33 | - name: upload tarball 34 | uses: actions/upload-release-asset@v1 35 | env: 36 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 37 | with: 38 | upload_url: ${{ github.event.release.upload_url }} 39 | asset_path: ./${{ steps.archive.outputs.tarball }} 40 | asset_name: ${{ steps.archive.outputs.tarball }} 41 | asset_content_type: application/gzip 42 | 43 | - name: upload shasum 44 | uses: actions/upload-release-asset@v1 45 | env: 46 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 47 | with: 48 | upload_url: ${{ github.event.release.upload_url }} 49 | asset_path: ./${{ steps.archive.outputs.shasum }} 50 | asset_name: ${{ steps.archive.outputs.shasum }} 51 | asset_content_type: text/plain 52 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | pull_request: 7 | branches: [main] 8 | schedule: 9 | - cron: '0 1 * * 0' 10 | 11 | permissions: 12 | contents: read 13 | 14 | jobs: 15 | analyze: 16 | name: Analyze 17 | runs-on: ubuntu-latest 18 | permissions: 19 | actions: read 20 | security-events: write 21 | 22 | env: 23 | # Enable format attributes in ncurses headers 24 | # Enable fortified memory/string handling 25 | CPPFLAGS: -DGCC_PRINTF -DGCC_SCANF -D_FORTIFY_SOURCE=2 26 | 27 | steps: 28 | - name: Checkout Repository 29 | uses: actions/checkout@v4 30 | 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v3 33 | with: 34 | languages: cpp 35 | 36 | - name: Install Dependencies 37 | run: sudo apt-get install --no-install-recommends libncursesw5-dev libhwloc-dev libnl-3-dev libnl-genl-3-dev libsensors-dev libcap-dev 38 | 39 | - name: Bootstrap 40 | run: ./autogen.sh 41 | 42 | - name: Configure 43 | run: ./configure --enable-werror --enable-openvz --enable-vserver --enable-ancient-vserver --enable-unicode --enable-hwloc --enable-delayacct --enable-sensors --enable-capabilities 44 | 45 | - name: Build 46 | run: make 47 | 48 | - name: Perform CodeQL Analysis 49 | uses: github/codeql-action/analyze@v3 50 | -------------------------------------------------------------------------------- /.github/workflows/htoprc: -------------------------------------------------------------------------------- 1 | # Beware! This file is rewritten by htop when settings are changed in the interface. 2 | # The parser is also very primitive, and not human-friendly. 3 | htop_version=3.3.0-dev 4 | config_reader_min_version=3 5 | fields=0 48 17 18 38 39 40 2 46 47 49 1 6 | hide_kernel_threads=1 7 | hide_userland_threads=0 8 | hide_running_in_container=0 9 | shadow_other_users=1 10 | show_thread_names=1 11 | show_program_path=1 12 | highlight_base_name=1 13 | highlight_deleted_exe=1 14 | shadow_distribution_path_prefix=1 15 | highlight_megabytes=1 16 | highlight_threads=1 17 | highlight_changes=1 18 | highlight_changes_delay_secs=5 19 | find_comm_in_cmdline=1 20 | strip_exe_from_cmdline=1 21 | show_merged_command=1 22 | header_margin=1 23 | screen_tabs=1 24 | detailed_cpu_time=1 25 | cpu_count_from_one=0 26 | show_cpu_usage=1 27 | show_cpu_frequency=1 28 | show_cpu_temperature=1 29 | degree_fahrenheit=0 30 | update_process_names=1 31 | account_guest_in_cpu_meter=1 32 | color_scheme=0 33 | enable_mouse=1 34 | delay=15 35 | hide_function_bar=0 36 | header_layout=two_50_50 37 | column_meters_0=LeftCPUs4 CPU Memory Swap MemorySwap Zram Clock Date DateTime ZFSARC ZFSCARC SELinux SystemdUser FileDescriptors 38 | column_meter_modes_0=1 1 1 1 1 1 2 2 2 2 2 2 2 2 39 | column_meters_1=RightCPUs4 Tasks LoadAverage Load Uptime Battery System HugePages Hostname Blank PressureStallCPUSome PressureStallIOSome PressureStallIOFull PressureStallIRQFull PressureStallMemorySome PressureStallMemoryFull DiskIO NetworkIO 40 | column_meter_modes_1=1 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 41 | tree_view=0 42 | sort_key=46 43 | tree_sort_key=0 44 | sort_direction=-1 45 | tree_sort_direction=1 46 | tree_view_always_by_pid=0 47 | all_branches_collapsed=0 48 | screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command 49 | .sort_key=PERCENT_CPU 50 | .tree_sort_key=PID 51 | .tree_view_always_by_pid=0 52 | .tree_view=0 53 | .sort_direction=-1 54 | .tree_sort_direction=1 55 | .all_branches_collapsed=0 56 | screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command 57 | .sort_key=IO_RATE 58 | .tree_sort_key=PID 59 | .tree_view_always_by_pid=0 60 | .tree_view=0 61 | .sort_direction=-1 62 | .tree_sort_direction=1 63 | .all_branches_collapsed=0 64 | screen:Dump=PID SCHEDULERPOLICY SYSCR CGROUP CCGROUP OOM IO_PRIORITY PERCENT_CPU_DELAY CTXT SECATTR CWD AUTOGROUP_ID Command 65 | .sort_key=PID 66 | .tree_sort_key=PID 67 | .tree_view_always_by_pid=0 68 | .tree_view=0 69 | .sort_direction=1 70 | .tree_sort_direction=1 71 | .all_branches_collapsed=0 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # the binaries: 2 | htop 3 | pcp-htop 4 | 5 | # all object files 6 | *.o 7 | 8 | # skip all backups 9 | *.bak 10 | *~ 11 | .*.sw? 12 | 13 | # skip coverage files 14 | *.gcda 15 | */*.gcda 16 | *.gcno 17 | */*.gcno 18 | *.h.gch 19 | */.dirstamp 20 | 21 | # automake/autoconf related files 22 | .deps/ 23 | Makefile 24 | Makefile.in 25 | INSTALL 26 | aclocal.m4 27 | autom4te.cache/ 28 | compile 29 | conf*/ 30 | config.guess 31 | config.h 32 | config.h.in 33 | config.log 34 | config.status 35 | config.cache 36 | config.sub 37 | configure 38 | depcomp 39 | htop.1 40 | pcp-htop.5 41 | install-sh 42 | libtool 43 | ltmain.sh 44 | m4/ 45 | missing 46 | stamp-h1 47 | 48 | # files related to valgrind/callgrind 49 | callgrind.out.* 50 | 51 | # IDE workspace configurations 52 | /.idea/ 53 | /.vscode/ 54 | 55 | # Language Servers 56 | /.cache/clangd/ 57 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | compiler: 4 | - clang 5 | - gcc 6 | 7 | os: 8 | - freebsd 9 | 10 | script: 11 | - ./autogen.sh 12 | - ./configure --enable-werror 13 | - make -k 14 | - make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror 15 | - sudo make install 16 | - make installcheck 17 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Originally authored by: 2 | Hisham H. Muhammad 3 | 4 | Currently maintained by the htop dev team: 5 | Benny Baumann 6 | Christian Göttsche 7 | Daniel Lange 8 | Nathan Scott 9 | 10 | For the full list of contributors see: 11 | git log --format="%aN" | sort -u 12 | -------------------------------------------------------------------------------- /Action.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Action 2 | #define HEADER_Action 3 | /* 4 | htop - Action.h 5 | (C) 2015 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "Header.h" 14 | #include "Machine.h" 15 | #include "Object.h" 16 | #include "Panel.h" 17 | #include "Process.h" 18 | #include "Settings.h" 19 | 20 | 21 | typedef enum { 22 | HTOP_OK = 0x00, 23 | HTOP_REFRESH = 0x01, 24 | HTOP_RECALCULATE = 0x02 | HTOP_REFRESH, 25 | HTOP_SAVE_SETTINGS = 0x04, 26 | HTOP_KEEP_FOLLOWING = 0x08, 27 | HTOP_QUIT = 0x10, 28 | HTOP_REDRAW_BAR = 0x20, 29 | HTOP_UPDATE_PANELHDR = 0x40 | HTOP_REFRESH, 30 | HTOP_RESIZE = 0x80 | HTOP_REFRESH | HTOP_REDRAW_BAR | HTOP_UPDATE_PANELHDR, 31 | } Htop_Reaction; 32 | 33 | struct MainPanel_; // IWYU pragma: keep 34 | 35 | typedef struct State_ { 36 | Machine* host; 37 | struct MainPanel_* mainPanel; 38 | Header* header; 39 | bool pauseUpdate; 40 | bool hideSelection; 41 | bool hideMeters; 42 | } State; 43 | 44 | static inline bool State_hideFunctionBar(const State* st) { 45 | const Settings* settings = st->host->settings; 46 | return settings->hideFunctionBar == 2 || (settings->hideFunctionBar == 1 && st->hideSelection); 47 | } 48 | 49 | typedef Htop_Reaction (*Htop_Action)(State* st); 50 | 51 | Object* Action_pickFromVector(State* st, Panel* list, int x, bool follow); 52 | 53 | bool Action_setUserOnly(const char* userName, uid_t* userId); 54 | 55 | Htop_Reaction Action_setSortKey(Settings* settings, ProcessField sortKey); 56 | 57 | Htop_Reaction Action_setScreenTab(State* st, int x); 58 | 59 | Htop_Reaction Action_follow(State* st); 60 | 61 | void Action_setBindings(Htop_Action* keys); 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Affinity.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Affinity 2 | #define HEADER_Affinity 3 | /* 4 | htop - Affinity.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | (C) 2020,2023 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 | 11 | #include "Machine.h" 12 | 13 | #if defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY) 14 | #include 15 | 16 | #include "Object.h" 17 | #include "Row.h" 18 | #endif 19 | 20 | 21 | #if defined(HAVE_LIBHWLOC) && defined(HAVE_AFFINITY) 22 | #error hwloc and affinity support are mutual exclusive. 23 | #endif 24 | 25 | 26 | typedef struct Affinity_ { 27 | Machine* host; 28 | unsigned int size; 29 | unsigned int used; 30 | unsigned int* cpus; 31 | } Affinity; 32 | 33 | Affinity* Affinity_new(Machine* host); 34 | 35 | void Affinity_delete(Affinity* this); 36 | 37 | void Affinity_add(Affinity* this, unsigned int id); 38 | 39 | #if defined(HAVE_LIBHWLOC) || defined(HAVE_AFFINITY) 40 | 41 | Affinity* Affinity_rowGet(const Row* row, Machine* host); 42 | 43 | bool Affinity_rowSet(Row* row, Arg arg); 44 | 45 | #endif /* HAVE_LIBHWLOC || HAVE_AFFINITY */ 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /AffinityPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_AffinityPanel 2 | #define HEADER_AffinityPanel 3 | /* 4 | htop - AffinityPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Affinity.h" 11 | #include "Machine.h" 12 | #include "Panel.h" 13 | 14 | 15 | extern const PanelClass AffinityPanel_class; 16 | 17 | Panel* AffinityPanel_new(Machine* host, const Affinity* affinity, int* width); 18 | 19 | Affinity* AffinityPanel_getAffinity(Panel* super, Machine* host); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /AvailableColumnsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_AvailableColumnsPanel 2 | #define HEADER_AvailableColumnsPanel 3 | /* 4 | htop - AvailableColumnsPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Hashtable.h" 11 | #include "Panel.h" 12 | 13 | 14 | typedef struct AvailableColumnsPanel_ { 15 | Panel super; 16 | Panel* columns; 17 | } AvailableColumnsPanel; 18 | 19 | extern const PanelClass AvailableColumnsPanel_class; 20 | 21 | AvailableColumnsPanel* AvailableColumnsPanel_new(Panel* columns, Hashtable* dynamicColumns); 22 | 23 | void AvailableColumnsPanel_fill(AvailableColumnsPanel* this, const char* dynamicScreen, Hashtable* dynamicColumns); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /AvailableMetersPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_AvailableMetersPanel 2 | #define HEADER_AvailableMetersPanel 3 | /* 4 | htop - AvailableMetersPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Header.h" 13 | #include "Machine.h" 14 | #include "MetersPanel.h" 15 | #include "Panel.h" 16 | #include "ScreenManager.h" 17 | 18 | 19 | typedef struct AvailableMetersPanel_ { 20 | Panel super; 21 | ScreenManager* scr; 22 | Machine* host; 23 | Header* header; 24 | size_t columns; 25 | MetersPanel** meterPanels; 26 | } AvailableMetersPanel; 27 | 28 | extern const PanelClass AvailableMetersPanel_class; 29 | 30 | AvailableMetersPanel* AvailableMetersPanel_new(Machine* host, Header* header, size_t columns, MetersPanel** meterPanels, ScreenManager* scr); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /BatteryMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - BatteryMeter.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | 7 | This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). 8 | */ 9 | 10 | #include "config.h" // IWYU pragma: keep 11 | 12 | #include "BatteryMeter.h" 13 | 14 | #include 15 | 16 | #include "CRT.h" 17 | #include "Macros.h" 18 | #include "Object.h" 19 | #include "Platform.h" 20 | #include "XUtils.h" 21 | 22 | 23 | static const int BatteryMeter_attributes[] = { 24 | BATTERY 25 | }; 26 | 27 | static void BatteryMeter_updateValues(Meter* this) { 28 | ACPresence isOnAC; 29 | double percent; 30 | 31 | Platform_getBattery(&percent, &isOnAC); 32 | 33 | if (!isNonnegative(percent)) { 34 | this->values[0] = NAN; 35 | xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "N/A"); 36 | return; 37 | } 38 | 39 | this->values[0] = percent; 40 | 41 | const char* text; 42 | switch (isOnAC) { 43 | case AC_PRESENT: 44 | text = this->mode == TEXT_METERMODE ? " (Running on A/C)" : "(A/C)"; 45 | break; 46 | case AC_ABSENT: 47 | text = this->mode == TEXT_METERMODE ? " (Running on battery)" : "(bat)"; 48 | break; 49 | case AC_ERROR: 50 | default: 51 | text = ""; 52 | break; 53 | } 54 | 55 | xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1f%%%s", percent, text); 56 | } 57 | 58 | const MeterClass BatteryMeter_class = { 59 | .super = { 60 | .extends = Class(Meter), 61 | .delete = Meter_delete 62 | }, 63 | .updateValues = BatteryMeter_updateValues, 64 | .defaultMode = TEXT_METERMODE, 65 | .supportedModes = METERMODE_DEFAULT_SUPPORTED, 66 | .maxItems = 1, 67 | .total = 100.0, 68 | .attributes = BatteryMeter_attributes, 69 | .name = "Battery", 70 | .uiName = "Battery", 71 | .caption = "Battery: " 72 | }; 73 | -------------------------------------------------------------------------------- /BatteryMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_BatteryMeter 2 | #define HEADER_BatteryMeter 3 | /* 4 | htop - BatteryMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | 9 | This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com). 10 | */ 11 | 12 | #include "Meter.h" 13 | 14 | 15 | typedef enum ACPresence_ { 16 | AC_ABSENT, 17 | AC_PRESENT, 18 | AC_ERROR 19 | } ACPresence; 20 | 21 | extern const MeterClass BatteryMeter_class; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing Guide 2 | ================== 3 | 4 | Thank you so much for taking the time to contribute in to htop! 5 | 6 | Bug Reports 7 | ----------- 8 | 9 | Bug reports should be posted in the [Github issue 10 | tracker](https://github.com/htop-dev/htop/issues). 11 | Bug reports are extremely important since it's impossible for us to test 12 | htop in every possible system, distribution and scenario. Your feedback 13 | is what keeps the tool stable and always improving! Thank you! 14 | 15 | Pull Requests 16 | ------------- 17 | 18 | Code contributions are most welcome! Just [fork the 19 | repo](https://github.com/htop-dev/htop) and send a [pull 20 | request](https://github.com/htop-dev/htop/pulls). Help is especially 21 | appreciated for support of platforms other than Linux. If proposing new 22 | features, please be mindful that htop is a system tool that needs to keep a 23 | small footprint and perform well on systems under stress -- so unfortunately 24 | we can't accept every new feature proposed, as we need to keep the tool slim 25 | and maintainable. Great ideas backed by a PR are always carefully considered 26 | for inclusion though! Also, PRs containing bug fixes and portability tweaks 27 | are always included, please send those in! 28 | 29 | Feature Requests 30 | ---------------- 31 | 32 | Please label Github issues that are feature requests with one of the `feature request` 33 | labels. If you can't do this yourself, don't worry. The friendly folks from the 34 | core team will distribute and fixup Github labels as part of the regular reviews. 35 | 36 | Style Guide 37 | ----------- 38 | 39 | To make working with the code easier a set of guidelines have evolved in 40 | the past that new contributions should try to follow. While they are not set 41 | in stone and always up for changes should the need arise they still provide 42 | a first orientation to go by when contributing to this repository. 43 | 44 | The details of the coding style as well as what to take care about with your 45 | contributions can be found in our [style guide](docs/styleguide.md). 46 | -------------------------------------------------------------------------------- /CPUMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CPUMeter 2 | #define HEADER_CPUMeter 3 | /* 4 | htop - CPUMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | typedef enum { 14 | CPU_METER_NICE = 0, 15 | CPU_METER_NORMAL = 1, 16 | CPU_METER_KERNEL = 2, 17 | CPU_METER_IRQ = 3, 18 | CPU_METER_SOFTIRQ = 4, 19 | CPU_METER_STEAL = 5, 20 | CPU_METER_GUEST = 6, 21 | CPU_METER_IOWAIT = 7, 22 | CPU_METER_FREQUENCY = 8, 23 | CPU_METER_TEMPERATURE = 9, 24 | CPU_METER_ITEMCOUNT = 10, // number of entries in this enum 25 | } CPUMeterValues; 26 | 27 | extern const MeterClass CPUMeter_class; 28 | 29 | extern const MeterClass AllCPUsMeter_class; 30 | 31 | extern const MeterClass AllCPUs2Meter_class; 32 | 33 | extern const MeterClass LeftCPUsMeter_class; 34 | 35 | extern const MeterClass RightCPUsMeter_class; 36 | 37 | extern const MeterClass LeftCPUs2Meter_class; 38 | 39 | extern const MeterClass RightCPUs2Meter_class; 40 | 41 | extern const MeterClass AllCPUs4Meter_class; 42 | 43 | extern const MeterClass LeftCPUs4Meter_class; 44 | 45 | extern const MeterClass RightCPUs4Meter_class; 46 | 47 | extern const MeterClass AllCPUs8Meter_class; 48 | 49 | extern const MeterClass LeftCPUs8Meter_class; 50 | 51 | extern const MeterClass RightCPUs8Meter_class; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /CategoriesPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CategoriesPanel 2 | #define HEADER_CategoriesPanel 3 | /* 4 | htop - CategoriesPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Header.h" 11 | #include "Machine.h" 12 | #include "Panel.h" 13 | #include "ScreenManager.h" 14 | 15 | 16 | typedef struct CategoriesPanel_ { 17 | Panel super; 18 | ScreenManager* scr; 19 | Machine* host; 20 | Header* header; 21 | } CategoriesPanel; 22 | 23 | extern const PanelClass CategoriesPanel_class; 24 | 25 | CategoriesPanel* CategoriesPanel_new(ScreenManager* scr, Header* header, Machine* host); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /ClockMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - ClockMeter.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "ClockMeter.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "CRT.h" 16 | #include "Machine.h" 17 | #include "Object.h" 18 | 19 | 20 | static const int ClockMeter_attributes[] = { 21 | CLOCK 22 | }; 23 | 24 | static void ClockMeter_updateValues(Meter* this) { 25 | const Machine* host = this->host; 26 | 27 | struct tm result; 28 | const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result); 29 | strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt); 30 | } 31 | 32 | const MeterClass ClockMeter_class = { 33 | .super = { 34 | .extends = Class(Meter), 35 | .delete = Meter_delete 36 | }, 37 | .updateValues = ClockMeter_updateValues, 38 | .defaultMode = TEXT_METERMODE, 39 | .supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE), 40 | .maxItems = 0, 41 | .total = 0.0, 42 | .attributes = ClockMeter_attributes, 43 | .name = "Clock", 44 | .uiName = "Clock", 45 | .caption = "Time: ", 46 | }; 47 | -------------------------------------------------------------------------------- /ClockMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ClockMeter 2 | #define HEADER_ClockMeter 3 | /* 4 | htop - ClockMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass ClockMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /ColorsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ColorsPanel 2 | #define HEADER_ColorsPanel 3 | /* 4 | htop - ColorsPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Panel.h" 11 | #include "Settings.h" 12 | 13 | 14 | typedef struct ColorsPanel_ { 15 | Panel super; 16 | 17 | Settings* settings; 18 | } ColorsPanel; 19 | 20 | extern const PanelClass ColorsPanel_class; 21 | 22 | ColorsPanel* ColorsPanel_new(Settings* settings); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /ColumnsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ColumnsPanel 2 | #define HEADER_ColumnsPanel 3 | /* 4 | htop - ColumnsPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Hashtable.h" 13 | #include "Panel.h" 14 | #include "Settings.h" 15 | 16 | 17 | typedef struct ColumnsPanel_ { 18 | Panel super; 19 | ScreenSettings* ss; 20 | bool* changed; 21 | 22 | bool moving; 23 | } ColumnsPanel; 24 | 25 | extern const PanelClass ColumnsPanel_class; 26 | 27 | ColumnsPanel* ColumnsPanel_new(ScreenSettings* ss, Hashtable* columns, bool* changed); 28 | 29 | void ColumnsPanel_fill(ColumnsPanel* this, ScreenSettings* ss, Hashtable* columns); 30 | 31 | void ColumnsPanel_update(Panel* super); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /CommandLine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CommandLine 2 | #define HEADER_CommandLine 3 | /* 4 | htop - CommandLine.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | (C) 2020-2021 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | typedef enum { 12 | STATUS_OK, 13 | STATUS_ERROR_EXIT, 14 | STATUS_OK_EXIT 15 | } CommandLineStatus; 16 | 17 | extern const char* program; 18 | 19 | int CommandLine_run(int argc, char** argv); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /CommandScreen.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - CommandScreen.c 3 | (C) 2017,2020 ryenus 4 | (C) 2020,2021 htop dev team 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "CommandScreen.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "Macros.h" 18 | #include "Panel.h" 19 | #include "ProvideCurses.h" 20 | 21 | 22 | static void CommandScreen_scan(InfoScreen* this) { 23 | Panel* panel = this->display; 24 | int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0); 25 | Panel_prune(panel); 26 | 27 | const char* p = Process_getCommand(this->process); 28 | char line[COLS + 1]; 29 | int line_offset = 0, last_spc = -1, len; 30 | for (; *p != '\0'; p++, line_offset++) { 31 | assert(line_offset >= 0 && (size_t)line_offset < sizeof(line)); 32 | line[line_offset] = *p; 33 | if (*p == ' ') { 34 | last_spc = line_offset; 35 | } 36 | 37 | if (line_offset == COLS) { 38 | len = (last_spc == -1) ? line_offset : last_spc; 39 | line[len] = '\0'; 40 | InfoScreen_addLine(this, line); 41 | 42 | line_offset -= len; 43 | last_spc = -1; 44 | memcpy(line, p - line_offset, line_offset + 1); 45 | } 46 | } 47 | 48 | if (line_offset > 0) { 49 | line[line_offset] = '\0'; 50 | InfoScreen_addLine(this, line); 51 | } 52 | 53 | Panel_setSelected(panel, idx); 54 | } 55 | 56 | static void CommandScreen_draw(InfoScreen* this) { 57 | InfoScreen_drawTitled(this, "Command of process %d - %s", Process_getPid(this->process), Process_getCommand(this->process)); 58 | } 59 | 60 | const InfoScreenClass CommandScreen_class = { 61 | .super = { 62 | .extends = Class(Object), 63 | .delete = CommandScreen_delete 64 | }, 65 | .scan = CommandScreen_scan, 66 | .draw = CommandScreen_draw 67 | }; 68 | 69 | CommandScreen* CommandScreen_new(Process* process) { 70 | CommandScreen* this = AllocThis(CommandScreen); 71 | return (CommandScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " "); 72 | } 73 | 74 | void CommandScreen_delete(Object* this) { 75 | free(InfoScreen_done((InfoScreen*)this)); 76 | } 77 | -------------------------------------------------------------------------------- /CommandScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CommandScreen 2 | #define HEADER_CommandScreen 3 | /* 4 | htop - CommandScreen.h 5 | (C) 2017,2020 ryenus 6 | (C) 2020,2021 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include "InfoScreen.h" 12 | #include "Object.h" 13 | #include "Process.h" 14 | 15 | 16 | typedef struct CommandScreen_ { 17 | InfoScreen super; 18 | } CommandScreen; 19 | 20 | extern const InfoScreenClass CommandScreen_class; 21 | 22 | CommandScreen* CommandScreen_new(Process* process); 23 | 24 | void CommandScreen_delete(Object* this); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Compat.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Compat 2 | #define HEADER_Compat 3 | /* 4 | htop - Compat.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include // IWYU pragma: keep 11 | #include 12 | #include // IWYU pragma: keep 13 | #include 14 | #include // IWYU pragma: keep 15 | 16 | 17 | int Compat_faccessat(int dirfd, 18 | const char* pathname, 19 | int mode, 20 | int flags); 21 | 22 | int Compat_fstatat(int dirfd, 23 | const char* dirpath, 24 | const char* pathname, 25 | struct stat* statbuf, 26 | int flags); 27 | 28 | #ifdef HAVE_OPENAT 29 | 30 | typedef int openat_arg_t; 31 | 32 | static inline void Compat_openatArgClose(openat_arg_t dirfd) { 33 | close(dirfd); 34 | } 35 | 36 | static inline int Compat_openat(openat_arg_t dirfd, const char* pathname, int flags) { 37 | return openat(dirfd, pathname, flags); 38 | } 39 | 40 | #else /* HAVE_OPENAT */ 41 | 42 | typedef const char* openat_arg_t; 43 | 44 | static inline void Compat_openatArgClose(openat_arg_t dirpath) { 45 | (void)dirpath; 46 | } 47 | 48 | int Compat_openat(openat_arg_t dirpath, const char* pathname, int flags); 49 | 50 | #endif /* HAVE_OPENAT */ 51 | 52 | ssize_t Compat_readlinkat(int dirfd, 53 | const char* dirpath, 54 | const char* pathname, 55 | char* buf, 56 | size_t bufsize); 57 | 58 | ssize_t Compat_readlink(openat_arg_t dirfd, 59 | const char* pathname, 60 | char* buf, 61 | size_t bufsize); 62 | 63 | /* 64 | * static_assert() hack for pre-C11 65 | * TODO: drop after moving to -std=c11 or newer 66 | */ 67 | 68 | /* C11 guarantees _Static_assert is a keyword */ 69 | #if (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112L 70 | # if !defined(_Static_assert) 71 | # define _Static_assert(expr, msg) \ 72 | extern int (*__Static_assert_function (void)) \ 73 | [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] 74 | # endif 75 | #endif 76 | 77 | /* C23 guarantees static_assert is a keyword or a macro */ 78 | #if (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 202311L 79 | # if !defined(static_assert) 80 | # define static_assert(expr, msg) _Static_assert(expr, msg) 81 | # endif 82 | #endif 83 | 84 | #endif /* HEADER_Compat */ 85 | -------------------------------------------------------------------------------- /DateMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - DateMeter.c 3 | (C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "DateMeter.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "CRT.h" 16 | #include "Machine.h" 17 | #include "Object.h" 18 | 19 | 20 | static const int DateMeter_attributes[] = { 21 | DATE 22 | }; 23 | 24 | static void DateMeter_updateValues(Meter* this) { 25 | const Machine* host = this->host; 26 | 27 | struct tm result; 28 | const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result); 29 | strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt); 30 | } 31 | 32 | const MeterClass DateMeter_class = { 33 | .super = { 34 | .extends = Class(Meter), 35 | .delete = Meter_delete 36 | }, 37 | .updateValues = DateMeter_updateValues, 38 | .defaultMode = TEXT_METERMODE, 39 | .supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE), 40 | .maxItems = 0, 41 | .total = 0.0, 42 | .attributes = DateMeter_attributes, 43 | .name = "Date", 44 | .uiName = "Date", 45 | .caption = "Date: ", 46 | }; 47 | -------------------------------------------------------------------------------- /DateMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DateMeter 2 | #define HEADER_DateMeter 3 | /* 4 | htop - DateMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass DateMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /DateTimeMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - DateTimeMeter.c 3 | (C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "DateTimeMeter.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "CRT.h" 16 | #include "Machine.h" 17 | #include "Object.h" 18 | 19 | 20 | static const int DateTimeMeter_attributes[] = { 21 | DATETIME 22 | }; 23 | 24 | static void DateTimeMeter_updateValues(Meter* this) { 25 | const Machine* host = this->host; 26 | 27 | struct tm result; 28 | const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result); 29 | strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt); 30 | } 31 | 32 | const MeterClass DateTimeMeter_class = { 33 | .super = { 34 | .extends = Class(Meter), 35 | .delete = Meter_delete 36 | }, 37 | .updateValues = DateTimeMeter_updateValues, 38 | .defaultMode = TEXT_METERMODE, 39 | .supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE), 40 | .maxItems = 0, 41 | .total = 0.0, 42 | .attributes = DateTimeMeter_attributes, 43 | .name = "DateTime", 44 | .uiName = "Date and Time", 45 | .caption = "Date & Time: ", 46 | }; 47 | -------------------------------------------------------------------------------- /DateTimeMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DateTimeMeter 2 | #define HEADER_DateTimeMeter 3 | /* 4 | htop - DateTimeMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass DateTimeMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /DiskIOMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DiskIOMeter 2 | #define HEADER_DiskIOMeter 3 | /* 4 | htop - DiskIOMeter.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Meter.h" 13 | 14 | 15 | typedef struct DiskIOData_ { 16 | uint64_t totalBytesRead; 17 | uint64_t totalBytesWritten; 18 | uint64_t totalMsTimeSpend; 19 | uint64_t numDisks; 20 | } DiskIOData; 21 | 22 | extern const MeterClass DiskIOMeter_class; 23 | 24 | #endif /* HEADER_DiskIOMeter */ 25 | -------------------------------------------------------------------------------- /DisplayOptionsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DisplayOptionsPanel 2 | #define HEADER_DisplayOptionsPanel 3 | /* 4 | htop - DisplayOptionsPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "FunctionBar.h" 11 | #include "Panel.h" 12 | #include "ScreenManager.h" 13 | #include "Settings.h" 14 | 15 | 16 | typedef struct DisplayOptionsPanel_ { 17 | Panel super; 18 | 19 | Settings* settings; 20 | ScreenManager* scr; 21 | FunctionBar* decIncBar; 22 | } DisplayOptionsPanel; 23 | 24 | extern const PanelClass DisplayOptionsPanel_class; 25 | 26 | DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /DynamicColumn.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - DynamicColumn.c 3 | (C) 2021 Sohaib Mohammed 4 | (C) 2021 htop dev team 5 | (C) 2021 Red Hat, Inc. All Rights Reserved. 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "config.h" // IWYU pragma: keep 11 | 12 | #include "DynamicColumn.h" 13 | 14 | #include 15 | #include 16 | 17 | #include "Platform.h" 18 | #include "RichString.h" 19 | #include "XUtils.h" 20 | 21 | 22 | Hashtable* DynamicColumns_new(void) { 23 | Hashtable* dynamics = Platform_dynamicColumns(); 24 | if (!dynamics) 25 | dynamics = Hashtable_new(0, true); 26 | return dynamics; 27 | } 28 | 29 | void DynamicColumns_delete(Hashtable* dynamics) { 30 | if (dynamics) { 31 | Platform_dynamicColumnsDone(dynamics); 32 | Hashtable_delete(dynamics); 33 | } 34 | } 35 | 36 | const char* DynamicColumn_name(unsigned int key) { 37 | return Platform_dynamicColumnName(key); 38 | } 39 | 40 | void DynamicColumn_done(DynamicColumn* this) { 41 | free(this->heading); 42 | free(this->caption); 43 | free(this->description); 44 | } 45 | 46 | typedef struct { 47 | const char* name; 48 | const DynamicColumn* data; 49 | unsigned int key; 50 | } DynamicIterator; 51 | 52 | static void DynamicColumn_compare(ht_key_t key, void* value, void* data) { 53 | const DynamicColumn* column = (const DynamicColumn*)value; 54 | DynamicIterator* iter = (DynamicIterator*)data; 55 | if (String_eq(iter->name, column->name)) { 56 | iter->data = column; 57 | iter->key = key; 58 | } 59 | } 60 | 61 | const DynamicColumn* DynamicColumn_search(Hashtable* dynamics, const char* name, unsigned int* key) { 62 | DynamicIterator iter = { .key = 0, .data = NULL, .name = name }; 63 | if (dynamics) 64 | Hashtable_foreach(dynamics, DynamicColumn_compare, &iter); 65 | if (key) 66 | *key = iter.key; 67 | return iter.data; 68 | } 69 | 70 | const DynamicColumn* DynamicColumn_lookup(Hashtable* dynamics, unsigned int key) { 71 | return (const DynamicColumn*) Hashtable_get(dynamics, key); 72 | } 73 | 74 | bool DynamicColumn_writeField(const Process* proc, RichString* str, unsigned int key) { 75 | return Platform_dynamicColumnWriteField(proc, str, key); 76 | } 77 | -------------------------------------------------------------------------------- /DynamicColumn.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DynamicColumn 2 | #define HEADER_DynamicColumn 3 | /* 4 | htop - DynamicColumn.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Hashtable.h" 13 | #include "Process.h" 14 | #include "RichString.h" 15 | #include "Table.h" 16 | 17 | 18 | #define DYNAMIC_MAX_COLUMN_WIDTH 64 19 | #define DYNAMIC_DEFAULT_COLUMN_WIDTH -5 20 | 21 | typedef struct DynamicColumn_ { 22 | char name[32]; /* unique, internal-only name */ 23 | char* heading; /* displayed in main screen */ 24 | char* caption; /* displayed in setup menu (short name) */ 25 | char* description; /* displayed in setup menu (detail) */ 26 | int width; /* display width +/- for value alignment */ 27 | bool enabled; /* false == ignore this column (until enabled) */ 28 | Table* table; /* pointer to DynamicScreen or ProcessTable */ 29 | } DynamicColumn; 30 | 31 | Hashtable* DynamicColumns_new(void); 32 | 33 | void DynamicColumns_delete(Hashtable* dynamics); 34 | 35 | const char* DynamicColumn_name(unsigned int key); 36 | 37 | void DynamicColumn_done(DynamicColumn* this); 38 | 39 | const DynamicColumn* DynamicColumn_lookup(Hashtable* dynamics, unsigned int key); 40 | 41 | const DynamicColumn* DynamicColumn_search(Hashtable* dynamics, const char* name, unsigned int* key); 42 | 43 | bool DynamicColumn_writeField(const Process* proc, RichString* str, unsigned int key); 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /DynamicMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DynamicMeter 2 | #define HEADER_DynamicMeter 3 | /* 4 | htop - DynamicMeter.h 5 | (C) 2021 htop dev team 6 | (C) 2021 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 | 11 | #include 12 | 13 | #include "Hashtable.h" 14 | #include "Meter.h" 15 | 16 | 17 | typedef struct DynamicMeter_ { 18 | char name[32]; /* unique name, cannot contain spaces */ 19 | char* caption; 20 | char* description; 21 | unsigned int type; 22 | double maximum; 23 | } DynamicMeter; 24 | 25 | Hashtable* DynamicMeters_new(void); 26 | 27 | void DynamicMeters_delete(Hashtable* dynamics); 28 | 29 | const char* DynamicMeter_lookup(Hashtable* dynamics, unsigned int key); 30 | 31 | bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* key); 32 | 33 | extern const MeterClass DynamicMeter_class; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /DynamicScreen.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - DynamicScreen.c 3 | (C) 2022 Sohaib Mohammed 4 | (C) 2022-2023 htop dev team 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "DynamicScreen.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "Hashtable.h" 18 | #include "Platform.h" 19 | #include "XUtils.h" 20 | 21 | 22 | Hashtable* DynamicScreens_new(void) { 23 | return Platform_dynamicScreens(); 24 | } 25 | 26 | void DynamicScreens_delete(Hashtable* screens) { 27 | if (screens) { 28 | Platform_dynamicScreensDone(screens); 29 | Hashtable_delete(screens); 30 | } 31 | } 32 | 33 | void DynamicScreen_done(DynamicScreen* this) { 34 | free(this->caption); 35 | free(this->fields); 36 | free(this->heading); 37 | free(this->sortKey); 38 | free(this->columnKeys); 39 | } 40 | 41 | typedef struct { 42 | ht_key_t key; 43 | const char* name; 44 | bool found; 45 | } DynamicIterator; 46 | 47 | static void DynamicScreen_compare(ht_key_t key, void* value, void* data) { 48 | const DynamicScreen* screen = (const DynamicScreen*)value; 49 | DynamicIterator* iter = (DynamicIterator*)data; 50 | if (String_eq(iter->name, screen->name)) { 51 | iter->found = true; 52 | iter->key = key; 53 | } 54 | } 55 | 56 | bool DynamicScreen_search(Hashtable* screens, const char* name, ht_key_t* key) { 57 | DynamicIterator iter = { .key = 0, .name = name, .found = false }; 58 | if (screens) 59 | Hashtable_foreach(screens, DynamicScreen_compare, &iter); 60 | if (key) 61 | *key = iter.key; 62 | return iter.found; 63 | } 64 | 65 | const char* DynamicScreen_lookup(Hashtable* screens, ht_key_t key) { 66 | const DynamicScreen* screen = Hashtable_get(screens, key); 67 | return screen ? screen->name : NULL; 68 | } 69 | -------------------------------------------------------------------------------- /DynamicScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DynamicScreen 2 | #define HEADER_DynamicScreen 3 | /* 4 | htop - DynamicColumn.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Hashtable.h" 13 | #include "Panel.h" 14 | 15 | 16 | typedef struct DynamicScreen_ { 17 | char name[32]; /* unique name cannot contain any spaces */ 18 | char* heading; /* user-settable more readable name */ 19 | char* caption; /* explanatory text for screen */ 20 | char* fields; 21 | char* sortKey; 22 | char* columnKeys; 23 | int direction; 24 | } DynamicScreen; 25 | 26 | Hashtable* DynamicScreens_new(void); 27 | 28 | void DynamicScreens_delete(Hashtable* screens); 29 | 30 | void DynamicScreen_done(DynamicScreen* this); 31 | 32 | void DynamicScreens_addAvailableColumns(Panel* availableColumns, char* screen); 33 | 34 | const char* DynamicScreen_lookup(Hashtable* screens, unsigned int key); 35 | 36 | bool DynamicScreen_search(Hashtable* screens, const char* name, unsigned int* key); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /EnvScreen.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - EnvScreen.c 3 | (C) 2015,2016 Michael Klein 4 | (C) 2016,2017 Hisham H. Muhammad 5 | (C) 2020,2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "config.h" // IWYU pragma: keep 11 | 12 | #include "EnvScreen.h" 13 | 14 | #include 15 | #include 16 | 17 | #include "Macros.h" 18 | #include "Panel.h" 19 | #include "Platform.h" 20 | #include "ProvideCurses.h" 21 | #include "Vector.h" 22 | #include "XUtils.h" 23 | 24 | 25 | EnvScreen* EnvScreen_new(Process* process) { 26 | EnvScreen* this = xMalloc(sizeof(EnvScreen)); 27 | Object_setClass(this, Class(EnvScreen)); 28 | return (EnvScreen*) InfoScreen_init(&this->super, process, NULL, LINES - 2, " "); 29 | } 30 | 31 | void EnvScreen_delete(Object* this) { 32 | free(InfoScreen_done((InfoScreen*)this)); 33 | } 34 | 35 | static void EnvScreen_draw(InfoScreen* this) { 36 | InfoScreen_drawTitled(this, "Environment of process %d - %s", Process_getPid(this->process), Process_getCommand(this->process)); 37 | } 38 | 39 | static void EnvScreen_scan(InfoScreen* this) { 40 | Panel* panel = this->display; 41 | int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0); 42 | 43 | Panel_prune(panel); 44 | 45 | char* env = Platform_getProcessEnv(Process_getPid(this->process)); 46 | if (env) { 47 | for (const char* p = env; *p; p = strrchr(p, 0) + 1) 48 | InfoScreen_addLine(this, p); 49 | free(env); 50 | } 51 | else { 52 | InfoScreen_addLine(this, "Could not read process environment."); 53 | } 54 | 55 | Vector_insertionSort(this->lines); 56 | Vector_insertionSort(panel->items); 57 | Panel_setSelected(panel, idx); 58 | } 59 | 60 | const InfoScreenClass EnvScreen_class = { 61 | .super = { 62 | .extends = Class(Object), 63 | .delete = EnvScreen_delete 64 | }, 65 | .scan = EnvScreen_scan, 66 | .draw = EnvScreen_draw 67 | }; 68 | -------------------------------------------------------------------------------- /EnvScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_EnvScreen 2 | #define HEADER_EnvScreen 3 | /* 4 | htop - EnvScreen.h 5 | (C) 2015,2016 Michael Klein 6 | (C) 2016,2017 Hisham H. Muhammad 7 | (C) 2020,2021 htop dev team 8 | Released under the GNU GPLv2+, see the COPYING file 9 | in the source distribution for its full text. 10 | */ 11 | 12 | #include "InfoScreen.h" 13 | #include "Object.h" 14 | #include "Process.h" 15 | 16 | 17 | typedef struct EnvScreen_ { 18 | InfoScreen super; 19 | } EnvScreen; 20 | 21 | extern const InfoScreenClass EnvScreen_class; 22 | 23 | EnvScreen* EnvScreen_new(Process* process); 24 | 25 | void EnvScreen_delete(Object* this); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /FileDescriptorMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FileDescriptorMeter 2 | #define HEADER_FileDescriptorMeter 3 | /* 4 | htop - FileDescriptorMeter.h 5 | (C) 2022 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass FileDescriptorMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /FunctionBar.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FunctionBar 2 | #define HEADER_FunctionBar 3 | /* 4 | htop - FunctionBar.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | 13 | typedef struct FunctionBar_ { 14 | int size; 15 | char** functions; 16 | union { 17 | char** keys; 18 | const char* const* constKeys; 19 | } keys; 20 | int* events; 21 | bool staticData; 22 | } FunctionBar; 23 | 24 | #define FUNCTIONBAR_MAXEVENTS 15 25 | 26 | FunctionBar* FunctionBar_newEnterEsc(const char* enter, const char* esc); 27 | 28 | FunctionBar* FunctionBar_new(const char* const* functions, const char* const* keys, const int* events); 29 | 30 | void FunctionBar_delete(FunctionBar* this); 31 | 32 | void FunctionBar_setLabel(FunctionBar* this, int event, const char* text); 33 | 34 | int FunctionBar_draw(const FunctionBar* this); 35 | 36 | int FunctionBar_drawExtra(const FunctionBar* this, const char* buffer, int attr, bool setCursor); 37 | 38 | void FunctionBar_append(const char* buffer, int attr); 39 | 40 | int FunctionBar_synthesizeEvent(const FunctionBar* this, int pos); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Hashtable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Hashtable 2 | #define HEADER_Hashtable 3 | /* 4 | htop - Hashtable.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | 14 | typedef unsigned int ht_key_t; 15 | 16 | typedef void(*Hashtable_PairFunction)(ht_key_t key, void* value, void* userdata); 17 | 18 | typedef struct Hashtable_ Hashtable; 19 | 20 | #ifndef NDEBUG 21 | 22 | size_t Hashtable_count(const Hashtable* this); 23 | 24 | #endif /* NDEBUG */ 25 | 26 | Hashtable* Hashtable_new(size_t size, bool owner); 27 | 28 | void Hashtable_delete(Hashtable* this); 29 | 30 | void Hashtable_clear(Hashtable* this); 31 | 32 | void Hashtable_setSize(Hashtable* this, size_t size); 33 | 34 | void Hashtable_put(Hashtable* this, ht_key_t key, void* value); 35 | 36 | void* Hashtable_remove(Hashtable* this, ht_key_t key); 37 | 38 | void* Hashtable_get(Hashtable* this, ht_key_t key); 39 | 40 | void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData); 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Header.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Header 2 | #define HEADER_Header 3 | /* 4 | htop - Header.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "HeaderLayout.h" 13 | #include "Machine.h" 14 | #include "Meter.h" 15 | #include "Vector.h" 16 | 17 | 18 | typedef struct Header_ { 19 | Vector** columns; 20 | Machine* host; 21 | HeaderLayout headerLayout; 22 | int pad; 23 | int height; 24 | } Header; 25 | 26 | #define Header_forEachColumn(this_, i_) for (size_t (i_)=0, H_fEC_numColumns_ = HeaderLayout_getColumns((this_)->headerLayout); (i_) < H_fEC_numColumns_; ++(i_)) 27 | 28 | Header* Header_new(Machine* host, HeaderLayout hLayout); 29 | 30 | void Header_delete(Header* this); 31 | 32 | void Header_setLayout(Header* this, HeaderLayout hLayout); 33 | 34 | void Header_populateFromSettings(Header* this); 35 | 36 | void Header_writeBackToSettings(const Header* this); 37 | 38 | Meter* Header_addMeterByClass(Header* this, const MeterClass* type, unsigned int param, unsigned int column); 39 | 40 | void Header_reinit(Header* this); 41 | 42 | void Header_draw(const Header* this); 43 | 44 | void Header_updateData(Header* this); 45 | 46 | int Header_calculateHeight(Header* this); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /HeaderOptionsPanel.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - HeaderOptionsPanel.c 3 | (C) 2021 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "HeaderOptionsPanel.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "CRT.h" 17 | #include "FunctionBar.h" 18 | #include "Header.h" 19 | #include "HeaderLayout.h" 20 | #include "Object.h" 21 | #include "OptionItem.h" 22 | #include "ProvideCurses.h" 23 | 24 | 25 | static const char* const HeaderOptionsFunctions[] = {" ", " ", " ", " ", " ", " ", " ", " ", " ", "Done ", NULL}; 26 | 27 | static void HeaderOptionsPanel_delete(Object* object) { 28 | HeaderOptionsPanel* this = (HeaderOptionsPanel*) object; 29 | Panel_done(&this->super); 30 | free(this); 31 | } 32 | 33 | static HandlerResult HeaderOptionsPanel_eventHandler(Panel* super, int ch) { 34 | HeaderOptionsPanel* this = (HeaderOptionsPanel*) super; 35 | 36 | HandlerResult result = IGNORED; 37 | 38 | switch (ch) { 39 | case 0x0a: 40 | case 0x0d: 41 | case KEY_ENTER: 42 | case KEY_MOUSE: 43 | case KEY_RECLICK: 44 | case ' ': { 45 | int mark = Panel_getSelectedIndex(super); 46 | assert(mark >= 0); 47 | assert(mark < LAST_HEADER_LAYOUT); 48 | 49 | for (int i = 0; i < LAST_HEADER_LAYOUT; i++) 50 | CheckItem_set((CheckItem*)Panel_get(super, i), false); 51 | CheckItem_set((CheckItem*)Panel_get(super, mark), true); 52 | 53 | Header_setLayout(this->scr->header, mark); 54 | this->settings->changed = true; 55 | this->settings->lastUpdate++; 56 | 57 | ScreenManager_resize(this->scr); 58 | 59 | result = HANDLED; 60 | } 61 | } 62 | 63 | return result; 64 | } 65 | 66 | const PanelClass HeaderOptionsPanel_class = { 67 | .super = { 68 | .extends = Class(Panel), 69 | .delete = HeaderOptionsPanel_delete 70 | }, 71 | .eventHandler = HeaderOptionsPanel_eventHandler 72 | }; 73 | 74 | HeaderOptionsPanel* HeaderOptionsPanel_new(Settings* settings, ScreenManager* scr) { 75 | HeaderOptionsPanel* this = AllocThis(HeaderOptionsPanel); 76 | Panel* super = &this->super; 77 | 78 | FunctionBar* fuBar = FunctionBar_new(HeaderOptionsFunctions, NULL, NULL); 79 | Panel_init(super, 1, 1, 1, 1, Class(CheckItem), true, fuBar); 80 | 81 | this->scr = scr; 82 | this->settings = settings; 83 | 84 | Panel_setHeader(super, "Header Layout"); 85 | for (int i = 0; i < LAST_HEADER_LAYOUT; i++) { 86 | Panel_add(super, (Object*) CheckItem_newByVal(HeaderLayout_layouts[i].description, false)); 87 | } 88 | CheckItem_set((CheckItem*)Panel_get(super, scr->header->headerLayout), true); 89 | return this; 90 | } 91 | -------------------------------------------------------------------------------- /HeaderOptionsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_HeaderOptionsPanel 2 | #define HEADER_HeaderOptionsPanel 3 | /* 4 | htop - ColorsPanel.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Panel.h" 11 | #include "ScreenManager.h" 12 | #include "Settings.h" 13 | 14 | 15 | typedef struct HeaderOptionsPanel_ { 16 | Panel super; 17 | 18 | ScreenManager* scr; 19 | Settings* settings; 20 | } HeaderOptionsPanel; 21 | 22 | extern const PanelClass HeaderOptionsPanel_class; 23 | 24 | HeaderOptionsPanel* HeaderOptionsPanel_new(Settings* settings, ScreenManager* scr); 25 | 26 | #endif /* HEADER_HeaderOptionsPanel */ 27 | -------------------------------------------------------------------------------- /HostnameMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - HostnameMeter.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "HostnameMeter.h" 11 | 12 | #include "CRT.h" 13 | #include "Object.h" 14 | #include "Platform.h" 15 | 16 | 17 | static const int HostnameMeter_attributes[] = { 18 | HOSTNAME 19 | }; 20 | 21 | static void HostnameMeter_updateValues(Meter* this) { 22 | Platform_getHostname(this->txtBuffer, sizeof(this->txtBuffer)); 23 | } 24 | 25 | const MeterClass HostnameMeter_class = { 26 | .super = { 27 | .extends = Class(Meter), 28 | .delete = Meter_delete 29 | }, 30 | .updateValues = HostnameMeter_updateValues, 31 | .defaultMode = TEXT_METERMODE, 32 | .supportedModes = (1 << TEXT_METERMODE), 33 | .maxItems = 0, 34 | .total = 0.0, 35 | .attributes = HostnameMeter_attributes, 36 | .name = "Hostname", 37 | .uiName = "Hostname", 38 | .caption = "Hostname: ", 39 | }; 40 | -------------------------------------------------------------------------------- /HostnameMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_HostnameMeter 2 | #define HEADER_HostnameMeter 3 | /* 4 | htop - HostnameMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass HostnameMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /IncSet.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_IncSet 2 | #define HEADER_IncSet 3 | /* 4 | htop - IncSet.h 5 | (C) 2005-2012 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "FunctionBar.h" 14 | #include "Panel.h" 15 | #include "Vector.h" 16 | 17 | 18 | #define INCMODE_MAX 128 19 | 20 | typedef enum { 21 | INC_SEARCH = 0, 22 | INC_FILTER = 1 23 | } IncType; 24 | 25 | typedef struct IncMode_ { 26 | char buffer[INCMODE_MAX + 1]; 27 | size_t index; 28 | FunctionBar* bar; 29 | bool isFilter; 30 | } IncMode; 31 | 32 | typedef struct IncSet_ { 33 | IncMode modes[2]; 34 | IncMode* active; 35 | Panel* panel; 36 | FunctionBar* defaultBar; 37 | bool filtering; 38 | bool found; 39 | } IncSet; 40 | 41 | static inline const char* IncSet_filter(const IncSet* this) { 42 | return this->filtering ? this->modes[INC_FILTER].buffer : NULL; 43 | } 44 | 45 | void IncSet_setFilter(IncSet* this, const char* filter); 46 | 47 | typedef const char* (*IncMode_GetPanelValue)(Panel*, int); 48 | 49 | void IncSet_reset(IncSet* this, IncType type); 50 | 51 | IncSet* IncSet_new(FunctionBar* bar); 52 | 53 | void IncSet_delete(IncSet* this); 54 | 55 | bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue getPanelValue, Vector* lines); 56 | 57 | const char* IncSet_getListItemValue(Panel* panel, int i); 58 | 59 | void IncSet_activate(IncSet* this, IncType type, Panel* panel); 60 | 61 | void IncSet_drawBar(const IncSet* this, int attr); 62 | 63 | int IncSet_synthesizeEvent(IncSet* this, int x); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /InfoScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_InfoScreen 2 | #define HEADER_InfoScreen 3 | /* 4 | htop - InfoScreen.h 5 | (C) 2016 Hisham H. Muhammad 6 | (C) 2020,2022 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | 13 | #include "FunctionBar.h" 14 | #include "IncSet.h" 15 | #include "Macros.h" 16 | #include "Object.h" 17 | #include "Panel.h" 18 | #include "Process.h" 19 | #include "Vector.h" 20 | 21 | 22 | typedef struct InfoScreen_ { 23 | Object super; 24 | const Process* process; 25 | Panel* display; 26 | IncSet* inc; 27 | Vector* lines; 28 | } InfoScreen; 29 | 30 | typedef void(*InfoScreen_Scan)(InfoScreen*); 31 | typedef void(*InfoScreen_Draw)(InfoScreen*); 32 | typedef void(*InfoScreen_OnErr)(InfoScreen*); 33 | typedef bool(*InfoScreen_OnKey)(InfoScreen*, int); 34 | 35 | typedef struct InfoScreenClass_ { 36 | const ObjectClass super; 37 | const InfoScreen_Scan scan; 38 | const InfoScreen_Draw draw; 39 | const InfoScreen_OnErr onErr; 40 | const InfoScreen_OnKey onKey; 41 | } InfoScreenClass; 42 | 43 | #define As_InfoScreen(this_) ((const InfoScreenClass*)(((InfoScreen*)(this_))->super.klass)) 44 | #define InfoScreen_scan(this_) As_InfoScreen(this_)->scan((InfoScreen*)(this_)) 45 | #define InfoScreen_draw(this_) As_InfoScreen(this_)->draw((InfoScreen*)(this_)) 46 | #define InfoScreen_onErr(this_) As_InfoScreen(this_)->onErr((InfoScreen*)(this_)) 47 | #define InfoScreen_onKey(this_, ch_) As_InfoScreen(this_)->onKey((InfoScreen*)(this_), ch_) 48 | 49 | InfoScreen* InfoScreen_init(InfoScreen* this, const Process* process, FunctionBar* bar, int height, const char* panelHeader); 50 | 51 | InfoScreen* InfoScreen_done(InfoScreen* this); 52 | 53 | ATTR_FORMAT(printf, 2, 3) 54 | void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...); 55 | 56 | void InfoScreen_addLine(InfoScreen* this, const char* line); 57 | 58 | void InfoScreen_appendLine(InfoScreen* this, const char* line); 59 | 60 | void InfoScreen_run(InfoScreen* this); 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /ListItem.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - ListItem.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "ListItem.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "CRT.h" 17 | #include "RichString.h" 18 | #include "XUtils.h" 19 | 20 | 21 | void ListItem_delete(Object* cast) { 22 | ListItem* this = (ListItem*)cast; 23 | free(this->value); 24 | free(this); 25 | } 26 | 27 | void ListItem_display(const Object* cast, RichString* out) { 28 | const ListItem* const this = (const ListItem*)cast; 29 | assert (this != NULL); 30 | 31 | if (this->moving) { 32 | RichString_writeWide(out, CRT_colors[DEFAULT_COLOR], 33 | #ifdef HAVE_LIBNCURSESW 34 | CRT_utf8 ? "↕ " : 35 | #endif 36 | "+ "); 37 | } 38 | RichString_appendWide(out, CRT_colors[DEFAULT_COLOR], this->value); 39 | } 40 | 41 | void ListItem_init(ListItem* this, const char* value, int key) { 42 | this->value = xStrdup(value); 43 | this->key = key; 44 | this->moving = false; 45 | } 46 | 47 | ListItem* ListItem_new(const char* value, int key) { 48 | ListItem* this = AllocThis(ListItem); 49 | ListItem_init(this, value, key); 50 | return this; 51 | } 52 | 53 | void ListItem_append(ListItem* this, const char* text) { 54 | size_t oldLen = strlen(this->value); 55 | size_t textLen = strlen(text); 56 | size_t newLen = oldLen + textLen; 57 | this->value = xRealloc(this->value, newLen + 1); 58 | memcpy(this->value + oldLen, text, textLen); 59 | this->value[newLen] = '\0'; 60 | } 61 | 62 | int ListItem_compare(const void* cast1, const void* cast2) { 63 | const ListItem* obj1 = (const ListItem*) cast1; 64 | const ListItem* obj2 = (const ListItem*) cast2; 65 | return strcmp(obj1->value, obj2->value); 66 | } 67 | 68 | const ObjectClass ListItem_class = { 69 | .display = ListItem_display, 70 | .delete = ListItem_delete, 71 | .compare = ListItem_compare 72 | }; 73 | -------------------------------------------------------------------------------- /ListItem.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ListItem 2 | #define HEADER_ListItem 3 | /* 4 | htop - ListItem.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Object.h" 13 | #include "RichString.h" 14 | 15 | 16 | typedef struct ListItem_ { 17 | Object super; 18 | char* value; 19 | int key; 20 | bool moving; 21 | } ListItem; 22 | 23 | extern const ObjectClass ListItem_class; 24 | 25 | void ListItem_delete(Object* cast); 26 | 27 | void ListItem_display(const Object* cast, RichString* out); 28 | 29 | void ListItem_init(ListItem* this, const char* value, int key); 30 | 31 | ListItem* ListItem_new(const char* value, int key); 32 | 33 | void ListItem_append(ListItem* this, const char* text); 34 | 35 | int ListItem_compare(const void* cast1, const void* cast2); 36 | 37 | static inline const char* ListItem_getRef(const ListItem* this) { 38 | return this->value; 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /LoadAverageMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_LoadAverageMeter 2 | #define HEADER_LoadAverageMeter 3 | /* 4 | htop - LoadAverageMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass LoadAverageMeter_class; 14 | 15 | extern const MeterClass LoadMeter_class; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /Machine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Machine 2 | #define HEADER_Machine 3 | /* 4 | htop - Machine.h 5 | (C) 2023 Red Hat, Inc. 6 | (C) 2004,2005 Hisham H. Muhammad 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "Panel.h" 18 | #include "Settings.h" 19 | #include "Table.h" 20 | #include "UsersTable.h" 21 | 22 | #ifdef HAVE_LIBHWLOC 23 | #include 24 | #endif 25 | 26 | 27 | #ifndef MAX_NAME 28 | #define MAX_NAME 128 29 | #endif 30 | 31 | #ifndef MAX_READ 32 | #define MAX_READ 2048 33 | #endif 34 | 35 | typedef unsigned long long int memory_t; 36 | #define MEMORY_MAX ULLONG_MAX 37 | 38 | typedef struct Machine_ { 39 | struct Settings_* settings; 40 | 41 | struct timeval realtime; /* time of the current sample */ 42 | uint64_t realtimeMs; /* current time in milliseconds */ 43 | uint64_t monotonicMs; /* same, but from monotonic clock */ 44 | uint64_t prevMonotonicMs; /* time in milliseconds from monotonic clock of previous scan */ 45 | 46 | int64_t iterationsRemaining; 47 | 48 | #ifdef HAVE_LIBHWLOC 49 | hwloc_topology_t topology; 50 | bool topologyOk; 51 | #endif 52 | 53 | memory_t totalMem; 54 | memory_t usedMem; 55 | memory_t buffersMem; 56 | memory_t cachedMem; 57 | memory_t sharedMem; 58 | memory_t availableMem; 59 | 60 | memory_t totalSwap; 61 | memory_t usedSwap; 62 | memory_t cachedSwap; 63 | 64 | unsigned int activeCPUs; 65 | unsigned int existingCPUs; 66 | 67 | UsersTable* usersTable; 68 | uid_t htopUserId; 69 | uid_t maxUserId; /* recently observed */ 70 | uid_t userId; /* selected row user ID */ 71 | 72 | size_t tableCount; 73 | Table **tables; 74 | Table *activeTable; 75 | Table *processTable; 76 | } Machine; 77 | 78 | 79 | Machine* Machine_new(UsersTable* usersTable, uid_t userId); 80 | 81 | void Machine_init(Machine* this, UsersTable* usersTable, uid_t userId); 82 | 83 | void Machine_delete(Machine* this); 84 | 85 | void Machine_done(Machine* this); 86 | 87 | bool Machine_isCPUonline(const Machine* this, unsigned int id); 88 | 89 | void Machine_populateTablesFromSettings(Machine* this, Settings* settings, Table* processTable); 90 | 91 | void Machine_setTablesPanel(Machine* this, Panel* panel); 92 | 93 | void Machine_scan(Machine* this); 94 | 95 | void Machine_scanTables(Machine* this); 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /MainPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_MainPanel 2 | #define HEADER_MainPanel 3 | /* 4 | htop - ColumnsPanel.h 5 | (C) 2004-2015 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 | 11 | #include 12 | 13 | #include "Action.h" 14 | #include "FunctionBar.h" 15 | #include "IncSet.h" 16 | #include "Object.h" 17 | #include "Panel.h" 18 | #include "Row.h" 19 | 20 | 21 | typedef struct MainPanel_ { 22 | Panel super; 23 | State* state; 24 | IncSet* inc; 25 | Htop_Action* keys; 26 | FunctionBar* processBar; /* function bar with process-specific actions */ 27 | FunctionBar* readonlyBar; /* function bar without process actions (ro) */ 28 | unsigned int idSearch; 29 | } MainPanel; 30 | 31 | typedef bool(*MainPanel_foreachRowFn)(Row*, Arg); 32 | 33 | #define MainPanel_getFunctionBar(this_) (((Panel*)(this_))->defaultBar) 34 | 35 | // update the Label Keys in the MainPanel bar, list: list / tree mode, filter: filter (inc) active / inactive 36 | void MainPanel_updateLabels(MainPanel* this, bool list, bool filter); 37 | 38 | int MainPanel_selectedRow(MainPanel* this); 39 | 40 | bool MainPanel_foreachRow(MainPanel* this, MainPanel_foreachRowFn fn, Arg arg, bool* wasAnyTagged); 41 | 42 | extern const PanelClass MainPanel_class; 43 | 44 | MainPanel* MainPanel_new(void); 45 | 46 | void MainPanel_setState(MainPanel* this, State* state); 47 | 48 | void MainPanel_setFunctionBar(MainPanel* this, bool readonly); 49 | 50 | void MainPanel_delete(Object* object); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /MemoryMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_MemoryMeter 2 | #define HEADER_MemoryMeter 3 | /* 4 | htop - MemoryMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | typedef enum { 13 | MEMORY_METER_USED = 0, 14 | MEMORY_METER_SHARED = 1, 15 | MEMORY_METER_COMPRESSED = 2, 16 | MEMORY_METER_BUFFERS = 3, 17 | MEMORY_METER_CACHE = 4, 18 | MEMORY_METER_AVAILABLE = 5, 19 | MEMORY_METER_ITEMCOUNT = 6, // number of entries in this enum 20 | } MemoryMeterValues; 21 | 22 | extern const MeterClass MemoryMeter_class; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /MemorySwapMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_MemorySwapMeter 2 | #define HEADER_MemorySwapMeter 3 | /* 4 | htop - MemorySwapMeter.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass MemorySwapMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /MeterMode.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_MeterMode 2 | #define HEADER_MeterMode 3 | /* 4 | htop - MeterMode.h 5 | (C) 2024 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | enum MeterModeId_ { 12 | /* Meter mode 0 is reserved */ 13 | BAR_METERMODE = 1, 14 | TEXT_METERMODE, 15 | GRAPH_METERMODE, 16 | LED_METERMODE, 17 | LAST_METERMODE 18 | }; 19 | 20 | typedef unsigned int MeterModeId; 21 | 22 | #define METERMODE_DEFAULT_SUPPORTED ( \ 23 | (1 << BAR_METERMODE) | \ 24 | (1 << TEXT_METERMODE) | \ 25 | (1 << GRAPH_METERMODE) | \ 26 | (1 << LED_METERMODE) | \ 27 | 0) // Avoids edits when updating 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /MetersPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_MetersPanel 2 | #define HEADER_MetersPanel 3 | /* 4 | htop - MetersPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Panel.h" 13 | #include "ScreenManager.h" 14 | #include "Settings.h" 15 | #include "Vector.h" 16 | 17 | 18 | struct MetersPanel_; 19 | typedef struct MetersPanel_ MetersPanel; 20 | 21 | struct MetersPanel_ { 22 | Panel super; 23 | 24 | Settings* settings; 25 | Vector* meters; 26 | ScreenManager* scr; 27 | MetersPanel* leftNeighbor; 28 | MetersPanel* rightNeighbor; 29 | bool moving; 30 | }; 31 | 32 | void MetersPanel_cleanup(void); 33 | 34 | void MetersPanel_setMoving(MetersPanel* this, bool moving); 35 | 36 | extern const PanelClass MetersPanel_class; 37 | 38 | MetersPanel* MetersPanel_new(Settings* settings, const char* header, Vector* meters, ScreenManager* scr); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | 2 | See the commit history for news of the past. 3 | See the bug tracker for news of the future. 4 | Run the program for news of the present. 5 | -------------------------------------------------------------------------------- /NetworkIOMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_NetworkIOMeter 2 | #define HEADER_NetworkIOMeter 3 | /* 4 | htop - NetworkIOMeter.h 5 | (C) 2020-2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Meter.h" 13 | 14 | 15 | typedef struct NetworkIOData_ { 16 | uint64_t bytesReceived; 17 | uint64_t packetsReceived; 18 | uint64_t bytesTransmitted; 19 | uint64_t packetsTransmitted; 20 | } NetworkIOData; 21 | 22 | extern const MeterClass NetworkIOMeter_class; 23 | 24 | #endif /* HEADER_NetworkIOMeter */ 25 | -------------------------------------------------------------------------------- /Object.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - Object.c 3 | (C) 2004-2012 Hisham H. Muhammad 4 | (C) 2020 Red Hat, Inc. All Rights Reserved. 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "Object.h" 12 | 13 | #include 14 | 15 | 16 | const ObjectClass Object_class = { 17 | .extends = NULL 18 | }; 19 | 20 | bool Object_isA(const Object* o, const ObjectClass* klass) { 21 | if (!o) 22 | return false; 23 | 24 | for (const ObjectClass* type = o->klass; type; type = type->extends) { 25 | if (type == klass) { 26 | return true; 27 | } 28 | } 29 | 30 | return false; 31 | } 32 | -------------------------------------------------------------------------------- /Object.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Object 2 | #define HEADER_Object 3 | /* 4 | htop - Object.h 5 | (C) 2004-2012 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 | 11 | #include 12 | #include 13 | 14 | #include "RichString.h" 15 | #include "XUtils.h" // IWYU pragma: keep 16 | 17 | 18 | struct Object_; 19 | typedef struct Object_ Object; 20 | 21 | typedef void(*Object_Display)(const Object*, RichString*); 22 | typedef int(*Object_Compare)(const void*, const void*); 23 | typedef void(*Object_Delete)(Object*); 24 | 25 | #define Object_getClass(obj_) ((const Object*)(obj_))->klass 26 | #define Object_setClass(obj_, class_) (((Object*)(obj_))->klass = (const ObjectClass*) (class_)) 27 | 28 | #define Object_delete(obj_) (assert(Object_getClass(obj_)->delete), Object_getClass(obj_)->delete((Object*)(obj_))) 29 | #define Object_displayFn(obj_) Object_getClass(obj_)->display 30 | #define Object_display(obj_, str_) (assert(Object_getClass(obj_)->display), Object_getClass(obj_)->display((const Object*)(obj_), str_)) 31 | #define Object_compare(obj_, other_) (assert(Object_getClass(obj_)->compare), Object_getClass(obj_)->compare((const void*)(obj_), other_)) 32 | 33 | #define Class(class_) ((const ObjectClass*)(&(class_ ## _class))) 34 | 35 | #define AllocThis(class_) (class_*) xMalloc(sizeof(class_)); Object_setClass(this, Class(class_)) 36 | 37 | typedef struct ObjectClass_ { 38 | const void* const extends; 39 | const Object_Display display; 40 | const Object_Delete delete; 41 | const Object_Compare compare; 42 | } ObjectClass; 43 | 44 | struct Object_ { 45 | const ObjectClass* klass; 46 | }; 47 | 48 | typedef union { 49 | int i; 50 | void* v; 51 | } Arg; 52 | 53 | extern const ObjectClass Object_class; 54 | 55 | bool Object_isA(const Object* o, const ObjectClass* klass); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /OpenFilesScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OpenFilesScreen 2 | #define HEADER_OpenFilesScreen 3 | /* 4 | htop - OpenFilesScreen.h 5 | (C) 2005-2006 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "InfoScreen.h" 13 | #include "Object.h" 14 | #include "Process.h" 15 | 16 | 17 | typedef struct OpenFilesScreen_ { 18 | InfoScreen super; 19 | pid_t pid; 20 | } OpenFilesScreen; 21 | 22 | extern const InfoScreenClass OpenFilesScreen_class; 23 | 24 | OpenFilesScreen* OpenFilesScreen_new(const Process* process); 25 | 26 | void OpenFilesScreen_delete(Object* this); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /OptionItem.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OptionItem 2 | #define HEADER_OptionItem 3 | /* 4 | htop - OptionItem.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Object.h" 13 | 14 | 15 | enum OptionItemType { 16 | OPTION_ITEM_TEXT, 17 | OPTION_ITEM_CHECK, 18 | OPTION_ITEM_NUMBER, 19 | }; 20 | 21 | typedef struct OptionItemClass_ { 22 | const ObjectClass super; 23 | 24 | enum OptionItemType kind; 25 | } OptionItemClass; 26 | 27 | #define As_OptionItem(this_) ((const OptionItemClass*)((this_)->super.klass)) 28 | #define OptionItem_kind(this_) As_OptionItem(this_)->kind 29 | 30 | typedef struct OptionItem_ { 31 | Object super; 32 | 33 | char* text; 34 | } OptionItem; 35 | 36 | typedef struct TextItem_ { 37 | OptionItem super; 38 | 39 | char* text; 40 | } TextItem; 41 | 42 | typedef struct CheckItem_ { 43 | OptionItem super; 44 | 45 | bool* ref; 46 | bool value; 47 | } CheckItem; 48 | 49 | typedef struct NumberItem_ { 50 | OptionItem super; 51 | 52 | char* text; 53 | int* ref; 54 | int value; 55 | int scale; 56 | int min; 57 | int max; 58 | } NumberItem; 59 | 60 | extern const OptionItemClass OptionItem_class; 61 | extern const OptionItemClass TextItem_class; 62 | extern const OptionItemClass CheckItem_class; 63 | extern const OptionItemClass NumberItem_class; 64 | 65 | TextItem* TextItem_new(const char* text); 66 | 67 | CheckItem* CheckItem_newByRef(const char* text, bool* ref); 68 | CheckItem* CheckItem_newByVal(const char* text, bool value); 69 | bool CheckItem_get(const CheckItem* this); 70 | void CheckItem_set(CheckItem* this, bool value); 71 | void CheckItem_toggle(CheckItem* this); 72 | 73 | NumberItem* NumberItem_newByRef(const char* text, int* ref, int scale, int min, int max); 74 | NumberItem* NumberItem_newByVal(const char* text, int value, int scale, int min, int max); 75 | int NumberItem_get(const NumberItem* this); 76 | void NumberItem_decrease(NumberItem* this); 77 | void NumberItem_increase(NumberItem* this); 78 | void NumberItem_toggle(NumberItem* this); 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /ProcessLocksScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ProcessLocksScreen 2 | #define HEADER_ProcessLocksScreen 3 | /* 4 | htop - ProcessLocksScreen.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "InfoScreen.h" 15 | #include "Object.h" 16 | #include "Process.h" 17 | 18 | 19 | typedef struct ProcessLocksScreen_ { 20 | InfoScreen super; 21 | pid_t pid; 22 | } ProcessLocksScreen; 23 | 24 | typedef struct FileLocks_Data_ { 25 | char* locktype; 26 | char* exclusive; 27 | char* readwrite; 28 | char* filename; 29 | int fd; 30 | dev_t dev; 31 | uint64_t inode; 32 | uint64_t start; 33 | uint64_t end; 34 | } FileLocks_Data; 35 | 36 | typedef struct FileLocks_LockData_ { 37 | FileLocks_Data data; 38 | struct FileLocks_LockData_* next; 39 | } FileLocks_LockData; 40 | 41 | typedef struct FileLocks_ProcessData_ { 42 | bool error; 43 | struct FileLocks_LockData_* locks; 44 | } FileLocks_ProcessData; 45 | 46 | extern const InfoScreenClass ProcessLocksScreen_class; 47 | 48 | ProcessLocksScreen* ProcessLocksScreen_new(const Process* process); 49 | 50 | void ProcessLocksScreen_delete(Object* this); 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ProcessTable.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - ProcessTable.c 3 | (C) 2004,2005 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "ProcessTable.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "Hashtable.h" 16 | #include "Row.h" 17 | #include "Settings.h" 18 | #include "Vector.h" 19 | 20 | 21 | void ProcessTable_init(ProcessTable* this, const ObjectClass* klass, Machine* host, Hashtable* pidMatchList) { 22 | Table_init(&this->super, klass, host); 23 | 24 | this->pidMatchList = pidMatchList; 25 | } 26 | 27 | void ProcessTable_done(ProcessTable* this) { 28 | Table_done(&this->super); 29 | } 30 | 31 | Process* ProcessTable_getProcess(ProcessTable* this, pid_t pid, bool* preExisting, Process_New constructor) { 32 | const Table* table = &this->super; 33 | Process* proc = (Process*) Hashtable_get(table->table, pid); 34 | *preExisting = proc != NULL; 35 | if (proc) { 36 | assert(Vector_indexOf(table->rows, proc, Row_idEqualCompare) != -1); 37 | assert(Process_getPid(proc) == pid); 38 | } else { 39 | proc = constructor(table->host); 40 | assert(proc->cmdline == NULL); 41 | Process_setPid(proc, pid); 42 | } 43 | return proc; 44 | } 45 | 46 | static void ProcessTable_prepareEntries(Table* super) { 47 | ProcessTable* this = (ProcessTable*) super; 48 | this->totalTasks = 0; 49 | this->userlandThreads = 0; 50 | this->kernelThreads = 0; 51 | this->runningTasks = 0; 52 | 53 | Table_prepareEntries(super); 54 | } 55 | 56 | static void ProcessTable_iterateEntries(Table* super) { 57 | ProcessTable* this = (ProcessTable*) super; 58 | // calling into platform-specific code 59 | ProcessTable_goThroughEntries(this); 60 | } 61 | 62 | static void ProcessTable_cleanupEntries(Table* super) { 63 | Machine* host = super->host; 64 | const Settings* settings = host->settings; 65 | 66 | // Finish process table update, culling any exit'd processes 67 | for (int i = Vector_size(super->rows) - 1; i >= 0; i--) { 68 | Process* p = (Process*) Vector_get(super->rows, i); 69 | 70 | // tidy up Process state after refreshing the ProcessTable table 71 | Process_makeCommandStr(p, settings); 72 | 73 | // keep track of the highest UID for column scaling 74 | if (p->st_uid > host->maxUserId) 75 | host->maxUserId = p->st_uid; 76 | 77 | Table_cleanupRow(super, (Row*) p, i); 78 | } 79 | 80 | // compact the table in case of deletions 81 | Table_compact(super); 82 | } 83 | 84 | const TableClass ProcessTable_class = { 85 | .super = { 86 | .extends = Class(Table), 87 | .delete = ProcessTable_delete, 88 | }, 89 | .prepare = ProcessTable_prepareEntries, 90 | .iterate = ProcessTable_iterateEntries, 91 | .cleanup = ProcessTable_cleanupEntries, 92 | }; 93 | -------------------------------------------------------------------------------- /ProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ProcessTable 2 | #define HEADER_ProcessTable 3 | /* 4 | htop - ProcessTable.h 5 | (C) 2004,2005 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "Hashtable.h" 14 | #include "Machine.h" 15 | #include "Object.h" 16 | #include "Process.h" 17 | #include "Table.h" 18 | 19 | 20 | typedef struct ProcessTable_ { 21 | Table super; 22 | 23 | Hashtable* pidMatchList; 24 | 25 | unsigned int totalTasks; 26 | unsigned int runningTasks; 27 | unsigned int userlandThreads; 28 | unsigned int kernelThreads; 29 | } ProcessTable; 30 | 31 | /* Implemented by platforms */ 32 | ProcessTable* ProcessTable_new(Machine* host, Hashtable* pidMatchList); 33 | void ProcessTable_delete(Object* cast); 34 | void ProcessTable_goThroughEntries(ProcessTable* this); 35 | 36 | void ProcessTable_init(ProcessTable* this, const ObjectClass* klass, Machine* host, Hashtable* pidMatchList); 37 | 38 | void ProcessTable_done(ProcessTable* this); 39 | 40 | extern const TableClass ProcessTable_class; 41 | 42 | static inline void ProcessTable_add(ProcessTable* this, Process* process) { 43 | Table_add(&this->super, &process->super); 44 | } 45 | 46 | Process* ProcessTable_getProcess(ProcessTable* this, pid_t pid, bool* preExisting, Process_New constructor); 47 | 48 | static inline Process* ProcessTable_findProcess(ProcessTable* this, pid_t pid) { 49 | return (Process*) Table_findRow(&this->super, pid); 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ProvideCurses.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ProvideCurses 2 | #define HEADER_ProvideCurses 3 | /* 4 | htop - ProvideCurses.h 5 | (C) 2004,2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | // This header is also used in tests by configure, thus conditionally 12 | // including "config.h". 13 | #if defined(HAVE_CONFIG_H) 14 | #include "config.h" // IWYU pragma: keep 15 | #endif 16 | 17 | // IWYU pragma: begin_exports 18 | 19 | #if defined(HAVE_NCURSESW_CURSES_H) 20 | #include 21 | #elif defined(HAVE_NCURSES_NCURSES_H) 22 | #include 23 | #elif defined(HAVE_NCURSES_CURSES_H) 24 | #include 25 | #elif defined(HAVE_NCURSES_H) 26 | #include 27 | #elif defined(HAVE_CURSES_H) 28 | #include 29 | #endif 30 | 31 | #ifdef HAVE_LIBNCURSESW 32 | #include 33 | #include 34 | #endif 35 | 36 | // IWYU pragma: end_exports 37 | 38 | #endif // HEADER_ProvideCurses 39 | -------------------------------------------------------------------------------- /ProvideTerm.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ProvideTerm 2 | #define HEADER_ProvideTerm 3 | /* 4 | htop - ProvideTerm.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "config.h" // IWYU pragma: keep 11 | 12 | // IWYU pragma: begin_exports 13 | 14 | #if defined(HAVE_NCURSESW_TERM_H) 15 | #include 16 | #elif defined(HAVE_NCURSES_TERM_H) 17 | #include 18 | #elif defined(HAVE_TERM_H) 19 | #include 20 | #endif 21 | 22 | // IWYU pragma: end_exports 23 | 24 | #endif // HEADER_ProvideTerm 25 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /RowField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_RowField 2 | #define HEADER_RowField 3 | /* 4 | htop - RowField.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "ProcessField.h" // platform-specific fields reserved for processes 11 | 12 | 13 | typedef enum ReservedFields_ { 14 | NULL_FIELD = 0, 15 | PID = 1, 16 | COMM = 2, 17 | STATE = 3, 18 | PPID = 4, 19 | PGRP = 5, 20 | SESSION = 6, 21 | TTY = 7, 22 | TPGID = 8, 23 | MINFLT = 10, 24 | MAJFLT = 12, 25 | PRIORITY = 18, 26 | NICE = 19, 27 | STARTTIME = 21, 28 | PROCESSOR = 38, 29 | M_VIRT = 39, 30 | M_RESIDENT = 40, 31 | ST_UID = 46, 32 | PERCENT_CPU = 47, 33 | PERCENT_MEM = 48, 34 | USER = 49, 35 | TIME = 50, 36 | NLWP = 51, 37 | TGID = 52, 38 | PERCENT_NORM_CPU = 53, 39 | ELAPSED = 54, 40 | SCHEDULERPOLICY = 55, 41 | PROC_COMM = 124, 42 | PROC_EXE = 125, 43 | CWD = 126, 44 | 45 | /* Platform specific fields, defined in ${platform}/ProcessField.h */ 46 | PLATFORM_PROCESS_FIELDS 47 | 48 | /* Do not add new fields after this entry (dynamic entries follow) */ 49 | LAST_RESERVED_FIELD 50 | } ReservedFields; 51 | 52 | /* Follow ReservedField entries with dynamic fields defined at runtime */ 53 | #define ROW_DYNAMIC_FIELDS LAST_RESERVED_FIELD 54 | typedef int32_t RowField; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Scheduling.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Scheduling 2 | #define HEADER_Scheduling 3 | /* 4 | htop - Scheduling.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "Object.h" 14 | #include "Panel.h" 15 | #include "Process.h" 16 | #include "Row.h" 17 | 18 | 19 | #if defined(HAVE_SCHED_SETSCHEDULER) && defined(HAVE_SCHED_GETSCHEDULER) 20 | #define SCHEDULER_SUPPORT 21 | 22 | typedef struct { 23 | const char* name; 24 | int id; 25 | bool prioritySupport; 26 | } SchedulingPolicy; 27 | 28 | #define SCHEDULINGPANEL_INITSELECTEDPOLICY SCHED_OTHER 29 | #define SCHEDULINGPANEL_INITSELECTEDPRIORITY 50 30 | 31 | Panel* Scheduling_newPolicyPanel(int preSelectedPolicy); 32 | void Scheduling_togglePolicyPanelResetOnFork(Panel* schedPanel); 33 | 34 | Panel* Scheduling_newPriorityPanel(int policy, int preSelectedPriority); 35 | 36 | 37 | typedef struct { 38 | int policy; 39 | int priority; 40 | } SchedulingArg; 41 | 42 | bool Scheduling_rowSetPolicy(Row* proc, Arg arg); 43 | 44 | const char* Scheduling_formatPolicy(int policy); 45 | 46 | void Scheduling_readProcessPolicy(Process* proc); 47 | 48 | #endif 49 | 50 | #endif /* HEADER_Scheduling */ 51 | -------------------------------------------------------------------------------- /ScreenManager.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ScreenManager 2 | #define HEADER_ScreenManager 3 | /* 4 | htop - ScreenManager.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Action.h" 13 | #include "Header.h" 14 | #include "Machine.h" 15 | #include "Panel.h" 16 | #include "Vector.h" 17 | 18 | 19 | typedef struct ScreenManager_ { 20 | int x1; 21 | int y1; 22 | int x2; 23 | int y2; 24 | Vector* panels; 25 | const char* name; 26 | int panelCount; 27 | Header* header; 28 | Machine* host; 29 | State* state; 30 | bool allowFocusChange; 31 | } ScreenManager; 32 | 33 | ScreenManager* ScreenManager_new(Header* header, Machine* host, State* state, bool owner); 34 | 35 | void ScreenManager_delete(ScreenManager* this); 36 | 37 | int ScreenManager_size(const ScreenManager* this); 38 | 39 | void ScreenManager_add(ScreenManager* this, Panel* item, int size); 40 | 41 | void ScreenManager_insert(ScreenManager* this, Panel* item, int size, int idx); 42 | 43 | Panel* ScreenManager_remove(ScreenManager* this, int idx); 44 | 45 | void ScreenManager_resize(ScreenManager* this); 46 | 47 | void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey, const char* name); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ScreenTabsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ScreenTabsPanel 2 | #define HEADER_ScreenTabsPanel 3 | /* 4 | htop - ScreenTabsPanel.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "DynamicScreen.h" 11 | #include "ListItem.h" 12 | #include "Object.h" 13 | #include "Panel.h" 14 | #include "ScreensPanel.h" 15 | #include "ScreenManager.h" 16 | #include "Settings.h" 17 | 18 | 19 | typedef struct ScreenNamesPanel_ { 20 | Panel super; 21 | 22 | ScreenManager* scr; 23 | Settings* settings; 24 | char buffer[SCREEN_NAME_LEN + 1]; 25 | DynamicScreen* ds; 26 | char* saved; 27 | int cursor; 28 | ListItem* renamingItem; 29 | } ScreenNamesPanel; 30 | 31 | typedef struct ScreenNameListItem_ { 32 | ListItem super; 33 | ScreenSettings* ss; 34 | } ScreenNameListItem; 35 | 36 | typedef struct ScreenTabsPanel_ { 37 | Panel super; 38 | 39 | ScreenManager* scr; 40 | Settings* settings; 41 | ScreenNamesPanel* names; 42 | int cursor; 43 | } ScreenTabsPanel; 44 | 45 | typedef struct ScreenTabListItem_ { 46 | ListItem super; 47 | DynamicScreen* ds; 48 | } ScreenTabListItem; 49 | 50 | 51 | ScreenTabsPanel* ScreenTabsPanel_new(Settings* settings); 52 | 53 | extern ObjectClass ScreenNameListItem_class; 54 | 55 | ScreenNameListItem* ScreenNameListItem_new(const char* value, ScreenSettings* ss); 56 | 57 | extern PanelClass ScreenNamesPanel_class; 58 | 59 | ScreenNamesPanel* ScreenNamesPanel_new(Settings* settings); 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /ScreensPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ScreensPanel 2 | #define HEADER_ScreensPanel 3 | /* 4 | htop - ScreensPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | (C) 2020-2022 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | 13 | #include "AvailableColumnsPanel.h" 14 | #include "ColumnsPanel.h" 15 | #include "DynamicScreen.h" 16 | #include "ListItem.h" 17 | #include "Object.h" 18 | #include "Panel.h" 19 | #include "ScreenManager.h" 20 | #include "Settings.h" 21 | 22 | #ifndef SCREEN_NAME_LEN 23 | #define SCREEN_NAME_LEN 20 24 | #endif 25 | 26 | typedef struct ScreensPanel_ { 27 | Panel super; 28 | 29 | ScreenManager* scr; 30 | Settings* settings; 31 | ColumnsPanel* columns; 32 | AvailableColumnsPanel* availableColumns; 33 | char buffer[SCREEN_NAME_LEN + 1]; 34 | char* saved; 35 | int cursor; 36 | bool moving; 37 | ListItem* renamingItem; 38 | } ScreensPanel; 39 | 40 | typedef struct ScreenListItem_ { 41 | ListItem super; 42 | DynamicScreen* ds; 43 | ScreenSettings* ss; 44 | } ScreenListItem; 45 | 46 | 47 | extern ObjectClass ScreenListItem_class; 48 | 49 | ScreenListItem* ScreenListItem_new(const char* value, ScreenSettings* ss); 50 | 51 | ScreensPanel* ScreensPanel_new(Settings* settings); 52 | 53 | void ScreensPanel_update(Panel* super); 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /SignalsPanel.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - SignalsPanel.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "SignalsPanel.h" 11 | // the above contains #include so do not add that here again (breaks Solaris build) 12 | 13 | #include 14 | 15 | #include "FunctionBar.h" 16 | #include "ListItem.h" 17 | #include "Object.h" 18 | #include "Panel.h" 19 | #include "Platform.h" 20 | #include "XUtils.h" 21 | 22 | 23 | Panel* SignalsPanel_new(int preSelectedSignal) { 24 | Panel* this = Panel_new(1, 1, 1, 1, Class(ListItem), true, FunctionBar_newEnterEsc("Send ", "Cancel ")); 25 | int defaultPosition = 15; 26 | unsigned int i; 27 | for (i = 0; i < Platform_numberOfSignals; i++) { 28 | Panel_set(this, i, (Object*) ListItem_new(Platform_signals[i].name, Platform_signals[i].number)); 29 | // signal 15 is not always the 15th signal in the table 30 | if (Platform_signals[i].number == preSelectedSignal) { 31 | defaultPosition = i; 32 | } 33 | } 34 | #if (defined(SIGRTMIN) && defined(SIGRTMAX)) 35 | if (SIGRTMAX - SIGRTMIN <= 100) { 36 | static char buf[16]; 37 | for (int sig = SIGRTMIN; sig <= SIGRTMAX; i++, sig++) { 38 | int n = sig - SIGRTMIN; 39 | xSnprintf(buf, sizeof(buf), "%2d SIGRTMIN%-+3d", sig, n); 40 | if (n == 0) { 41 | buf[11] = '\0'; 42 | } 43 | Panel_set(this, i, (Object*) ListItem_new(buf, sig)); 44 | } 45 | } 46 | #endif 47 | Panel_setHeader(this, "Send signal:"); 48 | Panel_setSelected(this, defaultPosition); 49 | return this; 50 | } 51 | -------------------------------------------------------------------------------- /SignalsPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SignalsPanel 2 | #define HEADER_SignalsPanel 3 | /* 4 | htop - SignalsPanel.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Panel.h" 11 | 12 | #ifndef HTOP_SOLARIS 13 | #include 14 | #endif 15 | 16 | 17 | typedef struct SignalItem_ { 18 | const char* name; 19 | int number; 20 | } SignalItem; 21 | 22 | #define SIGNALSPANEL_INITSELECTEDSIGNAL SIGTERM 23 | 24 | Panel* SignalsPanel_new(int preSelectedSignal); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /SwapMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - SwapMeter.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "SwapMeter.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "CRT.h" 16 | #include "Macros.h" 17 | #include "Object.h" 18 | #include "Platform.h" 19 | #include "RichString.h" 20 | 21 | 22 | static const int SwapMeter_attributes[] = { 23 | SWAP, 24 | SWAP_CACHE, 25 | SWAP_FRONTSWAP, 26 | }; 27 | 28 | static void SwapMeter_updateValues(Meter* this) { 29 | char* buffer = this->txtBuffer; 30 | size_t size = sizeof(this->txtBuffer); 31 | int written; 32 | 33 | this->values[SWAP_METER_CACHE] = NAN; /* 'cached' not present on all platforms */ 34 | this->values[SWAP_METER_FRONTSWAP] = NAN; /* 'frontswap' not present on all platforms */ 35 | Platform_setSwapValues(this); 36 | 37 | written = Meter_humanUnit(buffer, this->values[SWAP_METER_USED], size); 38 | METER_BUFFER_CHECK(buffer, size, written); 39 | 40 | METER_BUFFER_APPEND_CHR(buffer, size, '/'); 41 | 42 | Meter_humanUnit(buffer, this->total, size); 43 | } 44 | 45 | static void SwapMeter_display(const Object* cast, RichString* out) { 46 | char buffer[50]; 47 | const Meter* this = (const Meter*)cast; 48 | RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); 49 | Meter_humanUnit(buffer, this->total, sizeof(buffer)); 50 | RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); 51 | Meter_humanUnit(buffer, this->values[SWAP_METER_USED], sizeof(buffer)); 52 | RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); 53 | RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); 54 | 55 | if (isNonnegative(this->values[SWAP_METER_CACHE])) { 56 | Meter_humanUnit(buffer, this->values[SWAP_METER_CACHE], sizeof(buffer)); 57 | RichString_appendAscii(out, CRT_colors[METER_TEXT], " cache:"); 58 | RichString_appendAscii(out, CRT_colors[SWAP_CACHE], buffer); 59 | } 60 | 61 | if (isNonnegative(this->values[SWAP_METER_FRONTSWAP])) { 62 | Meter_humanUnit(buffer, this->values[SWAP_METER_FRONTSWAP], sizeof(buffer)); 63 | RichString_appendAscii(out, CRT_colors[METER_TEXT], " frontswap:"); 64 | RichString_appendAscii(out, CRT_colors[SWAP_FRONTSWAP], buffer); 65 | } 66 | } 67 | 68 | const MeterClass SwapMeter_class = { 69 | .super = { 70 | .extends = Class(Meter), 71 | .delete = Meter_delete, 72 | .display = SwapMeter_display, 73 | }, 74 | .updateValues = SwapMeter_updateValues, 75 | .defaultMode = BAR_METERMODE, 76 | .supportedModes = METERMODE_DEFAULT_SUPPORTED, 77 | .maxItems = SWAP_METER_ITEMCOUNT, 78 | .total = 100.0, 79 | .attributes = SwapMeter_attributes, 80 | .name = "Swap", 81 | .uiName = "Swap", 82 | .caption = "Swp" 83 | }; 84 | -------------------------------------------------------------------------------- /SwapMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SwapMeter 2 | #define HEADER_SwapMeter 3 | /* 4 | htop - SwapMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | typedef enum { 13 | SWAP_METER_USED = 0, 14 | SWAP_METER_CACHE = 1, 15 | SWAP_METER_FRONTSWAP = 2, 16 | SWAP_METER_ITEMCOUNT = 3, // number of entries in this enum 17 | } SwapMeterValues; 18 | 19 | extern const MeterClass SwapMeter_class; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /SysArchMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - SysArchMeter.c 3 | (C) 2021 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "SysArchMeter.h" 11 | 12 | #include 13 | 14 | #include "CRT.h" 15 | #include "Object.h" 16 | #include "Platform.h" 17 | #include "XUtils.h" 18 | 19 | 20 | static const int SysArchMeter_attributes[] = {HOSTNAME}; 21 | 22 | static void SysArchMeter_updateValues(Meter* this) { 23 | static char* string; 24 | 25 | if (string == NULL) 26 | Platform_getRelease(&string); 27 | 28 | String_safeStrncpy(this->txtBuffer, string, sizeof(this->txtBuffer)); 29 | } 30 | 31 | const MeterClass SysArchMeter_class = { 32 | .super = { 33 | .extends = Class(Meter), 34 | .delete = Meter_delete 35 | }, 36 | .updateValues = SysArchMeter_updateValues, 37 | .defaultMode = TEXT_METERMODE, 38 | .supportedModes = (1 << TEXT_METERMODE), 39 | .maxItems = 0, 40 | .total = 0.0, 41 | .attributes = SysArchMeter_attributes, 42 | .name = "System", 43 | .uiName = "System", 44 | .caption = "System: ", 45 | }; 46 | -------------------------------------------------------------------------------- /SysArchMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SysArchMeter 2 | #define HEADER_SysArchMeter 3 | /* 4 | htop - SysArchMeter.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | #include "Meter.h" 10 | 11 | 12 | extern const MeterClass SysArchMeter_class; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /TasksMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_TasksMeter 2 | #define HEADER_TasksMeter 3 | /* 4 | htop - TasksMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass TasksMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /TraceScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_TraceScreen 2 | #define HEADER_TraceScreen 3 | /* 4 | htop - TraceScreen.h 5 | (C) 2005-2006 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "InfoScreen.h" 15 | #include "Object.h" 16 | #include "Process.h" 17 | 18 | 19 | typedef struct TraceScreen_ { 20 | InfoScreen super; 21 | bool tracing; 22 | pid_t child; 23 | FILE* strace; 24 | bool contLine; 25 | bool follow; 26 | bool strace_alive; 27 | } TraceScreen; 28 | 29 | 30 | extern const InfoScreenClass TraceScreen_class; 31 | 32 | TraceScreen* TraceScreen_new(const Process* process); 33 | 34 | void TraceScreen_delete(Object* cast); 35 | 36 | bool TraceScreen_forkTracer(TraceScreen* this); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /UptimeMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - UptimeMeter.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "UptimeMeter.h" 11 | 12 | #include "CRT.h" 13 | #include "Object.h" 14 | #include "Platform.h" 15 | #include "XUtils.h" 16 | 17 | 18 | static const int UptimeMeter_attributes[] = { 19 | UPTIME 20 | }; 21 | 22 | static void UptimeMeter_updateValues(Meter* this) { 23 | int totalseconds = Platform_getUptime(); 24 | if (totalseconds <= 0) { 25 | xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "(unknown)"); 26 | return; 27 | } 28 | int seconds = totalseconds % 60; 29 | int minutes = (totalseconds / 60) % 60; 30 | int hours = (totalseconds / 3600) % 24; 31 | int days = (totalseconds / 86400); 32 | 33 | char daysbuf[32]; 34 | if (days > 100) { 35 | xSnprintf(daysbuf, sizeof(daysbuf), "%d days(!), ", days); 36 | } else if (days > 1) { 37 | xSnprintf(daysbuf, sizeof(daysbuf), "%d days, ", days); 38 | } else if (days == 1) { 39 | xSnprintf(daysbuf, sizeof(daysbuf), "1 day, "); 40 | } else { 41 | daysbuf[0] = '\0'; 42 | } 43 | xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%02d:%02d:%02d", daysbuf, hours, minutes, seconds); 44 | } 45 | 46 | const MeterClass UptimeMeter_class = { 47 | .super = { 48 | .extends = Class(Meter), 49 | .delete = Meter_delete 50 | }, 51 | .updateValues = UptimeMeter_updateValues, 52 | .defaultMode = TEXT_METERMODE, 53 | .supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE), 54 | .maxItems = 0, 55 | .total = 0.0, 56 | .attributes = UptimeMeter_attributes, 57 | .name = "Uptime", 58 | .uiName = "Uptime", 59 | .caption = "Uptime: " 60 | }; 61 | -------------------------------------------------------------------------------- /UptimeMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UptimeMeter 2 | #define HEADER_UptimeMeter 3 | /* 4 | htop - UptimeMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass UptimeMeter_class; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /UsersTable.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - UsersTable.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "UsersTable.h" 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "XUtils.h" 18 | 19 | 20 | UsersTable* UsersTable_new(void) { 21 | UsersTable* this; 22 | this = xMalloc(sizeof(UsersTable)); 23 | this->users = Hashtable_new(10, true); 24 | return this; 25 | } 26 | 27 | void UsersTable_delete(UsersTable* this) { 28 | Hashtable_delete(this->users); 29 | free(this); 30 | } 31 | 32 | char* UsersTable_getRef(UsersTable* this, unsigned int uid) { 33 | char* name = Hashtable_get(this->users, uid); 34 | if (name == NULL) { 35 | const struct passwd* userData = getpwuid(uid); 36 | if (userData != NULL) { 37 | name = xStrdup(userData->pw_name); 38 | Hashtable_put(this->users, uid, name); 39 | } 40 | } 41 | return name; 42 | } 43 | 44 | inline void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData) { 45 | Hashtable_foreach(this->users, f, userData); 46 | } 47 | -------------------------------------------------------------------------------- /UsersTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UsersTable 2 | #define HEADER_UsersTable 3 | /* 4 | htop - UsersTable.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Hashtable.h" 11 | 12 | 13 | typedef struct UsersTable_ { 14 | Hashtable* users; 15 | } UsersTable; 16 | 17 | UsersTable* UsersTable_new(void); 18 | 19 | void UsersTable_delete(UsersTable* this); 20 | 21 | char* UsersTable_getRef(UsersTable* this, unsigned int uid); 22 | 23 | void UsersTable_foreach(UsersTable* this, Hashtable_PairFunction f, void* userData); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Vector.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Vector 2 | #define HEADER_Vector 3 | /* 4 | htop - Vector.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Object.h" 11 | 12 | #include 13 | 14 | 15 | #ifndef DEFAULT_SIZE 16 | #define DEFAULT_SIZE (-1) 17 | #endif 18 | 19 | typedef struct Vector_ { 20 | Object** array; 21 | const ObjectClass* type; 22 | int arraySize; 23 | int growthRate; 24 | int items; 25 | /* lowest index of a pending soft remove/delete operation, 26 | used to speed up compaction */ 27 | int dirty_index; 28 | /* count of soft deletes, required for Vector_count to work in debug mode */ 29 | int dirty_count; 30 | bool owner; 31 | } Vector; 32 | 33 | Vector* Vector_new(const ObjectClass* type, bool owner, int size); 34 | 35 | void Vector_delete(Vector* this); 36 | 37 | void Vector_prune(Vector* this); 38 | 39 | void Vector_quickSortCustomCompare(Vector* this, Object_Compare compare); 40 | static inline void Vector_quickSort(Vector* this) { 41 | Vector_quickSortCustomCompare(this, this->type->compare); 42 | } 43 | 44 | void Vector_insertionSort(Vector* this); 45 | 46 | void Vector_insert(Vector* this, int idx, void* data_); 47 | 48 | Object* Vector_take(Vector* this, int idx); 49 | 50 | Object* Vector_remove(Vector* this, int idx); 51 | 52 | /* Vector_softRemove marks the item at index idx for deletion without 53 | reclaiming any space. If owned, the item is immediately freed. 54 | 55 | Vector_compact must be called to reclaim space.*/ 56 | Object* Vector_softRemove(Vector* this, int idx); 57 | 58 | /* Vector_compact reclaims space free'd up by Vector_softRemove, if any. */ 59 | void Vector_compact(Vector* this); 60 | 61 | void Vector_moveUp(Vector* this, int idx); 62 | 63 | void Vector_moveDown(Vector* this, int idx); 64 | 65 | void Vector_set(Vector* this, int idx, void* data_); 66 | 67 | #ifndef NDEBUG 68 | 69 | Object* Vector_get(const Vector* this, int idx); 70 | int Vector_size(const Vector* this); 71 | 72 | /* Vector_countEquals returns true if the number of non-NULL items 73 | in the Vector is equal to expectedCount. This is only for debugging 74 | and consistency checks. */ 75 | bool Vector_countEquals(const Vector* this, unsigned int expectedCount); 76 | 77 | #else /* NDEBUG */ 78 | 79 | static inline Object* Vector_get(const Vector* this, int idx) { 80 | return this->array[idx]; 81 | } 82 | 83 | static inline int Vector_size(const Vector* this) { 84 | return this->items; 85 | } 86 | 87 | #endif /* NDEBUG */ 88 | 89 | static inline const ObjectClass* Vector_type(const Vector* this) { 90 | return this->type; 91 | } 92 | 93 | void Vector_add(Vector* this, void* data_); 94 | 95 | int Vector_indexOf(const Vector* this, const void* search_, Object_Compare compare); 96 | 97 | void Vector_splice(Vector* this, Vector* from); 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf --force --install --verbose -Wall 3 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright (c) 2024 Alex313031. 4 | 5 | YEL='\033[1;33m' # Yellow 6 | CYA='\033[1;96m' # Cyan 7 | RED='\033[1;31m' # Red 8 | GRE='\033[1;32m' # Green 9 | c0='\033[0m' # Reset Text 10 | bold='\033[1m' # Bold Text 11 | underline='\033[4m' # Underline Text 12 | 13 | # Error handling 14 | yell() { echo "$0: $*" >&2; } 15 | die() { yell "$*"; exit 111; } 16 | try() { "$@" || die "${RED}Failed $*"; } 17 | 18 | # --help 19 | displayHelp () { 20 | printf "\n" && 21 | printf "${bold}${GRE}Script to clean htop build artifacts.${c0}\n" && 22 | printf "${bold}${YEL}Use the --help flag to show this help.${c0}\n" && 23 | printf "\n" 24 | } 25 | case $1 in 26 | --help) displayHelp; exit 0;; 27 | esac 28 | 29 | printf "\n" && 30 | printf "${YEL}Running \`make clean\` and \`make distclean\`...\n" && 31 | printf "${CYA}\n" && 32 | 33 | # Clean artifacts 34 | make clean 35 | make distclean 36 | rm -f -v ./clean && 37 | 38 | printf "\n" && 39 | printf "${GRE}${bold}Done.\n" && 40 | printf "\n" && 41 | tput sgr0 42 | -------------------------------------------------------------------------------- /darwin/DarwinMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DarwinMachine 2 | #define HEADER_DarwinMachine 3 | /* 4 | htop - DarwinMachine.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 | 10 | #include 11 | #include 12 | 13 | #include "Machine.h" 14 | #include "zfs/ZfsArcStats.h" 15 | 16 | 17 | typedef struct DarwinMachine_ { 18 | Machine super; 19 | 20 | host_basic_info_data_t host_info; 21 | #ifdef HAVE_STRUCT_VM_STATISTICS64 22 | vm_statistics64_data_t vm_stats; 23 | #else 24 | vm_statistics_data_t vm_stats; 25 | #endif 26 | processor_cpu_load_info_t prev_load; 27 | processor_cpu_load_info_t curr_load; 28 | 29 | ZfsArcStats zfs; 30 | } DarwinMachine; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /darwin/DarwinProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DarwinProcess 2 | #define HEADER_DarwinProcess 3 | /* 4 | htop - DarwinProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Machine.h" 13 | #include "darwin/DarwinProcessTable.h" 14 | 15 | 16 | #define PROCESS_FLAG_TTY 0x00000100 17 | 18 | typedef struct DarwinProcess_ { 19 | Process super; 20 | 21 | uint64_t utime; 22 | uint64_t stime; 23 | bool taskAccess; 24 | bool translated; 25 | } DarwinProcess; 26 | 27 | extern const ProcessClass DarwinProcess_class; 28 | 29 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 30 | 31 | Process* DarwinProcess_new(const Machine* settings); 32 | 33 | void Process_delete(Object* cast); 34 | 35 | void DarwinProcess_setFromKInfoProc(Process* proc, const struct kinfo_proc* ps, bool exists); 36 | 37 | void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessTable* dpt, double timeIntervalNS); 38 | 39 | /* 40 | * Scan threads for process state information. 41 | * Based on: http://stackoverflow.com/questions/6788274/ios-mac-cpu-usage-for-thread 42 | * and https://github.com/max-horvath/htop-osx/blob/e86692e869e30b0bc7264b3675d2a4014866ef46/ProcessList.c 43 | */ 44 | void DarwinProcess_scanThreads(DarwinProcess* dp, DarwinProcessTable* dpt); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /darwin/DarwinProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DarwinProcessTable 2 | #define HEADER_DarwinProcessTable 3 | /* 4 | htop - DarwinProcessTable.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 | 10 | #include 11 | #include 12 | 13 | #include "ProcessTable.h" 14 | 15 | 16 | typedef struct DarwinProcessTable_ { 17 | ProcessTable super; 18 | 19 | uint64_t global_diff; 20 | } DarwinProcessTable; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /darwin/PlatformHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PlatformHelpers 2 | #define HEADER_PlatformHelpers 3 | /* 4 | htop - darwin/PlatformHelpers.h 5 | (C) 2018 Pierre Malhaire, 2020-2022 htop dev team, 2021 Alexander Momchilov 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | 14 | typedef struct KernelVersion { 15 | short int major; 16 | short int minor; 17 | short int patch; 18 | } KernelVersion; 19 | 20 | void Platform_GetKernelVersion(KernelVersion* k); 21 | 22 | /* compare the given os version with the one installed returns: 23 | 0 if equals the installed version 24 | positive value if less than the installed version 25 | negative value if more than the installed version 26 | */ 27 | int Platform_CompareKernelVersion(KernelVersion v); 28 | 29 | // lowerBound <= currentVersion < upperBound 30 | bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upperBound); 31 | 32 | void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize); 33 | 34 | bool Platform_isRunningTranslated(void); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /darwin/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DarwinProcessField 2 | #define HEADER_DarwinProcessField 3 | /* 4 | htop - darwin/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | TRANSLATED = 100, \ 13 | \ 14 | DUMMY_BUMP_FIELD = CWD, \ 15 | // End of list 16 | 17 | 18 | #endif /* HEADER_DarwinProcessField */ 19 | -------------------------------------------------------------------------------- /docs/images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex313031/htop/93ad5ee5bd4c6bd490505d3cd40a3cbf211aab61/docs/images/screenshot.png -------------------------------------------------------------------------------- /dragonflybsd/DragonFlyBSDMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DragonFlyBSDMachine 2 | #define HEADER_DragonFlyBSDMachine 3 | /* 4 | htop - DragonFlyBSDMachine.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2017 Diederik de Groot 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include // required for kvm.h 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "Hashtable.h" 21 | #include "Machine.h" 22 | #include "ProcessTable.h" 23 | #include "UsersTable.h" 24 | 25 | 26 | typedef struct CPUData_ { 27 | double userPercent; 28 | double nicePercent; 29 | double systemPercent; 30 | double irqPercent; 31 | double idlePercent; 32 | double systemAllPercent; 33 | } CPUData; 34 | 35 | typedef struct DragonFlyBSDMachine_ { 36 | Machine super; 37 | kvm_t* kd; 38 | 39 | Hashtable* jails; 40 | 41 | int pageSize; 42 | int pageSizeKb; 43 | int kernelFScale; 44 | 45 | CPUData* cpus; 46 | 47 | unsigned long* cp_time_o; 48 | unsigned long* cp_time_n; 49 | 50 | unsigned long* cp_times_o; 51 | unsigned long* cp_times_n; 52 | } DragonFlyBSDMachine; 53 | 54 | char* DragonFlyBSDMachine_readJailName(const DragonFlyBSDMachine* host, int jailid); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /dragonflybsd/DragonFlyBSDProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DragonFlyBSDProcess 2 | #define HEADER_DragonFlyBSDProcess 3 | /* 4 | htop - dragonflybsd/DragonFlyBSDProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | (C) 2017 Diederik de Groot 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | 13 | #include "Object.h" 14 | #include "Process.h" 15 | #include "Machine.h" 16 | 17 | 18 | typedef struct DragonFlyBSDProcess_ { 19 | Process super; 20 | int jid; 21 | char* jname; 22 | } DragonFlyBSDProcess; 23 | 24 | extern const ProcessClass DragonFlyBSDProcess_class; 25 | 26 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 27 | 28 | Process* DragonFlyBSDProcess_new(const Machine* host); 29 | 30 | void Process_delete(Object* cast); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /dragonflybsd/DragonFlyBSDProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DragonFlyBSDProcessTable 2 | #define HEADER_DragonFlyBSDProcessTable 3 | /* 4 | htop - DragonFlyBSDProcessTable.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2017 Diederik de Groot 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "ProcessTable.h" 15 | 16 | 17 | typedef struct DragonFlyBSDProcessTable_ { 18 | ProcessTable super; 19 | } DragonFlyBSDProcessTable; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /dragonflybsd/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_DragonFlyBSDProcessField 2 | #define HEADER_DragonFlyBSDProcessField 3 | /* 4 | htop - dragonflybsd/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | JID = 100, \ 13 | JAIL = 101, \ 14 | \ 15 | DUMMY_BUMP_FIELD = CWD, \ 16 | // End of list 17 | 18 | 19 | #endif /* HEADER_DragonFlyBSDProcessField */ 20 | -------------------------------------------------------------------------------- /freebsd/FreeBSDMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FreeBSDMachine 2 | #define HEADER_FreeBSDMachine 3 | /* 4 | htop - FreeBSDMachine.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 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "Hashtable.h" 15 | #include "Machine.h" 16 | #include "UsersTable.h" 17 | #include "zfs/ZfsArcStats.h" 18 | 19 | 20 | typedef struct CPUData_ { 21 | double userPercent; 22 | double nicePercent; 23 | double systemPercent; 24 | double irqPercent; 25 | double systemAllPercent; 26 | 27 | double frequency; 28 | double temperature; 29 | } CPUData; 30 | 31 | typedef struct FreeBSDMachine_ { 32 | Machine super; 33 | kvm_t* kd; 34 | 35 | int pageSize; 36 | int pageSizeKb; 37 | int kernelFScale; 38 | 39 | ZfsArcStats zfs; 40 | 41 | CPUData* cpus; 42 | 43 | unsigned long* cp_time_o; 44 | unsigned long* cp_time_n; 45 | 46 | unsigned long* cp_times_o; 47 | unsigned long* cp_times_n; 48 | 49 | } FreeBSDMachine; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /freebsd/FreeBSDProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FreeBSDProcess 2 | #define HEADER_FreeBSDProcess 3 | /* 4 | htop - FreeBSDProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Object.h" 13 | #include "Process.h" 14 | #include "Machine.h" 15 | 16 | typedef enum { 17 | SCHEDCLASS_UNKNOWN = 0, 18 | 19 | SCHEDCLASS_INTR_THREAD, /* interrupt thread */ 20 | SCHEDCLASS_REALTIME, 21 | SCHEDCLASS_TIMESHARE, /* Regular scheduling */ 22 | SCHEDCLASS_IDLE, 23 | 24 | MAX_SCHEDCLASS, 25 | } FreeBSDSchedClass; 26 | 27 | typedef struct FreeBSDProcess_ { 28 | Process super; 29 | int jid; 30 | char* jname; 31 | char* emul; 32 | FreeBSDSchedClass sched_class; 33 | } FreeBSDProcess; 34 | 35 | extern const ProcessClass FreeBSDProcess_class; 36 | 37 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 38 | 39 | Process* FreeBSDProcess_new(const Machine* host); 40 | 41 | void Process_delete(Object* cast); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /freebsd/FreeBSDProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FreeBSDProcessTable 2 | #define HEADER_FreeBSDProcessTable 3 | /* 4 | htop - FreeBSDProcessTable.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 | 10 | #include 11 | #include 12 | 13 | #include "Hashtable.h" 14 | #include "ProcessTable.h" 15 | #include "UsersTable.h" 16 | 17 | typedef struct FreeBSDProcessTable_ { 18 | ProcessTable super; 19 | } FreeBSDProcessTable; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /freebsd/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_FreeBSDProcessField 2 | #define HEADER_FreeBSDProcessField 3 | /* 4 | htop - freebsd/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | JID = 100, \ 13 | JAIL = 101, \ 14 | EMULATION = 102, \ 15 | SCHEDCLASS = 103, \ 16 | \ 17 | DUMMY_BUMP_FIELD = CWD, \ 18 | // End of list 19 | 20 | 21 | #endif /* HEADER_FreeBSDProcessField */ 22 | -------------------------------------------------------------------------------- /generic/fdstat_sysctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - generic/fdstat_sysctl.c 3 | (C) 2022-2023 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "generic/fdstat_sysctl.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include // Shitty FreeBSD upstream headers 17 | #include 18 | 19 | 20 | static void Generic_getFileDescriptors_sysctl_internal( 21 | const char* sysctlname_maxfiles, 22 | const char* sysctlname_numfiles, 23 | size_t size_header, 24 | size_t size_entry, 25 | double* used, 26 | double* max 27 | ) { 28 | *used = NAN; 29 | *max = 65536; 30 | 31 | int max_fd, open_fd; 32 | size_t len; 33 | 34 | len = sizeof(max_fd); 35 | if (sysctlname_maxfiles && sysctlbyname(sysctlname_maxfiles, &max_fd, &len, NULL, 0) == 0) { 36 | if (max_fd) { 37 | *max = max_fd; 38 | } else { 39 | *max = NAN; 40 | } 41 | } 42 | 43 | len = sizeof(open_fd); 44 | if (sysctlname_numfiles && sysctlbyname(sysctlname_numfiles, &open_fd, &len, NULL, 0) == 0) { 45 | *used = open_fd; 46 | return; 47 | } 48 | 49 | // If no sysctl arc available, try to guess from the file table size at kern.file 50 | // The size per entry differs per OS, thus skip if we don't know: 51 | if (!size_entry) 52 | return; 53 | 54 | len = 0; 55 | if (sysctlbyname("kern.file", NULL, &len, NULL, 0) < 0) 56 | return; 57 | 58 | if (len < size_header) 59 | return; 60 | 61 | *used = (len - size_header) / size_entry; 62 | } 63 | 64 | void Generic_getFileDescriptors_sysctl(double* used, double* max) { 65 | #if defined(HTOP_DARWIN) 66 | Generic_getFileDescriptors_sysctl_internal( 67 | "kern.maxfiles", "kern.num_files", 0, 0, used, max); 68 | #elif defined(HTOP_DRAGONFLYBSD) 69 | Generic_getFileDescriptors_sysctl_internal( 70 | "kern.maxfiles", "kern.openfiles", 0, 0, used, max); 71 | #elif defined(HTOP_FREEBSD) 72 | Generic_getFileDescriptors_sysctl_internal( 73 | "kern.maxfiles", "kern.openfiles", 0, 0, used, max); 74 | #elif defined(HTOP_NETBSD) 75 | Generic_getFileDescriptors_sysctl_internal( 76 | "kern.maxfiles", NULL, 0, sizeof(struct kinfo_file), used, max); 77 | #else 78 | #error Unknown platform: Please implement proper way to query open/max file information 79 | #endif 80 | } 81 | -------------------------------------------------------------------------------- /generic/fdstat_sysctl.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_fdstat_sysctl 2 | #define HEADER_fdstat_sysctl 3 | /* 4 | htop - generic/fdstat_sysctl.h 5 | (C) 2022-2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | void Generic_getFileDescriptors_sysctl(double* used, double* max); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /generic/gettime.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - generic/gettime.c 3 | (C) 2021 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "generic/gettime.h" 11 | 12 | #include 13 | #include 14 | 15 | 16 | void Generic_gettime_realtime(struct timeval* tvp, uint64_t* msec) { 17 | 18 | #if defined(HAVE_CLOCK_GETTIME) 19 | 20 | struct timespec ts; 21 | if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { 22 | tvp->tv_sec = ts.tv_sec; 23 | tvp->tv_usec = (suseconds_t)(ts.tv_nsec / 1000); 24 | *msec = ((uint64_t)ts.tv_sec * 1000) + ((uint64_t)ts.tv_nsec / 1000000); 25 | } else { 26 | memset(tvp, 0, sizeof(struct timeval)); 27 | *msec = 0; 28 | } 29 | 30 | #else /* lower resolution gettimeofday(2) is always available */ 31 | 32 | struct timeval tv; 33 | if (gettimeofday(&tv, NULL) == 0) { 34 | *tvp = tv; /* struct copy */ 35 | *msec = ((uint64_t)tv.tv_sec * 1000) + ((uint64_t)tv.tv_usec / 1000); 36 | } else { 37 | memset(tvp, 0, sizeof(struct timeval)); 38 | *msec = 0; 39 | } 40 | 41 | #endif 42 | } 43 | 44 | void Generic_gettime_monotonic(uint64_t* msec) { 45 | #if defined(HAVE_CLOCK_GETTIME) 46 | 47 | struct timespec ts; 48 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) 49 | *msec = ((uint64_t)ts.tv_sec * 1000) + ((uint64_t)ts.tv_nsec / 1000000); 50 | else 51 | *msec = 0; 52 | 53 | #else /* lower resolution gettimeofday() should be always available */ 54 | 55 | struct timeval tv; 56 | if (gettimeofday(&tv, NULL) == 0) 57 | *msec = ((uint64_t)tv.tv_sec * 1000) + ((uint64_t)tv.tv_usec / 1000); 58 | else 59 | *msec = 0; 60 | 61 | #endif 62 | } 63 | -------------------------------------------------------------------------------- /generic/gettime.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_gettime 2 | #define HEADER_gettime 3 | /* 4 | htop - generic/gettime.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | 14 | void Generic_gettime_realtime(struct timeval* tvp, uint64_t* msec); 15 | 16 | void Generic_gettime_monotonic(uint64_t* msec); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /generic/hostname.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - generic/hostname.c 3 | (C) 2021 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "generic/hostname.h" 11 | 12 | #include 13 | 14 | 15 | void Generic_hostname(char* buffer, size_t size) { 16 | gethostname(buffer, size - 1); 17 | buffer[size - 1] = '\0'; 18 | } 19 | -------------------------------------------------------------------------------- /generic/hostname.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_hostname 2 | #define HEADER_hostname 3 | /* 4 | htop - generic/hostname.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | 13 | void Generic_hostname(char* buffer, size_t size); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /generic/openzfs_sysctl.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_openzfs_sysctl 2 | #define HEADER_openzfs_sysctl 3 | /* 4 | htop - generic/openzfs_sysctl.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 | 10 | #include "zfs/ZfsArcStats.h" 11 | 12 | 13 | void openzfs_sysctl_init(ZfsArcStats* stats); 14 | 15 | void openzfs_sysctl_updateArcStats(ZfsArcStats* stats); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /generic/uname.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_uname 2 | #define HEADER_uname 3 | /* 4 | htop - generic/uname.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | char* Generic_uname(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /htop.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - htop.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | (C) 2020-2021 htop dev team 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "CommandLine.h" 12 | 13 | 14 | const char* program = PACKAGE; 15 | 16 | int main(int argc, char** argv) { 17 | return CommandLine_run(argc, argv); 18 | } 19 | -------------------------------------------------------------------------------- /htop.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Version=1.0 4 | Name=Htop 5 | GenericName=Process Viewer 6 | GenericName[ca]=Visualitzador de processos 7 | GenericName[da]=Procesfremviser 8 | GenericName[de]=Prozessanzeige 9 | GenericName[en_GB]=Process Viewer 10 | GenericName[es]=Visor de procesos 11 | GenericName[fi]=Prosessikatselin 12 | GenericName[fr]=Visualiseur de processus 13 | GenericName[gl]=Visor de procesos 14 | GenericName[it]=Visore dei processi 15 | GenericName[ko]=프로세스 뷰어 16 | GenericName[nb]=Prosessviser 17 | GenericName[nl]=Viewer van processen 18 | GenericName[nn]=Prosessvisar 19 | GenericName[pl]=Przeglądarka procesów 20 | GenericName[pt]=Visualizador de Processos 21 | GenericName[pt_BR]=Visualizador de processos 22 | GenericName[ru]=Монитор процессов 23 | GenericName[sk]=Prehliadač procesov 24 | GenericName[sl]=Pregledovalnik opravil 25 | GenericName[sr@ijekavian]=Приказивач процеса 26 | GenericName[sr@ijekavianlatin]=Prikazivač procesa 27 | GenericName[sr@latin]=Prikazivač procesa 28 | GenericName[sr]=Приказивач процеса 29 | GenericName[sv]=Processvisning 30 | GenericName[tr]=Süreç Görüntüleyici 31 | GenericName[uk]=Перегляд процесів 32 | GenericName[zh_CN]=进程查看器 33 | GenericName[zh_TW]=行程檢視器 34 | Comment=Show System Processes 35 | Comment[ca]=Visualitzeu els processos del sistema 36 | Comment[da]=Vis systemprocesser 37 | Comment[de]=Systemprozesse anzeigen 38 | Comment[en_GB]=Show System Processes 39 | Comment[es]=Mostrar procesos del sistema 40 | Comment[fi]=Katsele järjestelmän prosesseja 41 | Comment[fr]=Affiche les processus système 42 | Comment[gl]=Mostrar os procesos do sistema. 43 | Comment[it]=Mostra processi di sistema 44 | Comment[ko]=시스템 프로세스 보기 45 | Comment[nb]=Vis systemprosesser 46 | Comment[nl]=Systeemprocessen tonen 47 | Comment[nn]=Vis systemprosessar 48 | Comment[pl]=Pokaż procesy systemowe 49 | Comment[pt]=Mostrar os Processos do Sistema 50 | Comment[pt_BR]=Mostra os processos do sistema 51 | Comment[ru]=Просмотр списка процессов в системе 52 | Comment[sk]=Zobraziť systémové procesy 53 | Comment[sl]=Prikaz sistemskih opravil 54 | Comment[sr@ijekavian]=Приказ системских процеса 55 | Comment[sr@ijekavianlatin]=Prikaz sistemskih procesa 56 | Comment[sr@latin]=Prikaz sistemskih procesa 57 | Comment[sr]=Приказ системских процеса 58 | Comment[sv]=Visa systemprocesser 59 | Comment[tr]=Sistem Süreçlerini Göster 60 | Comment[uk]=Перегляд системних процесів 61 | Comment[zh_CN]=显示系统进程 62 | Comment[zh_TW]=顯示系統行程 63 | Icon=htop 64 | Exec=htop 65 | Terminal=true 66 | Categories=System;Monitor;ConsoleOnly; 67 | Keywords=system;process;task 68 | -------------------------------------------------------------------------------- /htop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Alex313031/htop/93ad5ee5bd4c6bd490505d3cd40a3cbf211aab61/htop.png -------------------------------------------------------------------------------- /iwyu/htop.imp: -------------------------------------------------------------------------------- 1 | [ 2 | { include: ["", "private", "\"ProvideCurses.h\"", "public"] }, 3 | { include: ["", "private", "\"ProvideCurses.h\"", "public"] }, 4 | { include: ["", "private", "\"ProvideCurses.h\"", "public"] }, 5 | { include: ["", "private", "\"ProvideCurses.h\"", "public"] }, 6 | 7 | { include: ["", "private", "\"ProvideTerm.h\"", "public"] }, 8 | { include: ["", "private", "\"ProvideTerm.h\"", "public"] }, 9 | { include: ["", "private", "\"ProvideTerm.h\"", "public"] }, 10 | 11 | { include: ["", "private", "", "public"] }, 12 | { include: ["\"ibunwind-x86_64.h\"", "private", "", "public"] }, 13 | 14 | { include: ["", "private", "", "public"] }, 15 | 16 | { include: ["", "private", "", "public"] }, 17 | 18 | { include: ["", "private", "", "public"] }, 19 | 20 | { include: ["", "private", "", "public"] }, 21 | 22 | { include: ["", "private", "", "public"] }, 23 | 24 | { include: ["", "private", "", "public"] }, 25 | 26 | { include: ["", "private", "", "public"] }, 27 | 28 | { include: ["", "private", "", "public"] }, 29 | 30 | { include: ["", "private", "", "public"] }, 31 | 32 | { include: ["", "private", "", "public"] }, 33 | ] 34 | -------------------------------------------------------------------------------- /iwyu/run_iwyu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT=$(readlink -f "$0") 4 | SCRIPTDIR=$(dirname "$SCRIPT") 5 | SOURCEDIR="$SCRIPTDIR/.." 6 | 7 | PKG_NL3=$(pkg-config --cflags libnl-3.0) 8 | 9 | IWYU=${IWYU:-iwyu} 10 | 11 | cd "$SOURCEDIR" || exit 12 | 13 | ./configure CC=clang CXX=clang++ --enable-silent-rules 14 | make clean 15 | make -k -s CC="$IWYU" CFLAGS="-Xiwyu --no_comments -Xiwyu --no_fwd_decl -Xiwyu --mapping_file='$SCRIPTDIR/htop.imp' $PKG_NL3" 16 | -------------------------------------------------------------------------------- /linux/CGroupUtils.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_CGroupUtils 2 | #define HEADER_CGroupUtils 3 | /* 4 | htop - CGroupUtils.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | char* CGroup_filterName(const char* cgroup); 12 | char* CGroup_filterContainer(const char* cgroup); 13 | 14 | #endif /* HEADER_CGroupUtils */ 15 | -------------------------------------------------------------------------------- /linux/GPU.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_GPU 2 | #define HEADER_GPU 3 | /* 4 | htop - GPU.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Compat.h" 11 | #include "linux/LinuxProcess.h" 12 | #include "linux/LinuxProcessTable.h" 13 | 14 | 15 | void GPU_readProcessData(LinuxProcessTable* lpt, LinuxProcess* lp, openat_arg_t procFd); 16 | 17 | #endif /* HEADER_GPU */ 18 | -------------------------------------------------------------------------------- /linux/GPUMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_GPUMeter 2 | #define HEADER_GPUMeter 3 | /* 4 | htop - GPUMeter.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "Meter.h" 13 | 14 | 15 | extern const MeterClass GPUMeter_class; 16 | 17 | bool GPUMeter_active(void); 18 | 19 | #endif /* HEADER_GPUMeter */ 20 | -------------------------------------------------------------------------------- /linux/HugePageMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_HugePageMeter 2 | #define HEADER_HugePageMeter 3 | /* 4 | htop - HugePageMeter.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass HugePageMeter_class; 14 | 15 | #endif /* HEADER_HugePageMeter */ 16 | -------------------------------------------------------------------------------- /linux/IOPriority.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_IOPriority 2 | #define HEADER_IOPriority 3 | /* 4 | htop - IOPriority.h 5 | (C) 2004-2012 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | 9 | Based on ionice, 10 | Copyright (C) 2005 Jens Axboe 11 | Released under the terms of the GNU General Public License version 2 12 | */ 13 | 14 | enum { 15 | IOPRIO_CLASS_NONE, 16 | IOPRIO_CLASS_RT, 17 | IOPRIO_CLASS_BE, 18 | IOPRIO_CLASS_IDLE, 19 | }; 20 | 21 | #define IOPRIO_WHO_PROCESS 1 22 | 23 | #define IOPRIO_CLASS_SHIFT (13) 24 | #define IOPRIO_PRIO_MASK ((1UL << IOPRIO_CLASS_SHIFT) - 1) 25 | 26 | #define IOPriority_class(ioprio_) ((int) ((ioprio_) >> IOPRIO_CLASS_SHIFT) ) 27 | #define IOPriority_data(ioprio_) ((int) ((ioprio_) & IOPRIO_PRIO_MASK) ) 28 | 29 | typedef int IOPriority; 30 | 31 | #define IOPriority_tuple(class_, data_) (((class_) << IOPRIO_CLASS_SHIFT) | (data_)) 32 | 33 | #define IOPriority_None IOPriority_tuple(IOPRIO_CLASS_NONE, 0) 34 | #define IOPriority_Idle IOPriority_tuple(IOPRIO_CLASS_IDLE, 7) 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /linux/IOPriorityPanel.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - IOPriorityPanel.c 3 | (C) 2004-2012 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "linux/IOPriorityPanel.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "FunctionBar.h" 16 | #include "ListItem.h" 17 | #include "Object.h" 18 | #include "XUtils.h" 19 | #include "IOPriority.h" 20 | 21 | 22 | Panel* IOPriorityPanel_new(IOPriority currPrio) { 23 | Panel* this = Panel_new(1, 1, 1, 1, Class(ListItem), true, FunctionBar_newEnterEsc("Set ", "Cancel ")); 24 | 25 | Panel_setHeader(this, "IO Priority:"); 26 | Panel_add(this, (Object*) ListItem_new("None (based on nice)", IOPriority_None)); 27 | if (currPrio == IOPriority_None) { 28 | Panel_setSelected(this, 0); 29 | } 30 | static const struct { 31 | int klass; 32 | const char* name; 33 | } classes[] = { 34 | { .klass = IOPRIO_CLASS_RT, .name = "Realtime" }, 35 | { .klass = IOPRIO_CLASS_BE, .name = "Best-effort" }, 36 | { .klass = 0, .name = NULL } 37 | }; 38 | for (int c = 0; classes[c].name; c++) { 39 | for (int i = 0; i < 8; i++) { 40 | char name[50]; 41 | xSnprintf(name, sizeof(name), "%s %d %s", classes[c].name, i, i == 0 ? "(High)" : (i == 7 ? "(Low)" : "")); 42 | IOPriority ioprio = IOPriority_tuple(classes[c].klass, i); 43 | Panel_add(this, (Object*) ListItem_new(name, ioprio)); 44 | if (currPrio == ioprio) { 45 | Panel_setSelected(this, Panel_size(this) - 1); 46 | } 47 | } 48 | } 49 | Panel_add(this, (Object*) ListItem_new("Idle", IOPriority_Idle)); 50 | if (currPrio == IOPriority_Idle) { 51 | Panel_setSelected(this, Panel_size(this) - 1); 52 | } 53 | return this; 54 | } 55 | 56 | IOPriority IOPriorityPanel_getIOPriority(Panel* this) { 57 | const ListItem* selected = (ListItem*) Panel_getSelected(this); 58 | return selected ? selected->key : IOPriority_None; 59 | } 60 | -------------------------------------------------------------------------------- /linux/IOPriorityPanel.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_IOPriorityPanel 2 | #define HEADER_IOPriorityPanel 3 | /* 4 | htop - IOPriorityPanel.h 5 | (C) 2004-2012 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Panel.h" 11 | #include "linux/IOPriority.h" 12 | 13 | Panel* IOPriorityPanel_new(IOPriority currPrio); 14 | 15 | IOPriority IOPriorityPanel_getIOPriority(Panel* this); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /linux/LibNl.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_LibNl 2 | #define HEADER_LibNl 3 | /* 4 | htop - linux/LibNl.h 5 | (C) 2024 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "linux/LinuxProcess.h" 11 | #include "linux/LinuxProcessTable.h" 12 | 13 | 14 | void LibNl_destroyNetlinkSocket(LinuxProcessTable* this); 15 | 16 | void LibNl_readDelayAcctData(LinuxProcessTable* this, LinuxProcess* process); 17 | 18 | #endif /* HEADER_LibNl */ 19 | -------------------------------------------------------------------------------- /linux/LibSensors.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_LibSensors 2 | #define HEADER_LibSensors 3 | /* 4 | htop - linux/LibSensors.h 5 | (C) 2020-2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "linux/LinuxMachine.h" 11 | 12 | 13 | int LibSensors_init(void); 14 | void LibSensors_cleanup(void); 15 | int LibSensors_reload(void); 16 | 17 | int LibSensors_countCCDs(void); 18 | void LibSensors_getCPUTemperatures(CPUData* cpus, unsigned int existingCPUs, unsigned int activeCPUs); 19 | 20 | #endif /* HEADER_LibSensors */ 21 | -------------------------------------------------------------------------------- /linux/LinuxProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_LinuxProcessTable 2 | #define HEADER_LinuxProcessTable 3 | /* 4 | htop - LinuxProcessTable.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 | 10 | #include 11 | 12 | #include "ProcessTable.h" 13 | 14 | 15 | typedef struct TtyDriver_ { 16 | char* path; 17 | unsigned int major; 18 | unsigned int minorFrom; 19 | unsigned int minorTo; 20 | } TtyDriver; 21 | 22 | typedef struct LinuxProcessTable_ { 23 | ProcessTable super; 24 | 25 | TtyDriver* ttyDrivers; 26 | bool haveSmapsRollup; 27 | bool haveAutogroup; 28 | 29 | #ifdef HAVE_DELAYACCT 30 | struct nl_sock* netlink_socket; 31 | int netlink_family; 32 | #endif 33 | } LinuxProcessTable; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /linux/PressureStallMeter.h: -------------------------------------------------------------------------------- 1 | /* Do not edit this file. It was automatically generated. */ 2 | 3 | #ifndef HEADER_PressureStallMeter 4 | #define HEADER_PressureStallMeter 5 | /* 6 | htop - PressureStallMeter.h 7 | (C) 2004-2011 Hisham H. Muhammad 8 | (C) 2019 Ran Benita 9 | Released under the GNU GPLv2+, see the COPYING file 10 | in the source distribution for its full text. 11 | */ 12 | 13 | #include "Meter.h" 14 | 15 | 16 | extern const MeterClass PressureStallCPUSomeMeter_class; 17 | 18 | extern const MeterClass PressureStallIOSomeMeter_class; 19 | 20 | extern const MeterClass PressureStallIOFullMeter_class; 21 | 22 | extern const MeterClass PressureStallIRQFullMeter_class; 23 | 24 | extern const MeterClass PressureStallMemorySomeMeter_class; 25 | 26 | extern const MeterClass PressureStallMemoryFullMeter_class; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /linux/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_LinuxProcessField 2 | #define HEADER_LinuxProcessField 3 | /* 4 | htop - linux/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | CMINFLT = 11, \ 13 | CMAJFLT = 13, \ 14 | UTIME = 14, \ 15 | STIME = 15, \ 16 | CUTIME = 16, \ 17 | CSTIME = 17, \ 18 | M_SHARE = 41, \ 19 | M_TRS = 42, \ 20 | M_DRS = 43, \ 21 | M_LRS = 44, \ 22 | CTID = 100, \ 23 | VPID = 101, \ 24 | VXID = 102, \ 25 | RCHAR = 103, \ 26 | WCHAR = 104, \ 27 | SYSCR = 105, \ 28 | SYSCW = 106, \ 29 | RBYTES = 107, \ 30 | WBYTES = 108, \ 31 | CNCLWB = 109, \ 32 | IO_READ_RATE = 110, \ 33 | IO_WRITE_RATE = 111, \ 34 | IO_RATE = 112, \ 35 | CGROUP = 113, \ 36 | OOM = 114, \ 37 | IO_PRIORITY = 115, \ 38 | PERCENT_CPU_DELAY = 116, \ 39 | PERCENT_IO_DELAY = 117, \ 40 | PERCENT_SWAP_DELAY = 118, \ 41 | M_PSS = 119, \ 42 | M_SWAP = 120, \ 43 | M_PSSWP = 121, \ 44 | CTXT = 122, \ 45 | SECATTR = 123, \ 46 | AUTOGROUP_ID = 127, \ 47 | AUTOGROUP_NICE = 128, \ 48 | CCGROUP = 129, \ 49 | CONTAINER = 130, \ 50 | M_PRIV = 131, \ 51 | GPU_TIME = 132, \ 52 | GPU_PERCENT = 133, \ 53 | ISCONTAINER = 134, \ 54 | // End of list 55 | 56 | 57 | #endif /* HEADER_LinuxProcessField */ 58 | -------------------------------------------------------------------------------- /linux/SELinuxMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - SELinuxMeter.c 3 | (C) 2020 htop dev team 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "linux/SELinuxMeter.h" 11 | 12 | #include "CRT.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "Object.h" 22 | #include "XUtils.h" 23 | 24 | 25 | static const int SELinuxMeter_attributes[] = { 26 | METER_TEXT, 27 | }; 28 | 29 | static bool enabled = false; 30 | static bool enforcing = false; 31 | 32 | static bool hasSELinuxMount(void) { 33 | struct statfs sfbuf; 34 | int r = statfs("/sys/fs/selinux", &sfbuf); 35 | if (r != 0) { 36 | return false; 37 | } 38 | 39 | if ((uint32_t)sfbuf.f_type != /* SELINUX_MAGIC */ 0xf97cff8cU) { 40 | return false; 41 | } 42 | 43 | struct statvfs vfsbuf; 44 | r = statvfs("/sys/fs/selinux", &vfsbuf); 45 | if (r != 0 || (vfsbuf.f_flag & ST_RDONLY)) { 46 | return false; 47 | } 48 | 49 | return true; 50 | } 51 | 52 | static bool isSelinuxEnabled(void) { 53 | return hasSELinuxMount() && (0 == access("/etc/selinux/config", F_OK)); 54 | } 55 | 56 | static bool isSelinuxEnforcing(void) { 57 | if (!enabled) { 58 | return false; 59 | } 60 | 61 | char buf[20]; 62 | ssize_t r = xReadfile("/sys/fs/selinux/enforce", buf, sizeof(buf)); 63 | if (r < 0) 64 | return false; 65 | 66 | int enforce = 0; 67 | if (sscanf(buf, "%d", &enforce) != 1) { 68 | return false; 69 | } 70 | 71 | return !!enforce; 72 | } 73 | 74 | static void SELinuxMeter_updateValues(Meter* this) { 75 | enabled = isSelinuxEnabled(); 76 | enforcing = isSelinuxEnforcing(); 77 | 78 | xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%s%s", enabled ? "enabled" : "disabled", enabled ? (enforcing ? "; mode: enforcing" : "; mode: permissive") : ""); 79 | } 80 | 81 | const MeterClass SELinuxMeter_class = { 82 | .super = { 83 | .extends = Class(Meter), 84 | .delete = Meter_delete, 85 | }, 86 | .updateValues = SELinuxMeter_updateValues, 87 | .defaultMode = TEXT_METERMODE, 88 | .supportedModes = (1 << TEXT_METERMODE), 89 | .maxItems = 0, 90 | .total = 0.0, 91 | .attributes = SELinuxMeter_attributes, 92 | .name = "SELinux", 93 | .uiName = "SELinux", 94 | .description = "SELinux state overview", 95 | .caption = "SELinux: " 96 | }; 97 | -------------------------------------------------------------------------------- /linux/SELinuxMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SELinuxMeter 2 | #define HEADER_SELinuxMeter 3 | /* 4 | htop - SELinuxMeter.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Meter.h" 11 | 12 | 13 | extern const MeterClass SELinuxMeter_class; 14 | 15 | #endif /* HEADER_SELinuxMeter */ 16 | -------------------------------------------------------------------------------- /linux/SystemdMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SystemdMeter 2 | #define HEADER_SystemdMeter 3 | 4 | /* 5 | htop - SystemdMeter.h 6 | (C) 2020 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include "Meter.h" 12 | 13 | 14 | extern const MeterClass SystemdMeter_class; 15 | 16 | extern const MeterClass SystemdUserMeter_class; 17 | 18 | #endif /* HEADER_SystemdMeter */ 19 | -------------------------------------------------------------------------------- /linux/ZramMeter.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - linux/ZramMeter.c 3 | (C) 2020 Murloc Knight 4 | (C) 2020-2023 htop dev team 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "linux/ZramMeter.h" 12 | 13 | #include 14 | 15 | #include "CRT.h" 16 | #include "Meter.h" 17 | #include "Object.h" 18 | #include "Platform.h" 19 | #include "RichString.h" 20 | #include "ZramMeter.h" 21 | 22 | 23 | static const int ZramMeter_attributes[ZRAM_METER_ITEMCOUNT] = { 24 | [ZRAM_METER_COMPRESSED] = ZRAM_COMPRESSED, 25 | [ZRAM_METER_UNCOMPRESSED] = ZRAM_UNCOMPRESSED, 26 | }; 27 | 28 | static void ZramMeter_updateValues(Meter* this) { 29 | char* buffer = this->txtBuffer; 30 | size_t size = sizeof(this->txtBuffer); 31 | int written; 32 | 33 | Platform_setZramValues(this); 34 | 35 | written = Meter_humanUnit(buffer, this->values[ZRAM_METER_COMPRESSED], size); 36 | METER_BUFFER_CHECK(buffer, size, written); 37 | 38 | METER_BUFFER_APPEND_CHR(buffer, size, '('); 39 | 40 | double uncompressed = this->values[ZRAM_METER_COMPRESSED] + this->values[ZRAM_METER_UNCOMPRESSED]; 41 | written = Meter_humanUnit(buffer, uncompressed, size); 42 | METER_BUFFER_CHECK(buffer, size, written); 43 | 44 | METER_BUFFER_APPEND_CHR(buffer, size, ')'); 45 | 46 | METER_BUFFER_APPEND_CHR(buffer, size, '/'); 47 | 48 | Meter_humanUnit(buffer, this->total, size); 49 | } 50 | 51 | static void ZramMeter_display(const Object* cast, RichString* out) { 52 | char buffer[50]; 53 | const Meter* this = (const Meter*)cast; 54 | 55 | RichString_writeAscii(out, CRT_colors[METER_TEXT], ":"); 56 | 57 | Meter_humanUnit(buffer, this->total, sizeof(buffer)); 58 | RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); 59 | 60 | Meter_humanUnit(buffer, this->values[ZRAM_METER_COMPRESSED], sizeof(buffer)); 61 | RichString_appendAscii(out, CRT_colors[METER_TEXT], " used:"); 62 | RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); 63 | 64 | double uncompressed = this->values[ZRAM_METER_COMPRESSED] + this->values[ZRAM_METER_UNCOMPRESSED]; 65 | Meter_humanUnit(buffer, uncompressed, sizeof(buffer)); 66 | RichString_appendAscii(out, CRT_colors[METER_TEXT], " uncompressed:"); 67 | RichString_appendAscii(out, CRT_colors[METER_VALUE], buffer); 68 | } 69 | 70 | const MeterClass ZramMeter_class = { 71 | .super = { 72 | .extends = Class(Meter), 73 | .delete = Meter_delete, 74 | .display = ZramMeter_display, 75 | }, 76 | .updateValues = ZramMeter_updateValues, 77 | .defaultMode = BAR_METERMODE, 78 | .supportedModes = METERMODE_DEFAULT_SUPPORTED, 79 | .maxItems = ZRAM_METER_ITEMCOUNT, 80 | .total = 100.0, 81 | .attributes = ZramMeter_attributes, 82 | .name = "Zram", 83 | .uiName = "Zram", 84 | .caption = "zrm" 85 | }; 86 | -------------------------------------------------------------------------------- /linux/ZramMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZramMeter 2 | #define HEADER_ZramMeter 3 | /* 4 | htop - linux/ZramMeter.h 5 | (C) 2020 Murloc Knight 6 | (C) 2020-2023 htop dev team 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include "Meter.h" 12 | 13 | typedef enum { 14 | ZRAM_METER_COMPRESSED = 0, 15 | ZRAM_METER_UNCOMPRESSED = 1, 16 | ZRAM_METER_ITEMCOUNT = 2, // number of entries in this enum 17 | } ZramMeterValues; 18 | 19 | extern const MeterClass ZramMeter_class; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /linux/ZramStats.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZramStats 2 | #define HEADER_ZramStats 3 | /* 4 | htop - ZramStats.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "ProcessTable.h" 11 | 12 | typedef struct ZramStats_ { 13 | memory_t totalZram; 14 | memory_t usedZramComp; 15 | memory_t usedZramOrig; 16 | } ZramStats; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /linux/ZswapStats.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZswapStats 2 | #define HEADER_ZswapStats 3 | /* 4 | htop - ZswapStats.h 5 | (C) 2022 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "ProcessTable.h" 11 | 12 | typedef struct ZswapStats_ { 13 | /* amount of RAM used by the zswap pool */ 14 | memory_t usedZswapComp; 15 | /* amount of data stored inside the zswap pool */ 16 | memory_t usedZswapOrig; 17 | } ZswapStats; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /netbsd/NetBSDMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_NetBSDMachine 2 | #define HEADER_NetBSDMachine 3 | /* 4 | htop - NetBSDMachine.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | (C) 2021 Santhosh Raju 8 | (C) 2021 htop dev team 9 | Released under the GNU GPLv2+, see the COPYING file 10 | in the source distribution for its full text. 11 | */ 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "Machine.h" 18 | #include "ProcessTable.h" 19 | 20 | 21 | typedef struct CPUData_ { 22 | unsigned long long int totalTime; 23 | unsigned long long int userTime; 24 | unsigned long long int niceTime; 25 | unsigned long long int sysTime; 26 | unsigned long long int sysAllTime; 27 | unsigned long long int spinTime; 28 | unsigned long long int intrTime; 29 | unsigned long long int idleTime; 30 | 31 | unsigned long long int totalPeriod; 32 | unsigned long long int userPeriod; 33 | unsigned long long int nicePeriod; 34 | unsigned long long int sysPeriod; 35 | unsigned long long int sysAllPeriod; 36 | unsigned long long int spinPeriod; 37 | unsigned long long int intrPeriod; 38 | unsigned long long int idlePeriod; 39 | 40 | double frequency; 41 | } CPUData; 42 | 43 | typedef struct NetBSDMachine_ { 44 | Machine super; 45 | kvm_t* kd; 46 | 47 | long fscale; 48 | int pageSize; 49 | int pageSizeKB; 50 | 51 | CPUData* cpuData; 52 | } NetBSDMachine; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /netbsd/NetBSDProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_NetBSDProcess 2 | #define HEADER_NetBSDProcess 3 | /* 4 | htop - NetBSDProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | (C) 2021 Santhosh Raju 8 | (C) 2021 htop dev team 9 | Released under the GNU GPLv2+, see the COPYING file 10 | in the source distribution for its full text. 11 | */ 12 | 13 | #include 14 | 15 | #include "Machine.h" 16 | #include "Object.h" 17 | #include "Process.h" 18 | 19 | 20 | typedef struct NetBSDProcess_ { 21 | Process super; 22 | } NetBSDProcess; 23 | 24 | extern const ProcessClass NetBSDProcess_class; 25 | 26 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 27 | 28 | Process* NetBSDProcess_new(const Machine* host); 29 | 30 | void Process_delete(Object* cast); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /netbsd/NetBSDProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_NetBSDProcessTable 2 | #define HEADER_NetBSDProcessTable 3 | /* 4 | htop - NetBSDProcessTable.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | (C) 2021 Santhosh Raju 8 | (C) 2021 htop dev team 9 | Released under the GNU GPLv2+, see the COPYING file 10 | in the source distribution for its full text. 11 | */ 12 | 13 | #include 14 | #include 15 | 16 | #include "Hashtable.h" 17 | #include "ProcessTable.h" 18 | 19 | 20 | typedef struct NetBSDProcessTable_ { 21 | ProcessTable super; 22 | } NetBSDProcessTable; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /netbsd/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_NetBSDProcessField 2 | #define HEADER_NetBSDProcessField 3 | /* 4 | htop - netbsd/ProcessField.h 5 | (C) 2021 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | // End of list 13 | 14 | 15 | #endif /* HEADER_NetBSDProcessField */ 16 | -------------------------------------------------------------------------------- /netbsd/README.md: -------------------------------------------------------------------------------- 1 | NetBSD support in htop(1) 2 | === 3 | 4 | This implementation utilizes kvm_getprocs(3), sysctl(3), etc, eliminating the 5 | need for mount_procfs(8) with Linux compatibility enabled. 6 | 7 | The implementation was initially based on the OpenBSD support in htop(1). 8 | 9 | Notes on NetBSD curses 10 | --- 11 | 12 | NetBSD is one of the last operating systems to use and maintain its own 13 | implementation of Curses. 14 | 15 | htop(1) can be compiled against either ncurses or NetBSD's curses(3). 16 | By default, htop(1) will use ncurses when it is found, as support for NetBSD's 17 | curses in htop is limited. 18 | 19 | To use NetBSD's libcurses, htop(1) must be configured with `--disable-unicode`. 20 | Starting with htop 3.4.0, a new option `--with-curses=curses` may be specified 21 | to let `configure` skip ncurses when both libraries are installed. 22 | 23 | Technical caveats regarding NetBSD's curses support: 24 | 25 | * htop with Unicode enabled directly accesses ncurses's `cchar_t` struct, which 26 | has different contents in NetBSD's curses. 27 | 28 | * Versions of libcurses in NetBSD 9 and prior have no mouse support 29 | (this is an ncurses extension). Newer versions contain no-op mouse functions 30 | for compatibility with ncurses. 31 | 32 | What needs improvement 33 | --- 34 | 35 | * Kernel and userspace threads are not displayed or counted - 36 | maybe look at NetBSD top(1). 37 | * Support for compiling using libcurses's Unicode support. 38 | * Support for fstat(1) (view open files, like lsof(8) on Linux). 39 | * Support for ktrace(1) (like strace(1) on Linux). 40 | -------------------------------------------------------------------------------- /openbsd/OpenBSDMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OpenBSDMachine 2 | #define HEADER_OpenBSDMachine 3 | /* 4 | htop - OpenBSDMachine.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include "Machine.h" 16 | 17 | 18 | typedef struct CPUData_ { 19 | unsigned long long int totalTime; 20 | unsigned long long int userTime; 21 | unsigned long long int niceTime; 22 | unsigned long long int sysTime; 23 | unsigned long long int sysAllTime; 24 | unsigned long long int spinTime; 25 | unsigned long long int intrTime; 26 | unsigned long long int idleTime; 27 | 28 | unsigned long long int totalPeriod; 29 | unsigned long long int userPeriod; 30 | unsigned long long int nicePeriod; 31 | unsigned long long int sysPeriod; 32 | unsigned long long int sysAllPeriod; 33 | unsigned long long int spinPeriod; 34 | unsigned long long int intrPeriod; 35 | unsigned long long int idlePeriod; 36 | 37 | bool online; 38 | } CPUData; 39 | 40 | typedef struct OpenBSDMachine_ { 41 | Machine super; 42 | kvm_t* kd; 43 | 44 | CPUData* cpuData; 45 | 46 | long fscale; 47 | int cpuSpeed; 48 | int pageSize; 49 | int pageSizeKB; 50 | 51 | } OpenBSDMachine; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /openbsd/OpenBSDProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OpenBSDProcess 2 | #define HEADER_OpenBSDProcess 3 | /* 4 | htop - OpenBSDProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | 13 | #include "Machine.h" 14 | #include "Object.h" 15 | #include "Process.h" 16 | 17 | 18 | typedef struct OpenBSDProcess_ { 19 | Process super; 20 | 21 | /* 'Kernel virtual addr of u-area' to detect main threads */ 22 | uint64_t addr; 23 | } OpenBSDProcess; 24 | 25 | extern const ProcessClass OpenBSDProcess_class; 26 | 27 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 28 | 29 | Process* OpenBSDProcess_new(const Machine* host); 30 | 31 | void Process_delete(Object* cast); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /openbsd/OpenBSDProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OpenBSDProcessTable 2 | #define HEADER_OpenBSDProcessTable 3 | /* 4 | htop - OpenBSDProcessTable.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2015 Michael McConville 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "ProcessTable.h" 15 | 16 | 17 | typedef struct OpenBSDProcessTable_ { 18 | ProcessTable super; 19 | } OpenBSDProcessTable; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /openbsd/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_OpenBSDProcessField 2 | #define HEADER_OpenBSDProcessField 3 | /* 4 | htop - openbsd/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | // End of list 13 | 14 | 15 | #endif /* HEADER_OpenBSDProcessField */ 16 | -------------------------------------------------------------------------------- /pcp-htop.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - pcp-htop.c 3 | (C) 2004-2011 Hisham H. Muhammad 4 | (C) 2020-2021 htop dev team 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include 12 | 13 | #include "CommandLine.h" 14 | #include "Platform.h" 15 | 16 | 17 | const char* program = "pcp-htop"; 18 | 19 | int main(int argc, char** argv) { 20 | pmSetProgname(program); 21 | 22 | /* extract environment variables */ 23 | opts.flags |= PM_OPTFLAG_ENV_ONLY; 24 | (void)pmGetOptions(argc, argv, &opts); 25 | 26 | return CommandLine_run(argc, argv); 27 | } 28 | -------------------------------------------------------------------------------- /pcp/InDomTable.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - InDomTable.c 3 | (C) 2023 htop dev team 4 | (C) 2022-2023 Sohaib Mohammed 5 | Released under the GNU GPLv2+, see the COPYING file 6 | in the source distribution for its full text. 7 | */ 8 | 9 | #include "config.h" // IWYU pragma: keep 10 | 11 | #include "pcp/InDomTable.h" 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include "CRT.h" 18 | #include "DynamicColumn.h" 19 | #include "Hashtable.h" 20 | #include "Macros.h" 21 | #include "Platform.h" 22 | #include "Table.h" 23 | #include "Vector.h" 24 | #include "XUtils.h" 25 | 26 | #include "pcp/Instance.h" 27 | #include "pcp/Metric.h" 28 | #include "pcp/PCPDynamicColumn.h" 29 | 30 | 31 | InDomTable* InDomTable_new(Machine* host, pmInDom indom, int metricKey) { 32 | InDomTable* this = xCalloc(1, sizeof(InDomTable)); 33 | Object_setClass(this, Class(InDomTable)); 34 | this->metricKey = metricKey; 35 | this->id = indom; 36 | 37 | Table* super = &this->super; 38 | Table_init(super, Class(Row), host); 39 | 40 | return this; 41 | } 42 | 43 | void InDomTable_done(InDomTable* this) { 44 | Table_done(&this->super); 45 | } 46 | 47 | static void InDomTable_delete(Object* cast) { 48 | InDomTable* this = (InDomTable*) cast; 49 | InDomTable_done(this); 50 | free(this); 51 | } 52 | 53 | static Instance* InDomTable_getInstance(InDomTable* this, int id, bool* preExisting) { 54 | const Table* super = &this->super; 55 | Instance* inst = (Instance*) Hashtable_get(super->table, id); 56 | *preExisting = inst != NULL; 57 | if (inst) { 58 | assert(Vector_indexOf(super->rows, inst, Row_idEqualCompare) != -1); 59 | assert(Instance_getId(inst) == id); 60 | } else { 61 | inst = Instance_new(super->host, this); 62 | assert(inst->name == NULL); 63 | Instance_setId(inst, id); 64 | } 65 | return inst; 66 | } 67 | 68 | static void InDomTable_goThroughEntries(InDomTable* this) { 69 | Table* super = &this->super; 70 | 71 | /* for every instance ... */ 72 | int instid = -1, offset = -1; 73 | while (Metric_iterate(this->metricKey, &instid, &offset)) { 74 | bool preExisting; 75 | Instance* inst = InDomTable_getInstance(this, instid, &preExisting); 76 | inst->offset = offset >= 0 ? offset : 0; 77 | 78 | Row* row = (Row*) inst; 79 | if (!preExisting) 80 | Table_add(super, row); 81 | row->updated = true; 82 | row->show = true; 83 | } 84 | } 85 | 86 | static void InDomTable_iterateEntries(Table* super) { 87 | InDomTable* this = (InDomTable*) super; 88 | InDomTable_goThroughEntries(this); 89 | } 90 | 91 | const TableClass InDomTable_class = { 92 | .super = { 93 | .extends = Class(Table), 94 | .delete = InDomTable_delete, 95 | }, 96 | .prepare = Table_prepareEntries, 97 | .iterate = InDomTable_iterateEntries, 98 | .cleanup = Table_cleanupEntries, 99 | }; 100 | -------------------------------------------------------------------------------- /pcp/InDomTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_InDomTable 2 | #define HEADER_InDomTable 3 | /* 4 | htop - InDomTable.h 5 | (C) 2023 htop dev team 6 | (C) 2022-2023 Sohaib Mohammed 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | #include "Platform.h" 15 | #include "Table.h" 16 | 17 | 18 | typedef struct InDomTable_ { 19 | Table super; 20 | pmInDom id; /* shared by metrics in the table */ 21 | unsigned int metricKey; /* representative metric using this indom */ 22 | } InDomTable; 23 | 24 | extern const TableClass InDomTable_class; 25 | 26 | InDomTable* InDomTable_new(Machine* host, pmInDom indom, int metricKey); 27 | 28 | void InDomTable_done(InDomTable* this); 29 | 30 | RowField RowField_keyAt(const Settings* settings, int at); 31 | 32 | void InDomTable_scan(Table* super); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /pcp/Instance.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_Instance 2 | #define HEADER_Instance 3 | /* 4 | htop - Instance.h 5 | (C) 2022-2023 htop dev team 6 | (C) 2022-2023 Sohaib Mohammed 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include "Hashtable.h" 12 | #include "Object.h" 13 | #include "Platform.h" 14 | #include "Row.h" 15 | 16 | 17 | typedef struct Instance_ { 18 | Row super; 19 | 20 | char* name; /* external instance name */ 21 | const struct InDomTable_* indom; /* instance domain */ 22 | 23 | /* default result offset to use for searching metrics with instances */ 24 | unsigned int offset; 25 | } Instance; 26 | 27 | #define InDom_getId(i_) ((i_)->indom->id) 28 | #define Instance_getId(i_) ((i_)->super.id) 29 | #define Instance_setId(i_, id_) ((i_)->super.id = (id_)) 30 | 31 | extern const RowClass Instance_class; 32 | 33 | Instance* Instance_new(const Machine* host, const struct InDomTable_* indom); 34 | 35 | void Instance_done(Instance* this); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /pcp/PCPDynamicColumn.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPDynamicColumn 2 | #define HEADER_PCPDynamicColumn 3 | /* 4 | htop - PCPDynamicColumn.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "DynamicColumn.h" 13 | #include "Hashtable.h" 14 | #include "Process.h" 15 | #include "RichString.h" 16 | 17 | #include "pcp/PCPProcess.h" 18 | 19 | 20 | struct pmDesc; 21 | 22 | typedef struct PCPDynamicColumn_ { 23 | DynamicColumn super; 24 | char* metricName; 25 | char* format; 26 | size_t id; /* identifier for metric array lookups */ 27 | int width; /* optional width from configuration file */ 28 | bool defaultEnabled; /* default enabled in dynamic screen */ 29 | bool percent; 30 | bool instances; /* an instance *names* column, not values */ 31 | } PCPDynamicColumn; 32 | 33 | typedef struct PCPDynamicColumns_ { 34 | Hashtable* table; 35 | size_t count; /* count of dynamic columns discovered by scan */ 36 | size_t offset; /* start offset into the Platform metric array */ 37 | size_t cursor; /* identifier allocator for each new metric used */ 38 | } PCPDynamicColumns; 39 | 40 | void PCPDynamicColumns_init(PCPDynamicColumns* columns); 41 | 42 | void PCPDynamicColumns_done(Hashtable* table); 43 | 44 | void PCPDynamicColumns_setupWidths(PCPDynamicColumns* columns); 45 | 46 | void PCPDynamicColumn_writeField(PCPDynamicColumn* this, const Process* proc, RichString* str); 47 | 48 | void PCPDynamicColumn_writeAtomValue(PCPDynamicColumn* column, RichString* str, const struct Settings_* settings, int metric, int instance, const struct pmDesc* desc, const void* atomvalue); 49 | 50 | int PCPDynamicColumn_compareByKey(const PCPProcess* p1, const PCPProcess* p2, ProcessField key); 51 | 52 | void PCPDynamicColumn_done(PCPDynamicColumn* this); 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /pcp/PCPDynamicMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPDynamicMeter 2 | #define HEADER_PCPDynamicMeter 3 | /* 4 | htop - PCPDynamicMeter.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | 12 | #include "CRT.h" 13 | #include "DynamicMeter.h" 14 | #include "Hashtable.h" 15 | #include "Meter.h" 16 | #include "RichString.h" 17 | 18 | 19 | typedef struct PCPDynamicMetric_ { 20 | size_t id; /* index into metric array */ 21 | ColorElements color; 22 | char* name; /* derived metric name */ 23 | char* label; 24 | char* suffix; 25 | } PCPDynamicMetric; 26 | 27 | typedef struct PCPDynamicMeter_ { 28 | DynamicMeter super; 29 | PCPDynamicMetric* metrics; 30 | size_t totalMetrics; 31 | } PCPDynamicMeter; 32 | 33 | typedef struct PCPDynamicMeters_ { 34 | Hashtable* table; 35 | size_t count; /* count of dynamic meters discovered by scan */ 36 | size_t offset; /* start offset into the Platform metric array */ 37 | size_t cursor; /* identifier allocator for each new metric used */ 38 | } PCPDynamicMeters; 39 | 40 | void PCPDynamicMeters_init(PCPDynamicMeters* meters); 41 | 42 | void PCPDynamicMeters_done(Hashtable* table); 43 | 44 | void PCPDynamicMeter_enable(PCPDynamicMeter* this); 45 | 46 | void PCPDynamicMeter_updateValues(PCPDynamicMeter* this, Meter* meter); 47 | 48 | void PCPDynamicMeter_display(PCPDynamicMeter* this, const Meter* meter, RichString* out); 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /pcp/PCPDynamicScreen.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPDynamicScreen 2 | #define HEADER_PCPDynamicScreen 3 | /* 4 | htop - PCPDynamicScreen.h 5 | (C) 2023 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "CRT.h" 14 | #include "DynamicScreen.h" 15 | #include "Hashtable.h" 16 | #include "Machine.h" 17 | #include "Panel.h" 18 | #include "Settings.h" 19 | 20 | 21 | struct InDomTable_; 22 | struct PCPDynamicColumn_; 23 | struct PCPDynamicColumns_; 24 | 25 | typedef struct PCPDynamicScreen_ { 26 | DynamicScreen super; 27 | 28 | struct InDomTable_* table; 29 | struct PCPDynamicColumn_** columns; 30 | size_t totalColumns; 31 | 32 | unsigned int indom; /* instance domain number */ 33 | unsigned int key; /* PCPMetric identifier */ 34 | 35 | bool defaultEnabled; /* enabled setting from configuration file */ 36 | /* at runtime enabled screens have entries in settings->screens */ 37 | } PCPDynamicScreen; 38 | 39 | typedef struct PCPDynamicScreens_ { 40 | Hashtable* table; 41 | size_t count; /* count of dynamic screens discovered from scan */ 42 | } PCPDynamicScreens; 43 | 44 | void PCPDynamicScreens_init(PCPDynamicScreens* screens, struct PCPDynamicColumns_* columns); 45 | 46 | void PCPDynamicScreens_done(Hashtable* table); 47 | 48 | void PCPDynamicScreen_appendTables(PCPDynamicScreens* screens, Machine* host); 49 | 50 | void PCPDynamicScreen_appendScreens(PCPDynamicScreens* screens, Settings* settings); 51 | 52 | void PCPDynamicScreen_addDynamicScreen(PCPDynamicScreens* screens, ScreenSettings* ss); 53 | 54 | void PCPDynamicScreens_addAvailableColumns(Panel* availableColumns, Hashtable* screens, const char* screen); 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /pcp/PCPMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPMachine 2 | #define HEADER_PCPMachine 3 | /* 4 | htop - PCPMachine.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 | 10 | #include 11 | #include 12 | 13 | #include "Hashtable.h" 14 | #include "Machine.h" 15 | #include "UsersTable.h" 16 | 17 | #include "pcp/Platform.h" 18 | #include "linux/ZswapStats.h" 19 | #include "zfs/ZfsArcStats.h" 20 | 21 | 22 | typedef enum CPUMetric_ { 23 | CPU_TOTAL_TIME, 24 | CPU_USER_TIME, 25 | CPU_SYSTEM_TIME, 26 | CPU_SYSTEM_ALL_TIME, 27 | CPU_IDLE_ALL_TIME, 28 | CPU_IDLE_TIME, 29 | CPU_NICE_TIME, 30 | CPU_IOWAIT_TIME, 31 | CPU_IRQ_TIME, 32 | CPU_SOFTIRQ_TIME, 33 | CPU_STEAL_TIME, 34 | CPU_GUEST_TIME, 35 | CPU_GUESTNICE_TIME, 36 | 37 | CPU_TOTAL_PERIOD, 38 | CPU_USER_PERIOD, 39 | CPU_SYSTEM_PERIOD, 40 | CPU_SYSTEM_ALL_PERIOD, 41 | CPU_IDLE_ALL_PERIOD, 42 | CPU_IDLE_PERIOD, 43 | CPU_NICE_PERIOD, 44 | CPU_IOWAIT_PERIOD, 45 | CPU_IRQ_PERIOD, 46 | CPU_SOFTIRQ_PERIOD, 47 | CPU_STEAL_PERIOD, 48 | CPU_GUEST_PERIOD, 49 | CPU_GUESTNICE_PERIOD, 50 | 51 | CPU_FREQUENCY, 52 | 53 | CPU_METRIC_COUNT 54 | } CPUMetric; 55 | 56 | typedef struct PCPMachine_ { 57 | Machine super; 58 | int smaps_flag; 59 | double period; 60 | double timestamp; /* previous sample timestamp */ 61 | 62 | pmAtomValue* cpu; /* aggregate values for each metric */ 63 | pmAtomValue** percpu; /* per-processor values for each metric */ 64 | pmAtomValue* values; /* per-processor buffer for just one metric */ 65 | 66 | ZfsArcStats zfs; 67 | /*ZramStats zram; -- not needed, calculated in-line in Platform.c */ 68 | ZswapStats zswap; 69 | } PCPMachine; 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /pcp/PCPProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPProcessTable 2 | #define HEADER_PCPProcessTable 3 | /* 4 | htop - PCPProcessTable.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 | 10 | #include 11 | #include 12 | 13 | #include "Hashtable.h" 14 | #include "ProcessTable.h" 15 | #include "UsersTable.h" 16 | 17 | #include "pcp/Platform.h" 18 | 19 | 20 | typedef struct PCPProcessTable_ { 21 | ProcessTable super; 22 | } PCPProcessTable; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /pcp/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_PCPProcessField 2 | #define HEADER_PCPProcessField 3 | /* 4 | htop - pcp/ProcessField.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2021 htop dev team 7 | (C) 2020-2021 Red Hat, Inc. All Rights Reserved. 8 | Released under the GNU GPLv2+, see the COPYING file 9 | in the source distribution for its full text. 10 | */ 11 | 12 | 13 | #define PLATFORM_PROCESS_FIELDS \ 14 | CMINFLT = 11, \ 15 | CMAJFLT = 13, \ 16 | UTIME = 14, \ 17 | STIME = 15, \ 18 | CUTIME = 16, \ 19 | CSTIME = 17, \ 20 | M_SHARE = 41, \ 21 | M_TRS = 42, \ 22 | M_DRS = 43, \ 23 | M_LRS = 44, \ 24 | M_DT = 45, \ 25 | CTID = 100, \ 26 | RCHAR = 103, \ 27 | WCHAR = 104, \ 28 | SYSCR = 105, \ 29 | SYSCW = 106, \ 30 | RBYTES = 107, \ 31 | WBYTES = 108, \ 32 | CNCLWB = 109, \ 33 | IO_READ_RATE = 110, \ 34 | IO_WRITE_RATE = 111, \ 35 | IO_RATE = 112, \ 36 | CGROUP = 113, \ 37 | OOM = 114, \ 38 | PERCENT_CPU_DELAY = 116, \ 39 | PERCENT_IO_DELAY = 117, \ 40 | PERCENT_SWAP_DELAY = 118, \ 41 | M_PSS = 119, \ 42 | M_SWAP = 120, \ 43 | M_PSSWP = 121, \ 44 | CTXT = 122, \ 45 | SECATTR = 123, \ 46 | AUTOGROUP_ID = 127, \ 47 | AUTOGROUP_NICE = 128, \ 48 | CCGROUP = 129, \ 49 | CONTAINER = 130, \ 50 | M_PRIV = 131, \ 51 | // End of list 52 | 53 | 54 | #endif /* HEADER_PCPProcessField */ 55 | -------------------------------------------------------------------------------- /pcp/columns/container: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [container] 6 | heading = Container 7 | caption = CONTAINER 8 | width = -12 9 | metric = proc.id.container 10 | description = Name of processes container via cgroup heuristics 11 | -------------------------------------------------------------------------------- /pcp/columns/delayacct: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [blkio] 6 | heading = BLKIOD 7 | caption = BLKIO_TIME 8 | width = 6 9 | metric = proc.psinfo.delayacct_blkio_time 10 | description = Aggregated block I/O delays 11 | -------------------------------------------------------------------------------- /pcp/columns/fdcount: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [fds] 6 | heading = FDS 7 | caption = FDCOUNT 8 | width = 4 9 | metric = proc.fd.count 10 | description = Open file descriptors 11 | -------------------------------------------------------------------------------- /pcp/columns/gpu_memory: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [drm_memory_cpu] 6 | heading = DCPU 7 | width = 6 8 | metric = proc.fdinfo.drm_memory_cpu 9 | description = CPU memory which can be used by the GPU to store buffer objects 10 | 11 | [drm_memory_gtt] 12 | heading = DGTT 13 | width = 6 14 | metric = proc.fdinfo.drm_memory_gtt 15 | description = GTT memory which can be used by the GPU to store buffer objects 16 | 17 | [drm_memory_vram] 18 | heading = DVRAM 19 | width = 6 20 | metric = proc.fdinfo.drm_memory_vram 21 | description = VRAM memory which can be used by the GPU to store buffer objects 22 | 23 | [drm_shared_cpu] 24 | heading = DCPU_SHARE 25 | width = 6 26 | metric = proc.fdinfo.drm_shared_cpu 27 | description = CPU memory which can be used by the GPU to store buffer objects, and is shared with another file 28 | 29 | [drm_shared_gtt] 30 | heading = DGTT_SHARE 31 | width = 6 32 | metric = proc.fdinfo.drm_shared_gtt 33 | description = GTT memory which can be used by the GPU to store buffer objects, and is shared with another file 34 | 35 | [drm_shared_vram] 36 | heading = DVRAM_SHARE 37 | width = 6 38 | metric = proc.fdinfo.drm_shared_vram 39 | description = VRAM memory which can be used by the GPU to store buffer objects, and is shared with another file 40 | 41 | [amd_evicted_visible_vram] 42 | heading = AMD_EVVRAM 43 | width = 6 44 | metric = proc.fdinfo.amd_evicted_visible_vram 45 | description = Sum of evicted buffers due to CPU access 46 | 47 | [amd_evicted_vram] 48 | heading = AMD_EVRAM 49 | width = 6 50 | metric = proc.fdinfo.amd_evicted_vram 51 | description = Sum of evicted buffers, includes visible VRAM 52 | 53 | [amd_memory_visible_vram] 54 | heading = AMD_VVRAM 55 | width = 6 56 | metric = proc.fdinfo.amd_memory_visible_vram 57 | description = Current visible VRAM usage 58 | 59 | [amd_requested_gtt] 60 | heading = AMD_RGTT 61 | width = 6 62 | metric = proc.fdinfo.amd_requested_gtt 63 | description = How much GTT memory userspace asked for 64 | 65 | [amd_requested_visible_vram] 66 | heading = AMD_RVVRAM 67 | width = 6 68 | metric = proc.fdinfo.amd_requested_visible_vram 69 | description = How much visible VRAM userspace asked for 70 | 71 | [amd_requested_vram] 72 | heading = AMD_RVRAM 73 | width = 6 74 | metric = proc.fdinfo.amd_requested_vram 75 | description = How much VRAM userspace asked for, includes visible VRAM 76 | -------------------------------------------------------------------------------- /pcp/columns/guest: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [guest] 6 | heading = GUEST 7 | caption = GUEST_TIME 8 | width = 6 9 | metric = proc.psinfo.guest_time 10 | description = Guest time for the process 11 | 12 | [cguest] 13 | heading = CGUEST 14 | caption = CGUEST_TIME 15 | width = 6 16 | metric = proc.psinfo.guest_time + proc.psinfo.cguest_time 17 | description = Cumulative guest time for the process and its children 18 | -------------------------------------------------------------------------------- /pcp/columns/memory: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [vmdata] 6 | heading = VDATA 7 | width = 6 8 | metric = proc.memory.vmdata 9 | description = Virtual memory used for data 10 | 11 | [vmstack] 12 | heading = VSTACK 13 | width = -6 14 | metric = proc.memory.vmstack 15 | description = Virtual memory used for stack 16 | 17 | [vmexe] 18 | heading = VEXEC 19 | width = 6 20 | metric = proc.memory.vmexe 21 | description = Virtual memory used for non-library executable code 22 | 23 | [vmlib] 24 | heading = VLIBS 25 | width = 6 26 | metric = proc.memory.vmlib 27 | description = Virtual memory used for libraries 28 | 29 | [vmswap] 30 | heading = VSWAP 31 | width = 6 32 | metric = proc.memory.vmswap 33 | description = Virtual memory size currently swapped out 34 | 35 | [vmlock] 36 | heading = VLOCK 37 | width = 6 38 | metric = proc.memory.vmlock 39 | description = Locked virtual memory 40 | -------------------------------------------------------------------------------- /pcp/columns/sched: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [rundelay] 6 | heading = RUNQ 7 | caption = RUN_DELAY 8 | width = 4 9 | metric = proc.schedstat.run_delay 10 | description = Run queue time 11 | -------------------------------------------------------------------------------- /pcp/columns/swap: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [swap] 6 | heading = SWAP 7 | width = 5 8 | metric = proc.psinfo.nswap 9 | description = Count of swap operations for the process 10 | 11 | [cswap] 12 | heading = CSWAP 13 | width = 5 14 | metric = proc.psinfo.nswap + proc.psinfo.cnswap 15 | description = Cumulative swap operations for the process and its children 16 | -------------------------------------------------------------------------------- /pcp/columns/tcp: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [tcp_send_packets] 6 | heading = TCPS 7 | caption = TCP_SEND 8 | width = 6 9 | metric = bpf.proc.net.tcp.send.packets 10 | description = Count of TCP packets sent 11 | 12 | [tcp_send_bytes] 13 | heading = TCPSB 14 | caption = TCP_SEND_BYTES 15 | width = 6 16 | metric = bpf.proc.net.tcp.send.bytes 17 | description = Cumulative bytes sent via TCP 18 | 19 | [tcp_recv_packets] 20 | heading = TCPR 21 | caption = TCP_RECV 22 | width = 6 23 | metric = bpf.proc.net.tcp.recv.packets 24 | description = Count of TCP packets received 25 | 26 | [tcp_recv_bytes] 27 | heading = TCPRB 28 | caption = TCP_RECV_BYTES 29 | width = 6 30 | metric = bpf.proc.net.tcp.recv.bytes 31 | description = Cumulative bytes received via TCP 32 | -------------------------------------------------------------------------------- /pcp/columns/udp: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [udp_send_packets] 6 | heading = UDPS 7 | caption = UDP_SEND 8 | width = 6 9 | metric = bpf.proc.net.udp.send.packets 10 | description = Count of UDP packets sent 11 | 12 | [udp_send_bytes] 13 | heading = UDPSB 14 | caption = UDP_SEND_BYTES 15 | width = 6 16 | metric = bpf.proc.net.udp.send.bytes 17 | description = Cumulative bytes sent via UDP 18 | 19 | [udp_recv_packets] 20 | heading = UDPR 21 | caption = UDP_RECV 22 | width = 6 23 | metric = bpf.proc.net.udp.recv.packets 24 | description = Count of UDP packets received 25 | 26 | [udp_recv_bytes] 27 | heading = UDPRB 28 | caption = UDP_RECV_BYTES 29 | width = 6 30 | metric = bpf.proc.net.udp.recv.bytes 31 | description = Cumulative bytes received via UDP 32 | -------------------------------------------------------------------------------- /pcp/columns/wchan: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [wchan] 6 | heading = WCHAN 7 | caption = WCHAN_ADDRESS 8 | width = 8 9 | metric = proc.psinfo.wchan 10 | description = Wait channel, kernel address process is blocked or sleeping on 11 | 12 | [wchans] 13 | heading = WCHANS 14 | caption = WCHAN_SYMBOL 15 | width = -12 16 | metric = proc.psinfo.wchan_s 17 | description = Wait channel, kernel symbol process is blocked or sleeping on 18 | -------------------------------------------------------------------------------- /pcp/meters/entropy: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [entropy] 6 | caption = Entropy 7 | description = Entropy pool 8 | avail.metric = kernel.all.entropy.avail / kernel.all.entropy.poolsize * 100 9 | avail.label = avail 10 | avail.suffix = % 11 | -------------------------------------------------------------------------------- /pcp/meters/freespace: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [freespace] 6 | caption = Freespace 7 | description = Filesystem space 8 | used.metric = sum(filesys.used) 9 | used.color = blue 10 | free.metric = sum(filesys.free) 11 | free.color = green 12 | -------------------------------------------------------------------------------- /pcp/meters/gpu: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [amd_gpu_load] 6 | caption = AMD GPU load 7 | description = AMD GPU load 8 | load.metric = amdgpu.gpu.load 9 | load.suffix = % 10 | 11 | [amd_gpu_average_power] 12 | caption = AMD GPU average power 13 | description = AMD GPU average power in Watts 14 | average_power.metric = amdgpu.gpu.average_power 15 | average_power.suffix = W 16 | 17 | [amd_gpu_memory] 18 | type = bar 19 | caption = AMD GPU memory 20 | description = Allocated frame buffer memory 21 | used.metric = amdgpu.memory.used 22 | used.color = red 23 | total.metric = amdgpu.memory.total 24 | total.color: blue 25 | 26 | [amd_gpu_clock] 27 | caption = AMD GPU clock 28 | description = The GPU clock speed in MHz 29 | clock.metric = amdgpu.gpu.clock 30 | clock.label = MHz 31 | 32 | [amd_gpu_memory_clock] 33 | caption = AMD GPU memory clock 34 | description = The GDDRx memory clock speed in MHz 35 | clock.metric = amdgpu.memory.clock 36 | clock.label = MHz 37 | 38 | [amd_gpu_temp] 39 | caption = AMD GPU temperature 40 | description = The GPU temperature in degrees Celsius 41 | temp.metric = amdgpu.gpu.temperature / 1000 42 | temp.label = °C 43 | -------------------------------------------------------------------------------- /pcp/meters/ipc: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [ipc] 6 | caption = SysV IPC 7 | description = SysV IPC counts 8 | msg.metric = ipc.msg.used_queues 9 | msg.color = blue 10 | sem.metric = ipc.sem.used_sem 11 | sem.color = green 12 | shm.metric = ipc.shm.used_ids 13 | shm.color = cyan 14 | -------------------------------------------------------------------------------- /pcp/meters/locks: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [locks] 6 | caption = File locks 7 | description = VFS file locks 8 | posix.metric = vfs.locks.posix.count 9 | posix.color = blue 10 | flock.metric = vfs.locks.flock.count 11 | flock.color = green 12 | readlock.metric = vfs.locks.posix.read + vfs.locks.flock.read 13 | readlock.color = red 14 | writelock.metric = vfs.locks.posix.write + vfs.locks.flock.write 15 | writelock.color = yellow 16 | -------------------------------------------------------------------------------- /pcp/meters/memcache: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [memcache] 6 | caption = Memcache 7 | description = Memcache Hits 8 | hit.metric = sum(memcache.hits) 9 | hit.color = green 10 | miss.metric = sum(memcache.misses) 11 | miss.color = blue 12 | -------------------------------------------------------------------------------- /pcp/meters/mysql: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [mysql_io] 6 | caption = MySQL I/O 7 | description = MySQL throughput 8 | recv.metric = mysql.status.bytes_received 9 | recv.color = green 10 | sent.metric = mysql.status.bytes_sent 11 | sent.color = blue 12 | 13 | [mysql_keys] 14 | caption = MySQL keys 15 | description = MySQL key status 16 | key_blocks_used.metric = mysql.status.key_blocks_used 17 | key_blocks_used.color = yellow 18 | key_blocks_used.label = used 19 | key_reads.metric = mysql.status.key_reads 20 | key_reads.label = read 21 | key_reads.color = green 22 | key_writes.metric = mysql.status.key_writes 23 | key_writes.label = writ 24 | key_writes.color = blue 25 | key_read_requests.metric = mysql.status.key_read_requests 26 | key_read_requests.label = rreq 27 | key_read_requests.color = green 28 | key_write_requests.metric = mysql.status.key_write_requests 29 | key_write_requests.label = wreq 30 | key_write_requests.color = blue 31 | 32 | [innodb_buffer] 33 | caption = InnoDB pool 34 | description = InnoDB buffer pool 35 | created.metric = mysql.status.innodb_pages_created 36 | created.label = cr 37 | created.color = yellow 38 | read.metric = mysql.status.innodb_pages_read 39 | read.label = rd 40 | read.color = green 41 | written.metric = mysql.status.innodb_pages_written 42 | written.label = wr 43 | written.color = red 44 | 45 | [innodb_io] 46 | caption = InnoDB I/O 47 | description = InnoDB I/O operations 48 | read.metric = mysql.status.innodb_data_read 49 | read.label = rd 50 | read.color = green 51 | written.metric = mysql.status.innodb_data.writes 52 | written.label = wr 53 | written.color = blue 54 | sync.metric = mysql.status.innodb_data_fsyncs 55 | sync.label = sync 56 | sync.color = cyan 57 | 58 | [innodb_ops] 59 | caption = InnoDB ops 60 | description = InnoDB operations 61 | inserted.metric = mysql.status.innodb_rows_inserted 62 | inserted.label = ins 63 | inserted.color = blue 64 | updated.metric = mysql.status.innodb_rows_updated 65 | updated.label = upd 66 | updated.color = cyan 67 | deleted.metric = mysql.status.innodb_rows_deleted 68 | deleted.label = del 69 | deleted.color = red 70 | read.metric = mysql.status.innodb_rows_read 71 | read.label = rd 72 | read.color = green 73 | -------------------------------------------------------------------------------- /pcp/meters/postfix: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [postfix] 6 | caption = Postfix 7 | incoming.metric = sum(postfix.queues.incoming) 8 | incoming.color = green 9 | incoming.label = in 10 | active.metric = sum(postfix.queues.active) 11 | active.color = blue 12 | active.label = act 13 | deferred.metric = sum(postfix.queues.deferred) 14 | deferred.color = cyan 15 | deferred.label = dfr 16 | bounce.metric = sum(postfix.queues.maildrop) 17 | bounce.color = red 18 | bounce.label = bnc 19 | hold.metric = sum(postfix.queues.hold) 20 | hold.color = yellow 21 | -------------------------------------------------------------------------------- /pcp/meters/redis: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [redisxact] 6 | caption = Redis xact 7 | description = Redis transactions 8 | tps.metric = redis.instantaneous_ops_per_sec 9 | tps.color = green 10 | 11 | [redismem] 12 | caption = Redis mem 13 | description = Redis memory 14 | lua.metric = redis.used_memory_lua 15 | lua.color = magenta 16 | used.metric = redis.used_memory 17 | used.color = blue 18 | 19 | [redisclient] 20 | caption = Redis clients 21 | description = Redis clients 22 | type = bar 23 | blocked.metric = redis.blocked_clients 24 | blocked.color = blue 25 | blocked.label = blk 26 | clients.metric = redis.connected_clients 27 | clients.color = green 28 | clients.label = conn 29 | 30 | [redisconn] 31 | caption = Redis conn 32 | description = Redis connections 33 | type = bar 34 | reject.metric = redis.rejected_connections 35 | reject.color = magenta 36 | reject.label = fail/s 37 | total.metric = redis.total_connections_received 38 | total.color = blue 39 | total.label = conn/s 40 | -------------------------------------------------------------------------------- /pcp/meters/tcp: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [tcp] 6 | caption = TCP 7 | description = TCP sockets 8 | listen.metric = network.tcpconn.listen 9 | listen.color = green 10 | listen.label = lis 11 | active.metric = network.tcpconn.established 12 | active.color = blue 13 | active.label = act 14 | syn.metric = network.tcpconn.syn_sent + network.tcpconn.syn_recv + network.tcpconn.last_ack 15 | syn.color = cyan 16 | wait.metric = network.tcpconn.time_wait 17 | wait.color = red 18 | wait.label = tim 19 | close.metric = network.tcpconn.fin_wait1 + network.tcpconn.fin_wait2 + network.tcpconn.close + network.tcpconn.close_wait + network.tcpconn.closing 20 | close.color = yellow 21 | close.label = clo 22 | -------------------------------------------------------------------------------- /pcp/screens/biosnoop: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [biosnoop] 6 | heading = BioSnoop 7 | caption = BPF block I/O snoop 8 | default = false 9 | 10 | pid.heading = PID 11 | pid.caption = Process identifier 12 | pid.metric = bpf.biosnoop.pid 13 | pid.format = process 14 | 15 | disk.heading = DISK 16 | disk.caption = Device name 17 | disk.width = -7 18 | disk.metric = bpf.biosnoop.disk 19 | 20 | rwbs.heading = TYPE 21 | rwbs.caption = I/O type string 22 | rwbs.width = -4 23 | rwbs.metric = bpf.biosnoop.rwbs 24 | 25 | bytes.heading = BYTES 26 | bytes.caption = I/O size in bytes 27 | bytes.metric = bpf.biosnoop.bytes 28 | 29 | lat.heading = LAT 30 | lat.caption = I/O latency 31 | lat.metric = bpf.biosnoop.lat 32 | 33 | sector.heading = SECTOR 34 | sector.caption = Device sector 35 | sector.metric = bpf.biosnoop.sector 36 | 37 | comm.heading = Command 38 | comm.caption = Process command name 39 | comm.width = -16 40 | comm.metric = bpf.biosnoop.comm 41 | comm.format = process 42 | -------------------------------------------------------------------------------- /pcp/screens/cgroups: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [cgroups] 6 | heading = CGroups 7 | caption = Control Groups 8 | default = true 9 | 10 | user_cpu.heading = UTIME 11 | user_cpu.caption = User CPU Time 12 | user_cpu.metric = 1000 * rate(cgroup.cpu.stat.user) 13 | user_cpu.width = 6 14 | 15 | system_cpu.heading = STIME 16 | system_cpu.caption = Kernel CPU Time 17 | system_cpu.metric = 1000 * rate(cgroup.cpu.stat.system) 18 | system_cpu.width = 6 19 | 20 | cpu_usage.heading = CPU% 21 | cpu_usage.caption = CPU Utilization 22 | cpu_usage.metric = 100 * (rate(cgroup.cpu.stat.usage) / hinv.ncpu) 23 | cpu_usage.format = percent 24 | 25 | cpu_psi.heading = CPU-PSI 26 | cpu_psi.caption = CPU Pressure Stall Information 27 | cpu_psi.metric = 1000 * rate(cgroup.pressure.cpu.some.total) 28 | cpu_psi.width = 7 29 | 30 | mem_psi.heading = MEM-PSI 31 | mem_psi.caption = Memory Pressure Stall Information 32 | mem_psi.metric = 1000 * rate(cgroup.pressure.memory.some.total) 33 | mem_psi.width = 7 34 | 35 | io_psi.heading = I/O-PSI 36 | io_psi.caption = I/O Pressure Stall Information 37 | io_psi.metric = 1000 * rate(cgroup.pressure.io.some.total) 38 | io_psi.width = 7 39 | 40 | name.heading = Control group 41 | name.caption = Control group name 42 | name.width = -64 43 | name.metric = cgroup.cpu.stat.system 44 | name.instances = true 45 | name.format = cgroup 46 | -------------------------------------------------------------------------------- /pcp/screens/cgroupsio: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [cgroupsio] 6 | heading = CGroupsIO 7 | caption = Control Groups I/O 8 | default = false 9 | 10 | iops.heading = IOPS 11 | iops.caption = I/O operations 12 | iops.metric = rate(cgroup.io.stat.rios) + rate(cgroup.io.stat.wios) + rate(cgroup.io.stat.dios) 13 | 14 | readops.heading = RDIO 15 | readops.caption = Read operations 16 | readops.metric = rate(cgroup.io.stat.rios) 17 | readops.default = false 18 | 19 | writeops.heading = WRIO 20 | writeops.caption = Write operations 21 | writeops.metric = rate(cgroup.io.stat.wios) 22 | writeops.default = false 23 | 24 | directops.heading = DIO 25 | directops.caption = Direct I/O operations 26 | directops.metric = rate(cgroup.io.stat.dios) 27 | directops.default = false 28 | 29 | totalbytes.heading = R/W/D 30 | totalbytes.caption = Disk throughput 31 | totalbytes.metric = rate(cgroup.io.stat.rbytes) + rate(cgroup.io.stat.wbytes) + rate(cgroup.io.stat.dbytes) 32 | 33 | readbytes.heading = RBYTE 34 | readbytes.caption = Disk read throughput 35 | readbytes.metric = rate(cgroup.io.stat.rbytes) 36 | 37 | writebytes.heading = WBYTE 38 | writebytes.caption = Disk throughput 39 | writebytes.metric = rate(cgroup.io.stat.wbytes) 40 | 41 | directio.heading = DBYTE 42 | directio.caption = Direct I/O throughput 43 | directio.metric = rate(cgroup.io.stat.dbytes) 44 | 45 | name.heading = Control group device 46 | name.caption = Control group device 47 | name.width = -64 48 | name.metric = cgroup.io.stat.rbytes 49 | name.instances = true 50 | -------------------------------------------------------------------------------- /pcp/screens/cgroupsmem: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [cgroupsmem] 6 | heading = CGroupsMem 7 | caption = Control Groups Memory 8 | default = false 9 | 10 | current.heading = MEM 11 | current.caption = Current memory 12 | current.metric = cgroup.memory.current 13 | 14 | usage.heading = USAGE 15 | usage.caption = Memory usage 16 | usage.metric = cgroup.memory.usage 17 | 18 | container.heading = CONTAINER 19 | container.caption = Container Name 20 | container.metric = cgroup.memory.id.container 21 | 22 | resident.heading = RSS 23 | resident.metric = cgroup.memory.stat.rss 24 | 25 | cresident.heading = CRSS 26 | cresident.metric = cgroup.memory.stat.total.rss 27 | 28 | anonmem.heading = ANON 29 | anonmem.metric = cgroup.memory.stat.anon 30 | 31 | filemem.heading = FILE 32 | filemem.metric = cgroup.memory.stat.file 33 | 34 | shared.heading = SHMEM 35 | shared.metric = cgroup.memory.stat.shmem 36 | 37 | swap.heading = SWAP 38 | swap.metric = cgroup.memory.stat.swap 39 | 40 | pgfault.heading = FAULTS 41 | pgfault.metric = cgroup.memory.stat.pgfaults 42 | 43 | name.heading = Control group 44 | name.caption = Control group name 45 | name.width = -64 46 | name.metric = cgroup.memory.current 47 | name.instances = true 48 | name.format = cgroup 49 | -------------------------------------------------------------------------------- /pcp/screens/execsnoop: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [execsnoop] 6 | heading = ExecSnoop 7 | caption = BPF exec(2) syscall snoop 8 | default = false 9 | 10 | pid.heading = PID 11 | pid.caption = Process Identifier 12 | pid.metric = bpf.execsnoop.pid 13 | pid.format = process 14 | 15 | ppid.heading = PPID 16 | ppid.caption = Parent Process 17 | ppid.metric = bpf.execsnoop.ppid 18 | ppid.format = process 19 | 20 | uid.heading = UID 21 | uid.caption = User Identifier 22 | uid.metric = bpf.execsnoop.uid 23 | 24 | comm.heading = COMM 25 | comm.caption = Command 26 | comm.width = -16 27 | comm.metric = bpf.execsnoop.comm 28 | comm.format = command 29 | 30 | ret.heading = RET 31 | ret.caption = Return Code 32 | ret.metric = bpf.execsnoop.ret 33 | 34 | path.heading = Arguments 35 | path.caption = Arguments 36 | path.width = -12 37 | path.metric = bpf.execsnoop.args 38 | -------------------------------------------------------------------------------- /pcp/screens/exitsnoop: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [exitsnoop] 6 | heading = ExitSnoop 7 | caption = BPF process exit(2) snoop 8 | default = false 9 | 10 | pid.heading = PID 11 | pid.caption = Process Identifier 12 | pid.metric = bpf.exitsnoop.pid 13 | pid.format = process 14 | 15 | ppid.heading = PPID 16 | ppid.caption = Parent Process 17 | ppid.metric = bpf.exitsnoop.ppid 18 | ppid.format = process 19 | 20 | tid.heading = TID 21 | tid.caption = Task Identifier 22 | tid.metric = bpf.exitsnoop.tid 23 | tid.format = process 24 | tid.default = false 25 | 26 | signal.heading = SIG 27 | signal.caption = Signal number 28 | signal.metric = bpf.exitsnoop.sig 29 | 30 | exit.heading = EXIT 31 | exit.caption = Exit Code 32 | exit.metric = bpf.exitsnoop.exit_code 33 | 34 | core.heading = CORE 35 | core.caption = Dumped core 36 | core.metric = bpf.exitsnoop.coredump 37 | core.default = false 38 | 39 | age.heading = AGE 40 | age.caption = Process age 41 | age.metric = bpf.exitsnoop.age 42 | age.default = false 43 | 44 | comm.heading = Command 45 | comm.caption = COMM 46 | comm.width = -16 47 | comm.metric = bpf.exitsnoop.comm 48 | comm.format = command 49 | -------------------------------------------------------------------------------- /pcp/screens/filesystems: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [filesystems] 6 | heading = Filesystems 7 | caption = Mounted block device filesystems 8 | 9 | blockdev.heading = Device 10 | blockdev.metric = filesys.mountdir 11 | blockdev.instances = true 12 | blockdev.width = -14 13 | 14 | blocksize.heading = BSIZE 15 | blocksize.metric = filesys.blocksize 16 | blocksize.default = false 17 | 18 | capacity.heading = SIZE 19 | capacity.metric = filesys.capacity 20 | 21 | used.heading = USED 22 | used.metric = filesys.used 23 | 24 | free.heading = FREE 25 | free.metric = filesys.free 26 | free.default = false 27 | 28 | avail.heading = AVAIL 29 | avail.metric = filesys.avail 30 | 31 | full.heading = USE% 32 | full.metric = filesys.full 33 | full.format = percent 34 | 35 | usedfiles.heading = USEDF 36 | usedfiles.metric = filesys.usedfiles 37 | usedfiles.default = false 38 | 39 | freefiles.heading = FREEF 40 | freefiles.metric = filesys.freefiles 41 | freefiles.default = false 42 | 43 | maxfiles.heading = MAXF 44 | maxfiles.metric = filesys.maxfiles 45 | maxfiles.default = false 46 | 47 | mountdir.heading = Mount point 48 | mountdir.metric = filesys.mountdir 49 | mountdir.format = path 50 | mountdir.width = -33 51 | -------------------------------------------------------------------------------- /pcp/screens/opensnoop: -------------------------------------------------------------------------------- 1 | # 2 | # pcp-htop(1) configuration file - see pcp-htop(5) 3 | # 4 | 5 | [opensnoop] 6 | heading = OpenSnoop 7 | caption = BPF open(2) syscall snoop 8 | default = false 9 | 10 | pid.heading = PID 11 | pid.metric = bpf.opensnoop.pid 12 | pid.format = process 13 | 14 | comm.heading = COMM 15 | comm.metric = bpf.opensnoop.comm 16 | comm.format = command 17 | 18 | fd.heading = FD 19 | fd.metric = bpf.opensnoop.fd 20 | 21 | err.heading = ERR 22 | err.metric = bpf.opensnoop.err 23 | 24 | file.heading = File name 25 | file.width = -32 26 | file.metric = bpf.opensnoop.fname 27 | file.format = path 28 | -------------------------------------------------------------------------------- /scripts/htop_suppressions.valgrind: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | match-leak-kinds: possible,reachable 5 | ... 6 | fun:doupdate_sp 7 | fun:wrefresh 8 | } 9 | 10 | { 11 | 12 | Memcheck:Leak 13 | match-leak-kinds: possible,reachable 14 | ... 15 | fun:newterm_sp 16 | fun:newterm 17 | fun:initscr 18 | fun:CRT_init 19 | } 20 | 21 | { 22 | 23 | Memcheck:Leak 24 | match-leak-kinds: reachable 25 | ... 26 | obj:*/libtinfo* 27 | fun:CRT_init 28 | } 29 | 30 | { 31 | 32 | Memcheck:Leak 33 | match-leak-kinds: reachable 34 | ... 35 | obj:*/libncurses* 36 | fun:CRT_init 37 | } 38 | 39 | { 40 | 41 | Memcheck:Leak 42 | match-leak-kinds: possible,reachable 43 | ... 44 | obj:*/libncurses* 45 | fun:CRT_setColors 46 | fun:CRT_init 47 | } 48 | 49 | { 50 | 51 | Memcheck:Leak 52 | match-leak-kinds: possible,reachable 53 | ... 54 | obj:*/libdevstat* 55 | ... 56 | fun:Platform_getDiskIO 57 | } 58 | -------------------------------------------------------------------------------- /scripts/run_valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT=$(readlink -f "$0") 4 | SCRIPTDIR=$(dirname "$SCRIPT") 5 | 6 | valgrind --leak-check=full --show-reachable=yes --show-leak-kinds=all --track-fds=yes --errors-for-leak-kinds=all --track-origins=yes --suppressions="${SCRIPTDIR}/htop_suppressions.valgrind" "${SCRIPTDIR}/../htop" 7 | -------------------------------------------------------------------------------- /solaris/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SolarisProcessField 2 | #define HEADER_SolarisProcessField 3 | /* 4 | htop - solaris/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | ZONEID = 100, \ 13 | ZONE = 101, \ 14 | PROJID = 102, \ 15 | TASKID = 103, \ 16 | POOLID = 104, \ 17 | CONTID = 105, \ 18 | LWPID = 106, \ 19 | \ 20 | DUMMY_BUMP_FIELD = CWD, \ 21 | // End of list 22 | 23 | 24 | #endif /* HEADER_SolarisProcessField */ 25 | -------------------------------------------------------------------------------- /solaris/SolarisMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SolarisMachine 2 | #define HEADER_SolarisMachine 3 | /* 4 | htop - SolarisMachine.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2017,2018 Guy M. Broome 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "Hashtable.h" 22 | #include "Machine.h" 23 | #include "UsersTable.h" 24 | 25 | #include "zfs/ZfsArcStats.h" 26 | 27 | 28 | #define ZONE_ERRMSGLEN 1024 29 | extern char zone_errmsg[ZONE_ERRMSGLEN]; 30 | 31 | typedef struct CPUData_ { 32 | double userPercent; 33 | double nicePercent; 34 | double systemPercent; 35 | double irqPercent; 36 | double idlePercent; 37 | double systemAllPercent; 38 | double frequency; 39 | uint64_t luser; 40 | uint64_t lkrnl; 41 | uint64_t lintr; 42 | uint64_t lidle; 43 | bool online; 44 | } CPUData; 45 | 46 | typedef struct SolarisMachine_ { 47 | Machine super; 48 | 49 | kstat_ctl_t* kd; 50 | CPUData* cpus; 51 | 52 | int pageSize; 53 | int pageSizeKB; 54 | 55 | ZfsArcStats zfs; 56 | } SolarisMachine; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /solaris/SolarisProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SolarisProcess 2 | #define HEADER_SolarisProcess 3 | /* 4 | htop - SolarisProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | (C) 2017,2018 Guy M. Broome 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | 14 | /* On OmniOS /usr/include/sys/regset.h redefines ERR to 13 - \r, breaking the Enter key. 15 | * Since ncruses macros use the ERR macro, we can not use another name. 16 | */ 17 | #undef ERR 18 | #include 19 | #undef ERR 20 | #define ERR (-1) 21 | 22 | #include "Machine.h" 23 | #include "Process.h" 24 | 25 | 26 | typedef struct SolarisProcess_ { 27 | Process super; 28 | zoneid_t zoneid; 29 | char* zname; 30 | taskid_t taskid; 31 | projid_t projid; 32 | poolid_t poolid; 33 | ctid_t contid; 34 | pid_t realpid; 35 | pid_t realppid; 36 | pid_t realtgid; 37 | pid_t lwpid; 38 | } SolarisProcess; 39 | 40 | extern const ProcessClass SolarisProcess_class; 41 | 42 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 43 | 44 | Process* SolarisProcess_new(const Machine* host); 45 | 46 | void Process_delete(Object* cast); 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /solaris/SolarisProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_SolarisProcessTable 2 | #define HEADER_SolarisProcessTable 3 | /* 4 | htop - SolarisProcessTable.h 5 | (C) 2014 Hisham H. Muhammad 6 | (C) 2017,2018 Guy M. Broome 7 | Released under the GNU GPLv2+, see the COPYING file 8 | in the source distribution for its full text. 9 | */ 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "Hashtable.h" 21 | #include "ProcessTable.h" 22 | #include "UsersTable.h" 23 | 24 | #include "solaris/SolarisProcess.h" 25 | 26 | 27 | typedef struct SolarisProcessTable_ { 28 | ProcessTable super; 29 | } SolarisProcessTable; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /unsupported/ProcessField.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UnsupportedProcessField 2 | #define HEADER_UnsupportedProcessField 3 | /* 4 | htop - unsupported/ProcessField.h 5 | (C) 2020 htop dev team 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | 11 | #define PLATFORM_PROCESS_FIELDS \ 12 | // End of list 13 | 14 | 15 | #endif /* HEADER_UnsupportedProcessField */ 16 | -------------------------------------------------------------------------------- /unsupported/UnsupportedMachine.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - UnsupportedMachine.c 3 | (C) 2014 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "UnsupportedMachine.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "Machine.h" 16 | 17 | 18 | Machine* Machine_new(UsersTable* usersTable, uid_t userId) { 19 | UnsupportedMachine* this = xCalloc(1, sizeof(UnsupportedMachine)); 20 | Machine* super = &this->super; 21 | 22 | Machine_init(super, usersTable, userId); 23 | 24 | super->existingCPUs = 1; 25 | super->activeCPUs = 1; 26 | 27 | return super; 28 | } 29 | 30 | void Machine_delete(Machine* super) { 31 | UnsupportedMachine* this = (UnsupportedMachine*) super; 32 | Machine_done(super); 33 | free(this); 34 | } 35 | 36 | bool Machine_isCPUonline(const Machine* host, unsigned int id) { 37 | assert(id < host->existingCPUs); 38 | 39 | (void) host; (void) id; 40 | 41 | return true; 42 | } 43 | 44 | void Machine_scan(Machine* super) { 45 | super->existingCPUs = 1; 46 | super->activeCPUs = 1; 47 | 48 | super->totalMem = 0; 49 | super->usedMem = 0; 50 | super->buffersMem = 0; 51 | super->cachedMem = 0; 52 | super->sharedMem = 0; 53 | super->availableMem = 0; 54 | 55 | super->totalSwap = 0; 56 | super->usedSwap = 0; 57 | super->cachedSwap = 0; 58 | } 59 | -------------------------------------------------------------------------------- /unsupported/UnsupportedMachine.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UnsupportedMachine 2 | #define HEADER_UnsupportedMachine 3 | /* 4 | htop - UnsupportedMachine.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 | 10 | #include "Machine.h" 11 | 12 | 13 | typedef struct UnsupportedMachine_ { 14 | Machine super; 15 | } UnsupportedMachine; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /unsupported/UnsupportedProcess.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UnsupportedProcess 2 | #define HEADER_UnsupportedProcess 3 | /* 4 | htop - UnsupportedProcess.h 5 | (C) 2015 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "Machine.h" 11 | #include "Process.h" 12 | 13 | 14 | typedef struct UnsupportedProcess_ { 15 | Process super; 16 | 17 | /* Add platform specific fields */ 18 | } UnsupportedProcess; 19 | 20 | 21 | extern const ProcessFieldData Process_fields[LAST_PROCESSFIELD]; 22 | 23 | Process* UnsupportedProcess_new(const Machine* host); 24 | 25 | void Process_delete(Object* cast); 26 | 27 | extern const ProcessClass UnsupportedProcess_class; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /unsupported/UnsupportedProcessTable.c: -------------------------------------------------------------------------------- 1 | /* 2 | htop - UnsupportedProcessTable.c 3 | (C) 2014 Hisham H. Muhammad 4 | Released under the GNU GPLv2+, see the COPYING file 5 | in the source distribution for its full text. 6 | */ 7 | 8 | #include "config.h" // IWYU pragma: keep 9 | 10 | #include "UnsupportedProcessTable.h" 11 | 12 | #include 13 | #include 14 | 15 | #include "ProcessTable.h" 16 | #include "UnsupportedProcess.h" 17 | 18 | 19 | ProcessTable* ProcessTable_new(Machine* host, Hashtable* pidMatchList) { 20 | UnsupportedProcessTable* this = xCalloc(1, sizeof(UnsupportedProcessTable)); 21 | Object_setClass(this, Class(ProcessTable)); 22 | 23 | ProcessTable* super = &this->super; 24 | ProcessTable_init(super, Class(Process), host, pidMatchList); 25 | 26 | return super; 27 | } 28 | 29 | void ProcessTable_delete(Object* cast) { 30 | UnsupportedProcessTable* this = (UnsupportedProcessTable*) cast; 31 | ProcessTable_done(&this->super); 32 | free(this); 33 | } 34 | 35 | void ProcessTable_goThroughEntries(ProcessTable* super) { 36 | bool preExisting = true; 37 | Process* proc; 38 | 39 | proc = ProcessTable_getProcess(super, 1, &preExisting, UnsupportedProcess_new); 40 | 41 | /* Empty values */ 42 | proc->time = proc->time + 10; 43 | Process_setPid(proc, 1); 44 | Process_setParent(proc, 1); 45 | Process_setThreadGroup(proc, 0); 46 | 47 | Process_updateComm(proc, "commof16char"); 48 | Process_updateCmdline(proc, "", 0, 0); 49 | Process_updateExe(proc, "/path/to/executable"); 50 | 51 | const Settings* settings = super->super.host->settings; 52 | if (settings->ss->flags & PROCESS_FLAG_CWD) { 53 | free_and_xStrdup(&proc->procCwd, "/current/working/directory"); 54 | } 55 | 56 | proc->super.updated = true; 57 | 58 | proc->state = RUNNING; 59 | proc->isKernelThread = false; 60 | proc->isUserlandThread = false; 61 | proc->super.show = true; /* Reflected in settings-> "hideXXX" really */ 62 | proc->pgrp = 0; 63 | proc->session = 0; 64 | proc->tty_nr = 0; 65 | proc->tty_name = NULL; 66 | proc->tpgid = 0; 67 | proc->processor = 0; 68 | 69 | proc->percent_cpu = 2.5; 70 | proc->percent_mem = 2.5; 71 | Process_updateCPUFieldWidths(proc->percent_cpu); 72 | 73 | proc->st_uid = 0; 74 | proc->user = "nobody"; /* Update whenever proc->st_uid is changed */ 75 | 76 | proc->priority = 0; 77 | proc->nice = 0; 78 | proc->nlwp = 1; 79 | proc->starttime_ctime = 1433116800; // Jun 01, 2015 80 | Process_fillStarttimeBuffer(proc); 81 | 82 | proc->m_virt = 100; 83 | proc->m_resident = 100; 84 | 85 | proc->minflt = 20; 86 | proc->majflt = 20; 87 | 88 | if (!preExisting) 89 | ProcessTable_add(super, proc); 90 | } 91 | -------------------------------------------------------------------------------- /unsupported/UnsupportedProcessTable.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_UnsupportedProcessTable 2 | #define HEADER_UnsupportedProcessTable 3 | /* 4 | htop - UnsupportedProcessTable.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 | 10 | #include "ProcessTable.h" 11 | 12 | 13 | typedef struct UnsupportedProcessTable_ { 14 | ProcessTable super; 15 | } UnsupportedProcessTable; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /zfs/ZfsArcMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZfsArcMeter 2 | #define HEADER_ZfsArcMeter 3 | /* 4 | htop - ZfsArcMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "zfs/ZfsArcStats.h" 11 | 12 | #include "Meter.h" 13 | 14 | 15 | void ZfsArcMeter_readStats(Meter* this, const ZfsArcStats* stats); 16 | 17 | extern const MeterClass ZfsArcMeter_class; 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /zfs/ZfsArcStats.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZfsArcStats 2 | #define HEADER_ZfsArcStats 3 | /* 4 | htop - ZfsArcStats.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 | 10 | typedef struct ZfsArcStats_ { 11 | int enabled; 12 | int isCompressed; 13 | unsigned long long int min; 14 | unsigned long long int max; 15 | unsigned long long int size; 16 | unsigned long long int MFU; 17 | unsigned long long int MRU; 18 | unsigned long long int anon; 19 | unsigned long long int header; 20 | unsigned long long int other; 21 | unsigned long long int compressed; 22 | unsigned long long int uncompressed; 23 | } ZfsArcStats; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /zfs/ZfsCompressedArcMeter.h: -------------------------------------------------------------------------------- 1 | #ifndef HEADER_ZfsCompressedArcMeter 2 | #define HEADER_ZfsCompressedArcMeter 3 | /* 4 | htop - ZfsCompressedArcMeter.h 5 | (C) 2004-2011 Hisham H. Muhammad 6 | Released under the GNU GPLv2+, see the COPYING file 7 | in the source distribution for its full text. 8 | */ 9 | 10 | #include "zfs/ZfsArcStats.h" 11 | 12 | #include "Meter.h" 13 | 14 | 15 | void ZfsCompressedArcMeter_readStats(Meter* this, const ZfsArcStats* stats); 16 | 17 | extern const MeterClass ZfsCompressedArcMeter_class; 18 | 19 | #endif 20 | --------------------------------------------------------------------------------