Giter VIP home page Giter VIP logo

tmux-mem-cpu-load's Introduction

tmux-mem-cpu-load

CPU, RAM, and load monitor for use with tmux

https://circleci.com/gh/thewtex/tmux-mem-cpu-load.svg?style=svg

Description

A simple, lightweight program provided for system monitoring in the status line of tmux.

The memory monitor displays the used and available memory.

The CPU usage monitor outputs a percent CPU usage over all processors. It also displays a textual bar graph of the current percent usage.

The system load average is also displayed.

Example output:

2885/7987MB [|||||     ]  51.2% 2.11 2.35 2.44

 ^    ^          ^         ^     ^    ^    ^
 |    |          |         |     |    |    |
 1    2          3         4     5    6    7
  1. Currently used memory.
  2. Available memory.
  3. CPU usage bar graph.
  4. CPU usage percentage.
  5. Load average for the past minute.
  6. Load average for the past 5 minutes.
  7. Load average for the past 15 minutes.

For terminals with 256 color support, graded colors can be displayed by passing the --colors flag.

Installation

Dependencies

Currently, Linux, Mac OSX, FreeBSD, OpenBSD, and NetBSD are supported.

Building

  • >= CMake -3.5
  • C++ compiler with C++11 support (e.g. gcc/g++ >= 4.6)

Download

There are links to the source code at the project homepage.

Build

cd <source dir>
cmake .
make

Install

su -
make install
logout

Build and Install Using tpm

Include the plugin in your .tmux.conf, the same file you'll set the configuration in, below.

set -g @plugin 'thewtex/tmux-mem-cpu-load'

Install with Package Managers

  • Gentoo: emerge tmux-mem-cpu-load
  • Homebrew: brew install tmux-mem-cpu-load

Build and Install Using Antigen

Include the bundle in your .zshrc

antigen bundle thewtex/tmux-mem-cpu-load

Configuring tmux

Edit $HOME/.tmux.conf to display the program's output in status-left or status-right. For example:

set -g status-interval 2
set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2)#[default]"
set -g status-left-length 60

If you installed using tpm, you must specify the full path to the tmux-mem-cpu-load script, like below:

set -g status-right '#[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2)#[default]'

Note that the interval argument to tmux-mem-cpu-load should be the same number of seconds that status-interval is set at.

Another optional argument is the number of bars in the bar graph, which defaults to 10. This can, for instance, be set to the number of cores in a multi-core system.

The colors option will add graded colors for each of the measures.

The full usage:

Usage: tmux-mem-cpu-load [OPTIONS]

Available options:
-h, --help
         Prints this help message
-c, --colors
        Use tmux colors in output
-p, --powerline-left
        Use powerline left symbols throughout the output, enables --colors
-q, --powerline-right
        Use powerline right symbols throughout the output, enables --colors
-v, --vertical-graph
        Use vertical bar chart for CPU graph
-l <value>, --segments-left <value>
        Enable blending bg/fg color (depending on -p or -q use) with segment to left
        Provide color to be used depending on -p or -q option for seamless segment blending
        Color is an integer value which uses the standard tmux color palette values
-r <value>, --segments-right <value>
        Enable blending bg/fg color (depending on -p or -q use) with segment to right
        Provide color to be used depending on -p or -q option for seamless segment blending
        Color is an integer value which uses the standard tmux color palette values
-i <value>, --interval <value>
        Set tmux status refresh interval in seconds. Default: 1 second
-g <value>, --graph-lines <value>
        Set how many lines should be drawn in a graph. Default: 10
-m <value>, --mem-mode <value>
      Set memory display mode. 0: Default, 1: Free memory, 2: Usage percent.
-t <value>, --cpu-mode <value>
      Set cpu % display mode. 0: Default max 100%, 1: Max 100% * number of threads.
-a <value>, --averages-count <value>
      Set how many load-averages should be drawn. Default: 3

Blending Dynamic Colors Tmux Powerline Segments

The -l and -r options when used in conjunction with a recent version of Tmux Powerline that has the ability to selectively disable spacing and separators between segments allow for seamless blending of tmux-mem-cpu-load output with other adjacent segments. The end result is dynamic changing of appropriate foreground and background colors as the start and end of the tmux-mem-cpu-load output string that is aggregated with other Tmux Powerline output to produce a more polished status line in Tmux.

Segment Adjaceny before this feature:

seg-adj1.png

