-
Notifications
You must be signed in to change notification settings - Fork 71
Open
Description
So, after installing the plugin I noticed that my status bar was updated too frequently. Apparently, the presence of tmux-cpu influences the update and status-interval
is ignored.
For example, if I set
tmux set -g status-right "%H:%M:%S"
tmux set -g status-interval 5
I can see the seconds updated every 5 seconds. On the other hand, if I add the tmux_cpu plugin:
tmux set -g status-right "%H:%M:%S #(/path/to/plugin/scripts/cpu_percentage.sh)"
tmux set -g status-interval 5
I will see the seconds and the CPU percentage updated almost every second, disregarding the value of status-interval. I think status-interval should be taken into account, and I see this behaviour as buggy.
I can help with the debug, but not being familiar with tmux-plugins in any way I don't know where to start.
david-polak and lonix1
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ctjhoa commentedon Jan 27, 2017
I'm not sure if this is something related to
tmux-cpu
or if this is something related totpm
ortmux
in general.Have you try the same thing with tmux-plugins/tmux-battery?
ctjhoa commentedon Jan 27, 2017
As you can see get cpu percentage is very slow because you can only get CPU from a time frame of 1 second (thanks to
iostat
). So maybe it have impact on thestatus-interval
ctjhoa commentedon Jan 27, 2017
In theory, it should be something like this:
akiross commentedon Jan 27, 2017
cpu_percentage.sh
is slow here as well because it uses an interval of 1, but it can be omitted:iostat -c
is sufficient to get an immediate CPU usage statistic, instead ofiostat -c 1 2
as it is now in the script.In fact, replacing
iostat -c 1 2
withiostat -c
in thecpu_percentage.sh
, the issue appears to be fixed and start-interval is honoured.With the battery plugin it appears not to have this issue, at least using
battery_remain.sh
... Not knowing how tmux-plugins is implemented, I can't tell, but I think it's something structural causing this issue (i.e. in tpm).EDIT: just to clarify, I'm on linux.
ctjhoa commentedon Jan 27, 2017
From linux
iostat
man page:so I cannot use the first report
ctjhoa commentedon Jan 27, 2017
Same from BSD
iostat
man page:akiross commentedon Jan 27, 2017
Right... So, another way has to be found :)
ncdc commentedon Sep 15, 2017
FYI with the iostat in
sysstat-11.5.4-2.fc26.x86_64
, you can doiostat -c -y 1 1
to get the current cpu utilization. The docs for-y
:Omit first report with statistics since system boot, if displaying multiple records at given interval.
. I also had to change it totail -n 3
instead of 2, FWIW.BrainMaestro commentedon Aug 6, 2018
I have this issue as well, and I think it's related to tmux/tmux#797 (comment). Maybe, as a way to fix this, the
status-interval
is checked, and if that number of seconds since the last time have not passed, just return the last value to avoid a redraw. Not the nicest solution since we have to keep track of two variables between draws, but it should worktmux: kludge a fix to erroneous cpu numbers in statusbar
lonix1 commentedon Oct 8, 2019
Is this still an issue in the latest bits, and what is the current recommended workaround (OP was a few years ago).
ctjhoa commentedon Oct 8, 2019
@lonix1 iostat versions are very different across OSes and even depending on the version used. If you really care about the update frequency of your status bar, an alternative could be to add an option to customize the command used to compute CPU.
lonix1 commentedon Oct 8, 2019
@ctjhoa Since you know much more about this than I do, what approach do you take/recommend? (I'm on latest ubuntu BTW).
ctjhoa commentedon Oct 11, 2019
@lonix1 What I mean is, if we cannot guess what
iostat
version is used and there is a faster way to compute cpu percentage, we could let the user specify the command specific to his system through a tmux-cpu option.Using
eval
or such should be straightforward but I have doubt that a faster command exist for the majority of OSes.add cached eval
add cached eval
[-]Update frequency too high (and status-interval not respected)[/-][+]status-interval not respected[/+]casperdcl commentedon Jul 9, 2020
Is this still an issue? To be clear, this should not be the case:
Seems like it was an upstream bug but isn't a thing any more? My local tests show
status-interval
is loosely respected even with justtmux set -g status-right "%H:%M:%S"
.add cached eval
casperdcl commentedon Jul 9, 2020
While testing this, I think I've found an upstream problem (with
tmux
ortpm
). Basicallywill ignore
status-interval
and result in one update per second (!)ofdeath commentedon Jul 19, 2020
I have another solution. I know this is ugly because
But it's faster than running the iostat command directly and it can get the cpu percentage with longer interval (ex: 5s)
Anyway you can consider to add this optional method if you want :)
my cronjob
* * * * * root mkdir -p /dev/shm/tmux-cpu && mpstat 1 59 > /dev/shm/tmux-cpu/mpstat
my tmux.conf
set -g @cpu-stat-file '/dev/shm/tmux-cpu/mpstat'
modified cpu_percentage.sh
cpu_percentage.sh.txt
Cache results to prevent miscalculations