tmux
tmux copied to clipboard
Bug: Incorrect RAM values
Describe the bug
The values for RAM and CPU on my don't match with what's displayed the acitivity monitor (Macbook Pro 2015 / macOS Catalina - 10.15.6) and in general just don't feel right.
I mean the RAM always stays under 8GB and rarely gets into something different like 5 or 6 while when I look at my RAM usage from the activity monitor it's never under 13GB.
The CPU usage is usually higher than what's displayed on the activity monitor and often times get above 100% (How?). Showing numbers like 400%-500%... :(
This is what's in my config:
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'dracula/tmux'
set -g @plugin 'nhdaly/tmux-better-mouse-mode'
#set -g @plugin "arcticicestudio/nord-tmux"
# Dracula settings
set -g @dracula-show-weather false
set -g @dracula-show-network false
set -g @dracula-cpu-usage true
set -g @dracula-ram-usage true
set -g @dracula-border-contrast true
set -g @dracula-show-powerline true
set -g @dracula-refresh-rate 1
set -g @dracula-show-timezone false
# Tmux better mouse settings
set -g @scroll-speed-num-lines-per-scroll 1
# Setting the delay between prefix and command
set -s escape-time 5
# Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
# splitting panes with | and -
bind | split-window -h
bind - split-window -v
# Enable mouse
set-option -g mouse on
# Tell Tmux that outside terminal supports true color
set -ga terminal-overrides ",xterm-256color*:Tc"
set -g default-terminal "screen-256color"
set -g default-terminal "tmux-256color"
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
To Reproduce
Steps to reproduce the behavior: Just install this plugin and enable CPU/RAM display
Expected behavior
Correct CPU/RAM display
Screenshots
System
- OS: macOS Catalina - 10.15.6
- Tmux Version: 3.1b (Installed via
brew)
Hmm, okay, couple of thoughts. Firstly, are you totally up to date with the repo?
Full disclaimer, I don't have a MacBook and I'm the one who programmed the Mac part. So I'not very surprised it's not working. When I did it I programmed it on a 5 year old Mac running whatever the OS was from 2015 I borrowed.
Also try setting the refresh rate to something different than 1, that might be messing with it, I dunno.
Also, since you have a Mac and @danerwilliams have a Mac maybe one of you could try and fix it. I do more of the Linux stuff and I'm working on the FreeBSD stuff also, so working on the Mac stuff isn't what I usually do.
Alright, I'll try. If you a know a really good blog post or something related to this I'll be happy to know it btw.
I'll link to the issue, there's a few of resources in there I think. https://github.com/dracula/tmux/issues/36
I do experience a similar mismatch between the actual CPU and RAM usage compared to what the Dracula theme shows in the status bar. It also shows GGB instead of GB. Let me know if I can provide any further hint.
- OS: Linux Mint 19.3 cinnamon desktop
- Tmux Version: 2.6-3ubuntu0.2
- Theme installed via TPM
- Theme and TPM Updated: Yes (Prefix + U, then all)

set-window-option -g mode-keys vi
# Enable full mouse support.
set -g mouse on
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
bind -n S-Left previous-window
bind -n S-Right next-window
unbind r
bind r source-file ~/.tmux.conf \; display "Reloaded tmux conf!"
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Copy buffer to clipboard
set-option -g set-clipboard off
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -sel clip -i"
#List of plugins
# TPM Manager
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Dracula Theme
set -g @plugin 'dracula/tmux'
set -g @dracula-show-fahrenheit false
set -g @dracula-day-month true
set -g @dracula-cpu-usage true
set -g @dracula-ram-usage true
set -g @dracula-show-battery false
set -g @dracula-show-network false
set -g @dracula-show-left-icon session
set -g @dracula-refresh-rate 2
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
Hmm, @Tooa, you're issue with the GGB is a locale thing, I'm working on a fix for that right now. The scripts are wrote for a en_US.UTF-8 locale, but by default they use the system locale and that causes issues in some tools like awk.
For the incorrect values, I'll try and get a fix out soon. Not sure what's up, working on my end. Maybe the locale is causing issues with the accuracy of that too.
@Tooa try it now, just pushed a commit: ca2632845390c2bc40d578d4e94758cc9ce4889e
@ethancedwards8 Looks like the fix from RAM does not work in my case. Here is more information for debugging:
// RAM
$ memory_usage=$(free -g | awk '/^Mem/ {print $3}')
$ echo $memory_usage
2
$ total_mem=$(free -h | awk '/^Mem/ {print $2}')
$ echo $total_mem
7.7G
$ echo $memory_usage\G\B/$total_mem\G\B
2GB/7.7GGB
$ echo $LC_ALL
en_US.UTF-8
// CPU
$ percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/")
$ echo $percent
63.5
$ top -bn1 | grep "Cpu(s)"
%Cpu(s): 29.5 us, 6.7 sy, 0.0 ni, 63.6 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
It appears I'm having the same issue now, actually. But I have GiGB instead of GB. Weird. I'll try some more fixes, I could've sworn this was working correctly a few weeks ago. Maybe It's because I replaced the awk with grep a few commits back..
I see whats up now. Although the CPU one still baffles me, I guess I'll find another way.
I forked this project some while ago and I think I fixed this issue while I was fiddling around with my preferred date format (yyyy-mm-dd). It looks like macOS reports the CPU usage by 100% per one core (6 cores = 600% maximum, hyperthreaded cores seem to count too). The code I ended up with, that had a value that felt right was this:
Darwin)
cpuvalue=$(ps -A -o %cpu | awk -F. '{s+=$1} END {print s}')
cpucores=$(sysctl -n hw.logicalcpu)
cpuusage=$(( cpuvalue / cpucores ))
percent="$cpuusage%"
echo $percent
;;
Okay, I've fixed the CPU usage issue now. https://github.com/dracula/tmux/commit/6757a5329948f00addd66b02ea94f61dd94456f5 the value looked correct to me also, all thats left is the memory issue.
@genesis-algorithms @aschlenker @Tooa @markcornick can everyone test new HEAD and see if they're getting these issues?
@ethancedwards8 Sry it took so long. Let me know if I can provide something else.
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# Hotkey + I
# Changes to .tmux.conf
# Reloaded tmux configuration

# .tmux.conf
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'dracula/tmux'
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
set -g @dracula-show-fahrenheit false
set -g @dracula-refresh-rate 1
set -g @dracula-show-left-icon session
run '~/.tmux/plugins/tpm/tpm'
@Tooa can you try the newest commit?