Segment Adjaceny after this feature:

seg-adj2.png

Note that the values for the -l and -r options will be the standard Tmux integer color values. They set the appropriate background and foreground colors used for the separator character when used with the poweline-left or powerline-right options so it is easy to match coloring to adjacent segments. An example from the segment script that calls tmux-mem-cpu-load is as follows:

tmux-mem-cpu-load -q -v -l 52 -r 33

This combines with theme options available to tmux-powerline, such as the following:

"disk_usage_cust 52 123 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 52 123 right_disable" \
"tmux_mem_cpu_load_cust 52 234 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 52 234 both_disable separator_disable" \
"batt_cust 33 154 ${TMUX_POWERLINE_SEPARATOR_LEFT_BOLD} 16 33 N separator_disable" \

Authors

Matt McCormick (thewtex) <[email protected]>

Contributions from:

tmux-mem-cpu-load's People

Contributors

0-wiz-0 avatar allcatsarebeautiful avatar assistcontrol avatar bensuperpc avatar blackheaven avatar compilenix avatar cousine avatar dependabot[bot] avatar fluffykhv avatar golinski avatar jameshanlon avatar jasperla avatar jmmweismiller avatar jodavies avatar kil9 avatar l0ner avatar milesfrain avatar mlp6 avatar ngocphamm avatar nhdaly avatar perfectra1n avatar peterdavehello avatar qqshfox avatar rnagy avatar thesamesam avatar thewtex avatar tony avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmux-mem-cpu-load's Issues

Not working on OS X 10.8

There is no complaint from cmake or make about abi, but when I try to run it, there seems to be an exception related to abi.

ยง cmake .
-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is Clang 4.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/willkd9/dev/git/tmux-mem-cpu-load

ยง make
Scanning dependencies of target tmux-mem-cpu-load
[100%] Building CXX object CMakeFiles/tmux-mem-cpu-load.dir/tmux-mem-cpu-load.cpp.o
Linking CXX executable tmux-mem-cpu-load
[100%] Built target tmux-mem-cpu-load

ยง ./tmux-mem-cpu-load
libc++abi.dylib: terminate called throwing an exception
0/0MB zsh: abort      ./tmux-mem-cpu-load

README update - add parameter for status-left-length

Since the default status-left-length setting for tmux is 10 the supplied initial parameters in the README will cause tmux to partially show the memory metrics and nothing else. It would make life easier for tmux n00b's trying out this project if the sample config lines included setting status-left-length to something large enough to display the full script output. Since this is a max value setting and not a static setting, using a large value should be safe:

set -g status-interval 2
set -g status-left "#S #[fg=green,bg=black]#(tmux-mem-cpu-load --colors --interval 2)#[default]"
set -g status-left-length 60

Significant discrepancies between reported and actual memory usage

tmux-mem-cpu-load seems to consistently under-report my memory usage. As an extreme example, I've attached a screenshot of my memory usages as reported by OS X's Activity Monitor alongside tmux-mem-cpu-load's reported usage; you'll notice that OS X reports that I'm usually almost all my physical memory (and aggressively swapping almost 12 GB) while tmux-mem-cpu-load reports that I'm using only 1.4 GB.

I can confirm that when taking this screenshot my system was very sluggish, which leads me to believe OS X's reporting is the correct one.

As a side note, I also noticed that the CPU load averages are incorrect. My system load before and after this screenshot was consistently in the 30โ€“50% for about an hour (the instantaneous screenshot here doesn't show it), but the running averages never moved past 2.xx%.

I'm running OS X El Capitan 10.11.5 on a MacBook Air with 4 GB physical memory.

tmux-cpu-mem inconsistency

Not showing at first config load

Hi,

installed with tpm, so I used the example found in the installation guide:

set -g status-right "#[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2)#[default]"

It works, but only if I reload tmux configuration. So at first tmux startup, it doesn't show anything. Other plugin works.

I compared with a friend's tmux configuration and he is using the same tmux command, but with single quote. I tried and it works instantly.
To be clear, above example, rewritten with single quote (see below), works without reloading tmux configuration:

set -g status-right '#[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2)#[default]'

How it's possible?

tmux version: 2.6

SIGABRT

Hey,

When i have this program on, it gets randomly aborted, looks random for something triggered every 2 seconds and i haven't been able to reproduce it beside letting it run and it'll happen, it's quite frequent tho it'll generate a bunch of coredumps every day:
2021-04-22 12_40_53-~
The backtrace is not useful at all
2021-04-22 12_47_27-~
and would point towards bad memory access or smth like that.

Idk if anyone is able to reproduce, i noticed it because it slowed down that computer while handling the coredump, but this is happening on a RPI Model B Plus Rev 1.2, running archarm.
Here is the full journal output from journalctl MESSAGE_ID=fc2e22bc6ee647b6b90729ab34a250b1 -o verbose : http://ix.io/2WWM

At least i know i can reproduce it but the fact that it's started every 2 seconds makes it hard to attack strace or smth, anyway, i'll make a debug build and update this when i get some time.

Have a good day!

"-m 0" output is printing used memory twice

Appears to have been introduced in commit 42275e0. Observed behavior on a Linux system:

% cat /proc/meminfo
MemTotal:        2052448 kB
MemFree:         1617816 kB
MemAvailable:    1902188 kB
Buffers:          136800 kB
Cached:           147920 kB
% tmux-mem-cpu-load
146/146MB [          ]  1.5% 0 0.01 0.05

The following change to common/memory.cc should fix this:

@@ -65,7 +65,7 @@
     }
   default: // Default mode, just show the used/total memory in MB
     oss << static_cast< unsigned int >( mem_status.used_mem ) << '/'
-      << static_cast< unsigned int >( mem_status.used_mem ) << "MB";
+      << static_cast< unsigned int >( mem_status.total_mem ) << "MB";
   }

   if( use_colors )

Doesn't work on OS X 10.6

$ tmux-mem-cpu-load 2
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr
Abort trap

Fixed decimal points

The UI can be quite jumpy at times, it would be great if there was an option to make cpu percentage and load numbers having a fixed amount of decimal points.

Expected:

| 20.0% 1.20 1.01 1.00 |

Or alternatively pad the output with whitespaces.

| 20%   1.2  1.01 1    |

Actual:

| 20% 1.2 1.01 1 |

tpm returns 1

anyone else have the problem of tpm returning 1?
It has no errors if I comment out 'thewtex/tmux-mem-cpu-load'

any help would be appreciated... thanks

edit - sorry didn't have cmake installed

Provide usage metric variables individually

Other tmux status-line plugins provide variables that can be accessed individually, e.g.

set -g @plugin 'tmux-plugins/tmux-cpu'

provides access to

set -g status-right '#{cpu_bg_color} CPU: #{cpu_icon} #{cpu_percentage}'

I really like what tmux-mem-cpu-load provides, but I don't want to always use the entire string,

2885/7987MB [ | | | | |     ]  51.2% 2.11 2.35 2.44

all the time.

Partitioning the output into individual variables would vastly improve the ability to integrate the plugin into custom status lines, and eliminate bloat and overcrowding, particularly on small laptop screens, or when using a large font.

Provide argument flag to disable coloration based on usage

I've just managed to get your cool plugin working with tpm, many thanks! I'm just wondering if there is an existing argument to disable the coloration of the CPU usage bar graph (and maybe other UI elements) based on usage? I didn't find such an argument in the man page but it would be nice to have.

Cannot build on Ubuntu 20

Hello. Getting this when trying to build the plugin manually. cmake . works, but then:

$ make &> out ; head out
[ 12%] Linking CXX executable tmux-mem-cpu-load
/usr/bin/ld: CMakeFiles/tmux-mem-cpu-load.dir/common/main.cc.o: in function `cpu_string[abi:cxx11](CPU_MODE, unsigned int, unsigned int, bool, bool, bool)':main.cc:(.text+0x70): undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()'
/usr/bin/ld: main.cc:(.text+0x217): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: main.cc:(.text+0x256): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: main.cc:(.text+0x265): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/usr/bin/ld: main.cc:(.text+0x27b): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/usr/bin/ld: main.cc:(.text+0x2e0): undefined reference to `std::basic_ios<char, std::char_traits<char> >::fill(char)'
/usr/bin/ld: main.cc:(.text+0x2f6): undefined reference to `std::ostream::operator<<(std::ios_base& (*)(std::ios_base&))'
$ gcc -v                                     
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

tpm vs antigen

Hi! I'm just wondering, since this is at its heart a tmux feature, why do you suggest users install it with antigen?

Could it be installed through tmux-plugins/tpm? I guess it might have something to do with the compiled aspect of it, but you could probably get that to work through tpm too?

------- EDIT ------
Well, not really an edit, since I haven't submitted yet, but I spent about 20-30 min trying to set this up, and I see one issue that might've prevented you from doing it this way in the first place: as far as I can tell, through a tmux plugin you cannot get the user to type a password to authenticate make install... That might mean it's not gonna work for a tmux plugin.

disable date and time

Hello,

Is it possible for this plugin to be disabled date and time in status bar?

constant segfaults

Hi,

I installed (2.2.1) on gentoo/amd64 and once setup in my .tmux.conf I started getting constant segfaults.

tmux-mem-cpu-lo[21267]: segfault at 410088 ip 00007ffa50471d6a sp 00007fff3a6626c8 error 4 in libc-2.19.so[7ffa503ed000+199000]

git repo status?

Any interest in possibly adding git repository status, like active branch, similar to what vim-fugitive does for vim? I'm happy to help w/ this if there is more than my personal interest, but my C++ coding leaves a little to be desired relative to C or Python.

Applying --color shows `fg=black` instead of the color

When I apply --colors I cannot see colors instead I see their ascii tag code. How can I fix this?

$ ./tmux-mem-cpu-load --colors
#[fg=black,bg=colour144]619/976MB#[fg=default,bg=default]#[fg=brightwhite,bg=colour16] [          ]  5.1%#[fg=default,bg=default]#[fg=brightwhite,bg=colour16] 0.14 0.21 0.33#[fg=default,bg=default]

Option `--averages-count 0` breaks any trailing output

System/version information:

[ehildenb@ehildenb-ubuntu tmux-mem-cpu-load]% uname -a
Linux ehildenb-ubuntu 4.15.0-38-generic #41-Ubuntu SMP Wed Oct 10 10:59:38 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[ehildenb@ehildenb-ubuntu tmux-mem-cpu-load]% git rev-parse HEAD
2fdcf932967c33aa30ea4708d472356120533bcd

If I use --averages-cont 1, the output I get for my status bar is:

Sat, 08 Dec 2018 - 18:35  | Net: tenzor - 10.0.0.141  | Temps: max: 46 avg: 38.7  | Load: 5101/7759MB [          ]  5.2% 0.63  | Uptime:  1d 4h 24m

If I use --averages-count 0, the output I get for my status bar is:

 Sat, 08 Dec 2018 - 18:36  | Net: tenzor - 10.0.0.141  | Temps: max: 46 avg: 38.9  | Load: 5117/7759MB [          ]  3.1%

Notice how everything after the tmux-mem-cpu-load is consumed (in this case my uptime information). I build the overall status using:

        output=""
        output="$output $(get_date)$separator"
        output="$output Net: $(net print | head -c10) - $(net list)$separator"
        output="$output Temps: $(hw temp | tr -d '\n')$separator"
        output="$output Load: $(tmux-mem-cpu-load --averages-count 0)$separator"
        output="$output Uptime: $(get_uptime)"

My tmux status bar has enough characters to render the total output when I do --averages-count 1, so I don't think it's that.

Doesn't build on RPI2 FreeBSD, patch provided

Had to apply this patch to avoid this error:

[ 12%] Building CXX object CMakeFiles/tmux-mem-cpu-load.dir/freebsd/cpu.cc.o
/home/dmilith/tmux-mem-cpu-load/freebsd/cpu.cc:29:9: error: functions that differ only in their return type cannot be overloaded
int32_t get_cpu_count()
~~~~~~~ ^
/home/dmilith/tmux-mem-cpu-load/common/cpu.h:48:10: note: previous declaration is here
uint32_t get_cpu_count();
~~~~~~~~ ^
1 error generated.

Patch:

diff --git a/freebsd/cpu.cc b/freebsd/cpu.cc
index b85d402..4c7dddb 100644
--- a/freebsd/cpu.cc
+++ b/freebsd/cpu.cc
@@ -26,12 +26,12 @@
 #include "getsysctl.h"
 #include "cpu.h"

-uint8_t get_cpu_count()
+uint32_t get_cpu_count()
 {
   int32_t cpu_count = 0;
   GETSYSCTL( "hw.ncpu", cpu_count );

-  return static_cast<uint8_t>( cpu_count );
+  return static_cast<uint32_t>( cpu_count );
 }

 float cpu_percentage( unsigned int cpu_usage_delay )

Mac OSX: Every time I open a new window, it reinstalls tmux-mem-cpu-load

This has frustrated me for a while, but I finally know what's happening.

When I open a new window, it rebuilds and attempts to install the binary to my machine:

~/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-thewtex-SLASH-tmux-mem-cpu-load.git ~/dotfiles/nhdaly
-- Darwin detected
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/nhdaly/.antigen/repos/https-COLON--SLASH--SLASH-github.com-SLASH-thewtex-SLASH-tmux-mem-cpu-load.git
[100%] Built target tmux-mem-cpu-load
Password:
[100%] Built target tmux-mem-cpu-load
Install the project...
-- Install configuration: "MinSizeRel"
-- Installing: /Users/nhdaly/homebrew/bin/tmux-mem-cpu-load
~/dotfiles/nhdaly
๐Ÿฐ 22:27:35 ๎‚ฐ ~/dotfiles/nhdaly ๎‚ฐ ๎‚  master โœ˜ โœน โœญ ๎‚ฐ

BUT, as you can see, I've realized it's putting it in /Users/nhdaly/homebrew/bin/tmux-mem-cpu-load for some magical reason. I assume this must be because I've installed homebrew to that directory, and it's probably finding the version of cmake installed by homebrew?

So ANYWAY, after it's installed, the tmux-mem-cpu-load.plugin.zsh script checks (on this line) whether it's installed at /usr/local/bin/tmux-mem-cpu-load, which of course it isn't.

Can that line somehow inherit the same magic as cmake to figure out where to check for it? Thanks!

Option to include Cached memory in output

My tmuxstatus line says I am only using 16GBof my 32GB available ram. But my machine is really sluggish, and looking at the output of free -m, you can see this just isn't true:

$ free -m
             total       used       free     shared    buffers     cached
Mem:         32100      28415       3684         32        151      11381
-/+ buffers/cache:      16882      15217
Swap:        32695        289      32406

This is because the Cache is actually taking up a lot of memory:

$ cat /proc/meminfo
MemTotal:       32870884 kB
MemFree:         3102568 kB
Buffers:          152772 kB
Cached:         11650120 kB
SwapCached:        64272 kB
Active:         19052916 kB
Inactive:        8415600 kB
...

Can there be an option to use the total memory usage which includes the Cache, so I can get a better idea for why my computer is slow? Thanks.

Build error on FreeBSD

On FreeBSD 13.0, using the default llvm 11.0.1, version 3.5.0 gives the following error:

/wrkdirs/usr/ports/sysutils/tmux-mem-cpu-load/work/tmux-mem-cpu-load-3.5.0/freebsd/cpu.cc:29:9: error: functions that differ only in their return type cannot be overloaded
uint8_t get_cpu_count()
~~~~~~~ ^
/wrkdirs/usr/ports/sysutils/tmux-mem-cpu-load/work/tmux-mem-cpu-load-3.5.0/common/cpu.h:48:10: note: previous declaration is here
uint32_t get_cpu_count();
~~~~~~~~ ^
1 error generated.

Memory and CPU run together with -g 0

When the graph is disabled with -g 0, the memory and CPU displays run together when CPU is 100%:

15/12GB100%

When the CPU graph is disabled, perhaps it should be replaced by a single space?

Plugin tries to install to elevated directory

Added plugin directive to tmux.conf and on the build / install the plugin is trying to install into privileged directory.

Here is what the output is of the build when I run it manually.
image

Here is what the output is when I start tmux
image

Can I somehow adjust the colors?

Plainly, the colors are illegible, in particular for the memory usage:
decohost_2022-12-14T03:19:35

I know they can be disabled, but they're actually super-useful, just that they also prevent me from reading the text after I have been alerted to the fact that things are happening.

Would it be possible to customize them somehow?
I know too many config options actually make things more confusing but the alternative as it stands is having dark green (? can't even tell) on dark blue.

Inverse coloring issue

I'm observing inverse coloring in the output on the latest macos Sierra. That is, for a list of 101 colors and produced color x, I am getting instead 101 - x. Here's an example:

#[bg=default] #[fg=colour144]๎‚ฒ#[fg=black,bg=colour144] 9713/16384MB #[fg=colour52]๎‚ฒ#[fg=brightwhite,bg=colour52] [          ]  3.3% #[fg=colour16]๎‚ฒ#[fg=brightwhite,bg=colour16] 1.4 1.49 1.56

The CPU utilization is only 3.3%, but the display is bright white on red. I confirmed this intuition with this hack:

diff --git a/common/main.cc b/common/main.cc
index 2b237d8..9424a23 100644
--- a/common/main.cc
+++ b/common/main.cc
@@ -63,7 +63,7 @@ std::string cpu_string( CPU_MODE cpu_mode, unsigned int cpu_us
     oss.precision( 0 );
   }
 
-  unsigned int percent = static_cast<unsigned int>( percentage );
+  unsigned int percent = 101 - static_cast<unsigned int>( percentage );
   if( use_colors )
   {
     if( use_powerline_right )

After using this patch, the colors appear correct for CPU, but still not for memory and load averages. So this color inversion applies to all measurements. The percentage value is actually correct, but somehow the translation into colors is not working properly. Any ideas what's causing this?

Issues building on OpenBSD: `uint8_t get_cpu_count`

Thought I installed it correctly with tpm, but it never showed on the status line. Then went back and performed a standard build to make sure the package was installed.

cd /path/to/tmux-mem-cpu-load
cmake .
make 

This execution resulted in the below error. I swapped over from using make to gnu-make, and the result was relatively the same.

[ 12%] Building CXX object CMakeFiles/tmux-mem-cpu-load.dir/openbsd/cpu.cc.o
/home/user/.tmux/plugins/tmux-mem-cpu-load/openbsd/cpu.cc:27:9: error: functions that differ only in their return type cannot be overloaded
uint8_t get_cpu_count()
~~~~~~~ ^
/home/user/.tmux/plugins/tmux-mem-cpu-load/common/cpu.h:48:10: note: previous declaration is here
uint32_t get_cpu_count();
~~~~~~~~ ^
1 error generated.
*** Error 1 in . (CMakeFiles/tmux-mem-cpu-load.dir/build.make:146 'CMakeFiles/tmux-mem-cpu-load.dir/openbsd/cpu.cc.o': /usr/bin/c++  -I/home...)
*** Error 2 in . (CMakeFiles/Makefile2:111 'CMakeFiles/tmux-mem-cpu-load.dir/all': make -s -f CMakeFiles/tmux-mem-cpu-load.dir/build.make CM...)
*** Error 2 in /home/user/.tmux/plugins/tmux-mem-cpu-load (Makefile:146 'all': make -s -f CMakeFiles/Makefile2 all)

Would be nice if this could somehow build successfully. Although, I am completely clueless to what the issue could be.

--colors broken on OpenBSD

When running the tests for an upcoming OpenBSD port I noticed that the --colors test fails:

===>  Regression tests for tmux-mem-cpu-load-3.2.0
[1/1] cd /usr/obj/ports/tmux-mem-cpu-load-3.2.0/build-amd64 && /usr/local/bin/ctest --force-new-ctest-process
Test project /usr/obj/ports/tmux-mem-cpu-load-3.2.0/build-amd64
    Start 1: usage
1/8 Test #1: usage ............................   Passed    0.00 sec
    Start 2: no_arguments
2/8 Test #2: no_arguments .....................   Passed    1.00 sec
    Start 3: custom_interval
3/8 Test #3: custom_interval ..................   Passed    3.00 sec
    Start 4: no_cpu_graph
4/8 Test #4: no_cpu_graph .....................   Passed    1.00 sec
    Start 5: colors
5/8 Test #5: colors ...........................***Exception: SegFault  0.01 sec
    Start 6: invalid_status_interval
6/8 Test #6: invalid_status_interval ..........   Passed    0.00 sec
    Start 7: invalid_graph_lines
7/8 Test #7: invalid_graph_lines ..............   Passed    0.00 sec
    Start 8: old_option_specification
8/8 Test #8: old_option_specification .........   Passed    0.00 sec

88% tests passed, 1 tests failed out of 8

Total Test time (real) =   5.03 sec

The following tests FAILED:
          5 - colors (SEGFAULT)
Errors while running CTest

Backtrace:

(gdb) bt
#0  strlen () at /usr/src/lib/libc/arch/amd64/string/strlen.S:124
#1  0x00000ab7751abdb1 in operator<< <std::char_traits<char> > (__out=@0x7f7fffff9bd8, 
    __s=0xab545001620 <Address 0xab545001620 out of bounds>) at char_traits.h:258
#2  0x00000ab544f02a74 in mem_string (use_colors=true) at memory.cc:106
#3  0x00000ab544f0226b in main (argc=2, argv=0x7f7fffff9e68) at main.cc:157
Current language:  auto; currently asm
(gdb) bt full
#0  strlen () at /usr/src/lib/libc/arch/amd64/string/strlen.S:124
No locals.
#1  0x00000ab7751abdb1 in operator<< <std::char_traits<char> > (__out=@0x7f7fffff9bd8, 
    __s=0xab545001620 <Address 0xab545001620 out of bounds>) at char_traits.h:258
No locals.
#2  0x00000ab544f02a74 in mem_string (use_colors=true) at memory.cc:106
        hw_pagesize = {6, 7}
        vm_totalmem = {2, 1}
        vm_bcstats = {10, 0, 3}
        oss = <incomplete type>
        total_mem = -409329664
        used_mem = 1488257024
        free_mem = -1897586688
        size = 120
        page_size = 1
        vm_total = {t_rq = 1, t_dw = 7, t_pw = 0, t_sl = 63, t_sw = 0, t_vm = 468078, t_avm = 268424, 
  t_rm = 468078, t_arm = 268424, t_vmshr = 0, t_avmshr = 0, t_rmshr = 0, t_armshr = 0, t_free = 480564}
        bcstats = {numbufs = 26146, numbufpages = 104734, numdirtypages = 736, numcleanpages = 103998, 
  pendingwrites = 0, pendingreads = 0, numwrites = 38431, numreads = 29518, cachehits = 451144, busymapped = 0, 
  dmapages = 0, highpages = 0, delwribufs = 184, kvaslots = 6553, kvaslots_avail = 6553}
#3  0x00000ab544f0226b in main (argc=2, argv=0x7f7fffff9e68) at main.cc:157
        long_options = {{name = 0xab5450041d0 "help", has_arg = 0, flag = 0x0, val = 104}, {
    name = 0xab5450041d5 "colors", has_arg = 0, flag = 0x0, val = 99}, {name = 0xab5450041dc "interval", 
    has_arg = 1, flag = 0x0, val = 105}, {name = 0xab5450041e5 "graph-lines", has_arg = 1, flag = 0x0, 
    val = 103}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}
        cpu_usage_delay = 990000
        graph_lines = 10
        use_colors = true
        c = -1
(gdb) 

This happens both with and without MALLOC_OPTIONS set to S. Note that even when run without --colors the memory reporting is odd:

1421/-390MB [ ]

Linux memory information parsing hits out of range for a large memory machine

Hitting the issue with a print of the value that is out of range:

$ ./tmux-mem-cpu-load
> 2377804304
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi
Aborted

Machine configuration:

$ cat /proc/version
Linux version 6.1.0-18-amd64 ([email protected]) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01)

This particular machine has ~2TB RAM.

Suggested fix:

diff --git a/linux/memory.cc b/linux/memory.cc
index 4bcc295..136afca 100644
--- a/linux/memory.cc
+++ b/linux/memory.cc
@@ -19,6 +19,7 @@
 #include <sstream>
 #include <fstream>
 #include <sys/sysinfo.h>

 #include "memory.h"
 #include "conversions.h"
@@ -66,21 +67,21 @@ void mem_status( MemoryStatus & status )
     if( substr.compare( "MemTotal" ) == 0 )
     {
       // get total memory
-      total_mem = stoi( line.substr( substr_start, substr_len ) );
+      total_mem = stol( line.substr( substr_start, substr_len ) );
     }
     else if( substr.compare( "MemFree" ) == 0 )
     {
-      used_mem = total_mem - stoi( line.substr( substr_start, substr_len ) );
+      used_mem = total_mem - stol( line.substr( substr_start, substr_len ) );
     }
     else if( substr.compare( "Shmem" ) == 0 )
     {
-      used_mem += stoi( line.substr( substr_start, substr_len ) );
+      used_mem += stol( line.substr( substr_start, substr_len ) );
     }
     else if( substr.compare( "Buffers" ) == 0 ||
              substr.compare( "Cached" ) == 0  ||
              substr.compare( "SReclaimable" ) == 0 )
     {
-      used_mem -= stoi( line.substr( substr_start, substr_len ) );
+      used_mem -= stol( line.substr( substr_start, substr_len ) );
     }
   }

tpm vs antigen

Hi! I'm just wondering, since this is at its heart a tmux feature, why do you suggest users install it with antigen?

Could it be installed through tmux-plugins/tpm? I guess it might have something to do with the complied aspect of it, but you could probably get that to work through tpm too.

I ask because it seems like it's not related to zsh at all, and shouldn't need zsh as a dependency. Is that true? :)

incorrect used memory in status line

Running Fedora 20 on 2 machines, and one just started reporting the used memory incorrectly. Looking at /proc/meminfo, it appears that some of the entries have changed:

One working machine, the first 4 lines:

MemTotal:       16389008 kB
MemFree:         5842704 kB
Buffers:         1348264 kB
Cached:          5477328 kB

Yielding a realistic memory usage line: 3634/16004MB

One the incorrect machine, the first 5 lines:

MemTotal:       16124136 kB
MemFree:         7372360 kB
MemAvailable:   10398964 kB
Buffers:          592928 kB
Cached:          2482160 kB

Yielding this spurious memory usage line: 4192564/15746MB

It appears that MemAvailable is now present, fouling up the calculation of used memory, which appears to currently be done by summing up the 3 lines after MemTotal. Not sure why two machines running identical kernels on Fedora20 are suddenly yielding different results here, but I will try to work on a Pull Request to make this immune to the different entries that may be present in /proc/meminfo.

empty cpu usage bar graph

I just installed tmux-mem-cpu-load on Ubuntu lucid. I'm using tmux1.5 on iterm 0.10 (sshing into Ubuntu from my Mac)

The CPU usage bar graph shows up empty for me and I also see a number 0 to the left of my memory usage. Any idea what this might be due to ?
screen shot 2014-03-19 at 5 07 26 pm

Wont load, installed using tpm

Hello,

Im sure im mising something simple here, but im just not seeing it.
Installed tpm using the tpm install instructions.
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

After prefix + I the folder tmux-mem-cpu-load is created in ~/.tmux/plugins/

even after prefix + r it does not load.

Reading "If you installed using tpm, you must specify the full path to the tmux-mem-cpu-load script, like below:" there is no script called "tmux-mem-cpu-load" in that folder,

image

prefix + r
image

# Appearance customization
#set -g status-bg black
#set -g status-fg white
set -g window-status-current-fg red
set -g pane-active-border-fg red
set -g clock-mode-colour red

# Custom modifier key
set -g prefix C-Space
unbind-key C-b
bind-key C-Space send-prefix

# Terminal improvements
set -g terminal-overrides "xterm*:XT:smcup@:rmcup@"
set-window-option -g automatic-rename off
set-option -g set-titles on
set -g mouse on
set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000

# Clear scrollback buffer
bind l clear-history

# Custom key bindings to split the window
bind-key v split-window -h
bind-key s split-window -v

# Reload tmux config
bind r source-file ~/.tmux.conf

# No delay for escape key press
set -sg escape-time 0

# Shift arrow to switch panes
bind -n S-Left  select-pane -L
bind -n S-Right select-pane -R
bind -n S-Up    select-pane -U
bind -n S-Down  select-pane -D

# Control arrow to create panes
bind -n C-Down  split-window -v
bind -n C-Up    split-window -v -b
bind -n C-Right split-window -h
bind -n C-Left  split-window -h -b

# Easier window navigation
bind -n C-Tab     next-window
bind -n C-S-Tab   previous-window
bind -n C-S-Left  previous-window
bind -n C-S-Right next-window

# Ctrl + Alt + Left/Right to move windows
bind-key -n C-M-Left swap-window -t -1
bind-key -n C-M-Right swap-window -t +1

# Copy to cygwin clipboard
bind -n C-t run "tmux save-buffer - > /dev/clipboard"

# Kill tabs quicker
bind-key x kill-pane

set -g terminal-overrides "xterm*:kLFT5=\eOD:kRIT5=\eOC:kUP5=\eOA:kDN5=\eOB:smkx@:rmkx@"

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'thewtex/tmux-mem-cpu-load'


set -g status-interval 2
set -g status-right '#[fg=green]#($TMUX_PLUGIN_MANAGER_PATH/tmux-mem-cpu-load/tmux-mem-cpu-load --colors --powerline-right --interval 2)#[default]'
set -g status-right-length 60

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

Error on OpenBSD 6.4

Doesn't matter if compiled or install from pkg_add

 ./tmux-mem-cpu-load      
1158/7878MBsysctl: error getting initial cpu stats: Cannot allocate memory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.