Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Not working / reporting errors when launched on Mac OS X #25

Closed
gwarf opened this issue Apr 24, 2020 · 42 comments
Closed

[BUG] Not working / reporting errors when launched on Mac OS X #25

gwarf opened this issue Apr 24, 2020 · 42 comments
Assignees
Labels
bug Something isn't working

Comments

@gwarf
Copy link

gwarf commented Apr 24, 2020

Hi,
I've just cloned the repo and tried to run it without any parameters on my Mac OS X system and it prints various errors and stops:

./bashtop
./bashtop: line 33: shopt: globasciiranges: invalid shell option name
./bashtop: line 33: shopt: globstar: invalid shell option name
./bashtop: line 112: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]

I'm using ZSH but bash is installed (and that shouldn't change much):

 bash --version                                                                                                                                   ─╯
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19)
Copyright (C) 2007 Free Software Foundation, Inc.

Screenshot 2020-04-24 at 15 37 34
Screenshot 2020-04-24 at 15 39 39

@gwarf gwarf added the bug Something isn't working label Apr 24, 2020
@gwarf
Copy link
Author

gwarf commented Apr 24, 2020

Oh, sorry just realised this bash version is too old. Will see if I can test with a more recent one.

@aristocratos
Copy link
Owner

It's also only supported on Linux for the moment. There will be OSX support in a couple of weeks.

@gwarf
Copy link
Author

gwarf commented Apr 24, 2020

OK, clear. Thanks!
So with bash 5 from https://brew.sh/ it starts without errors and shows all the placeholders, just lacking the dynamic info.

Screenshot 2020-04-24 at 15 49 28

@aristocratos
Copy link
Owner

Yeah, it will be using python for data collection when I'm done rewriting, so will have support for linux, bsd, osx and possibly even windows :P

@gwarf
Copy link
Author

gwarf commented Apr 24, 2020

But for sure it looks cool :) And also like a crazy idea to do this in bash ;)

@diogopublio
Copy link

cant wait for the mac version

@sudoFerraz
Copy link

+1 for mac

1 similar comment
@yeyuguo
Copy link

yeyuguo commented Apr 27, 2020

+1 for mac

@sudoFerraz
Copy link

@aristocratos can you update us on this thread upon release of mac support? <3

@assoft
Copy link

assoft commented Apr 28, 2020

+1 for mac

@aristocratos
Copy link
Owner

@gwarf @diogopublio @sudoFerraz @assoft
Mac OS X support added in v0.9.0

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So I had to install gnu-sed with homebrew, coreutils was already installed, but not sure if it's required.
I also had to setup a python3 virutalenv and to install psutils with pyenv.

brew install gnu-sed
pyenv install 3.8.2
pyenv global 3.8.2
pip install psutil

And then it worked nicely even if it's not as easy as just having bash as a dependency:
Screenshot 2020-05-25 at 09 51 44

@aristocratos
Copy link
Owner

Did the instructions under https://github.com/aristocratos/bashtop#installation not work?

brew install bash coreutils gnu-sed python3 git
pip3 install psutil

Shouldn't be any need for pyenv if you got python3 installed and use pip3 to install psutil.
At least hasn't been a problem in a OSX Mojave vm.

Also needs osx-cpu-temp if you want CPU temps reported.

@aristocratos
Copy link
Owner

aristocratos commented May 25, 2020

@gwarf Looks to be something weird going on with your reported disks. Would you mind showing the output you get when running gdf -x squashfs -x tmpfs -x devtmpfs -x overlay?

@gwarf
Copy link
Author

gwarf commented May 25, 2020

OK, so I scanned the README too quickly it seems as I didn't saw those instructions ;)
osx-cpu-temp is also available in homebrew: https://github.com/Homebrew/homebrew-core/blob/master/Formula/osx-cpu-temp.rb

brew install osx-cpu-temp

So I tried with python3 and pip3 from homebrew and it works fine too.

So I unmounted an install disk and now it shows also the keybase and Google FileStream virtual drives:

❯ gdf -x squashfs -x tmpfs -x devtmpfs -x overlay
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/disk1s5   976797816  10887620 567769232   2% /
/dev/disk1s4   976797816   9716800 567769232   2% /private/var/vm
kbfs@kbfuse0   262144000     18190 262125810   1% /Volumes/Keybase (baptiste)
drivefs        976797816 437417048 539380768  45% /Volumes/GoogleDrive

But it seems to be missing to report the space used by my files:

Screenshot 2020-05-25 at 10 59 56
Screenshot 2020-05-25 at 11 00 00

And the bashtop output is:

Screenshot 2020-05-25 at 10 43 29

I've also enabled CPU monitoring in the menu and restarted bashtop as there was some artefacts on the screen:
It seems a bit hot to me but maybe it's fine, never checked this before.

Screenshot 2020-05-25 at 10 48 14

@aristocratos
Copy link
Owner

@gwarf

osx-cpu-temp is also available in homebrew

Oh, nice, gonna change the instructions.

But it seems to be missing to report the space used by my files

Gonna take a look at implementing psutil for disks collection too, seems like GNU df has some problems on OSX.

I've also enabled CPU monitoring in the menu and restarted bashtop as there was some artefacts on the screen:
It seems a bit hot to me but maybe it's fine, never checked this before.

I would say that's pretty normal for newer macs, especially with that CPU. They can get pretty scary hot.

@aristocratos
Copy link
Owner

@gwarf
Oh right.

Will also need to be run as superuser on OSX to display stats for processes not owned by user.
The disk io stats on OSX and FreeBSD shows iostats for all disks at the top instead of per disk.

Try running bashtop with sudo and see if the missing disk show up.

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So even with sudo it's not shown:

❯ sudo gdf
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/disk1s5   976797816  10887620 568741736   2% /
/dev/disk1s4   976797816   8668220 568741736   2% /private/var/vm
kbfs@kbfuse0   262144000     18190 262125810   1% /Volumes/Keybase (baptiste)
drivefs        976797816 436493168 540304648  45% /Volumes/GoogleDrive

And bashtop running with sudo:
Screenshot 2020-05-25 at 12 25 16

But diskutil and the MacOS X system df can show some more stuff:

❯ sudo diskutil list
/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     314.6 MB   disk0s1
   2:                 Apple_APFS Container disk1         1.0 TB     disk0s2

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +1.0 TB     disk1
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD - Data     396.5 GB   disk1s1
   2:                APFS Volume Preboot                 105.5 MB   disk1s2
   3:                APFS Volume Recovery                1.0 GB     disk1s3
   4:                APFS Volume VM                      8.9 GB     disk1s4
   5:                APFS Volume Macintosh HD            11.1 GB    disk1s5
❯ /bin/df
Filesystem         512-blocks      Used  Available Capacity     iused      ifree %iused  Mounted on
/dev/disk1s5       1953595632  21775240 1137432848     2%      487496 9767490664    0%   /
devfs                     541       541          0   100%         939          0  100%   /dev
/dev/disk1s1       1953595632 774400256 1137432848    41%     2340828 9765637332    0%   /System/Volumes/Data
/dev/disk1s4       1953595632  17336440 1137432848     2%           8 9767978152    0%   /private/var/vm
map auto_home               0         0          0   100%           0          0  100%   /System/Volumes/Data/home
keybase-redirector          0         0          0   100%           0          0  100%   /Volumes/Keybase
kbfs@kbfuse0        524288000     36380  524251620     1%           0          0  100%   /Volumes/Keybase (baptiste)
drivefs            1953595632 873034432 1080561200    45% 18446744069414660980 4294967295 24063376863009772%   /Volumes/GoogleDrive
❯ /bin/df -l
Filesystem   512-blocks      Used  Available Capacity     iused      ifree %iused  Mounted on
/dev/disk1s5 1953595632  21775240 1137432544     2%      487496 9767490664    0%   /
/dev/disk1s1 1953595632 774400560 1137432544    41%     2340832 9765637328    0%   /System/Volumes/Data
/dev/disk1s4 1953595632  17336440 1137432544     2%           8 9767978152    0%   /private/var/vm
drivefs      1953595632 873034720 1080560912    45% 18446744069414660980 4294967295 24063376863009772%   /Volumes/GoogleDrive
❯ /bin/df -T apfs
Filesystem   512-blocks      Used  Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s5 1953595632  21775240 1137432960     2%  487496 9767490664    0%   /
/dev/disk1s1 1953595632 774400144 1137432960    41% 2340830 9765637330    0%   /System/Volumes/Data
/dev/disk1s4 1953595632  17336440 1137432960     2%       8 9767978152    0%   /private/var/vm

@aristocratos
Copy link
Owner

Ok, I've changed so bashtop will use system df on OSX and filter out devfs and any disk with 0 block size. Seems to be working but I don't know if there is more filtering needed for unwanted items that might get picked up. That could however be solved by the user setting a filter in the options...

Will include fix in a update later today.

@aristocratos
Copy link
Owner

Also added value for active memory since OSX don't report cached memory. Also moved /private/var/vm from disks to show as swap memory instead.

@aristocratos
Copy link
Owner

@gwarf Test v0.9.3 and see if it works better :)

@gwarf
Copy link
Author

gwarf commented May 25, 2020

Thanks :)
So it's missing the disks names, and apparently I still got the same 4:

Screenshot 2020-05-25 at 14 44 20

By the way with molokai theme it's really nice, but it would be great to get a nord theme too: https://github.com/arcticicestudio

@aristocratos
Copy link
Owner

@gwarf Can you check if there's any output in ~/.config/bashtop/error.log

Not sure why it isn't working, works fine in my vm, and the formatting of "bsd df" doesn't differ between Mojave and Catalina.

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So I cleaned previous output, restarted, same behaviour (with or without sudo) and no errors shown, only:

New instance of bashtop version: 0.9.3 Pid: 27281

I'm using the latest master:

❯ git pull
Already up to date.
Current branch master is up to date.
❯ git log -n 1
commit 6927ee954bed80c978654a0078455e073d109d7f (HEAD -> master, tag: v0.9.3, origin/master, origin/HEAD)
Author: aristocratos <gnmjpl@gmail.com>
Date:   Mon May 25 14:00:20 2020 +0200

    v0.9.3 OSX fixes and misc optimizations

My config file is:

❯ cat ~/.config/bashtop/bashtop.cfg
#? Config file for bashtop v. 0.9.3

#* Color theme, looks for a .theme file in "$HOME/.config/bashtop/themes", "Default" for builtin default theme
color_theme="monokai"

#* Update time in milliseconds, increases automatically if set below internal loops processing time, recommended 2000 ms or above for better sample times for graphs
update_ms="2600"

#* Processes sorting, "pid" "program" "arguments" "threads" "user" "memory" "cpu lazy" "cpu responsive" "tree"
#* "cpu lazy" updates sorting over time, "cpu responsive" updates sorting directly at a cpu usage cost
proc_sorting="cpu lazy"

#* Reverse sorting order, "true" or "false"
proc_reversed="false"

#* Check cpu temperature, only works if "sensors", "vcgencmd" or "osx-cpu-temp" commands is available
check_temp="true"

#* Draw a clock at top of screen, formatting according to strftime, empty string to disable
draw_clock="%X"

#* Update main ui when menus are showing, set this to false if the menus is flickering too much for comfort
background_update="true"

#* Custom cpu model name, empty string to disable
custom_cpu_name=""

#* Enable error logging to "$HOME/.config/bashtop/error.log", "true" or "false"
error_logging="true"

#* Show color gradient in process list, "true" or "false"
proc_gradient="true"

#* If process cpu usage should be of the core it's running on or usage of the total available cpu power
proc_per_core="false"

#* Optional filter for shown disks, should be names of mountpoints, "root" replaces "/", separate multiple values with space
disks_filter=""

#* Enable check for new version from github.com/aristocratos/bashtop at start
update_check="true"

#* Enable graphs with double the horizontal resolution, increases cpu usage
hires_graphs="false"

#* Enable the use of psutil python3 module for data collection, default on OSX
use_psutil="true"

@aristocratos
Copy link
Owner

Can you post ouput of df -k, should only change to reporting 1k blocks but you never know if something weird is happening.

The name gets collected from an array containing each line, so should be 9 columns and the last should be the mount point.

@gwarf
Copy link
Author

gwarf commented May 25, 2020

❯ df -k
Filesystem     1K-blocks      Used Available Use% Mounted on
/dev/disk1s5   976797816  10887620 567560412   2% /
/dev/disk1s4   976797816   9716800 567560412   2% /private/var/vm
kbfs@kbfuse0   262144000     18190 262125810   1% /Volumes/Keybase (baptiste)
drivefs        976797816 437615428 539182388  45% /Volumes/GoogleDrive

❯ /bin/df -k
Filesystem         1024-blocks      Used Available Capacity     iused      ifree %iused  Mounted on
/dev/disk1s5         976797816  10887620 567560432     2%      487496 9767490664    0%   /
devfs                      267       267         0   100%         924          0  100%   /dev
/dev/disk1s1         976797816 387307540 567560432    41%     2338270 9765639890    0%   /System/Volumes/Data
/dev/disk1s4         976797816   9716800 567560432     2%           9 9767978151    0%   /private/var/vm
map auto_home                0         0         0   100%           0          0  100%   /System/Volumes/Data/home
keybase-redirector           0         0         0   100%           0          0  100%   /Volumes/Keybase
kbfs@kbfuse0         262144000     18190 262125810     1%           0          0  100%   /Volumes/Keybase (baptiste)
drivefs              976797816 437615408 539182408    45% 18446744069414661756 4294967295 23822230347277924%   /Volumes/GoogleDrive

I've also a customized zsh env, not sure if some stuff could interfere.

❯ where df
df: aliased to df -kh
/usr/local/opt/coreutils/libexec/gnubin/df
/bin/df

@aristocratos
Copy link
Owner

Ah, that's the problem, it's defaulting to GNU df and I didn't add the path to the binary.
If you change line 2221 to:
readarray -t df_array < <(/bin/df -k 2>/dev/null || true)
It should work.

Will add the fix in next update.

@aristocratos
Copy link
Owner

Btw do you know if the swap your system reports is from /private/var/vm or if it's a seperate swap file?

I have it setup right now so /private/var/vm will replace the values reported from swap. If it's not taken from the same pool I should probably change it to add to the values instead of replacing.

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So I'm not used to swap management in MacOS X, but here is some information, it seems it's reporting the summary of the swap file (+ a sleepimage file, probably for hibernation, but didn't looked further):

Screenshot 2020-05-25 at 15 44 42

And with the manual patch it works great :)

Screenshot 2020-05-25 at 15 46 44

Thanks!

@aristocratos
Copy link
Owner

The problem is that I'm not sure where psutil gets swap info from
python3 -c "import psutil; print(psutil.swap_memory())"
It's reporting zero on all values in my virtual machine, but seems to get some values on your "real" mac. So the question is if I should add the values reported from psutil to the values from /private/var/vm. Or if I should just override them.
Not sure they are the same looking at the older screenshots you posted.

And with the manual patch it works great :)

Awesome :)

@aristocratos
Copy link
Owner

By the way with molokai theme it's really nice, but it would be great to get a nord theme too:

Somebody started making a nord theme #116 but I don't know if he gave up.

@aristocratos
Copy link
Owner

aristocratos commented May 25, 2020

I just realized that the values psutil is reporting might be all the swapfiles minus the sleepimage.
Should probably keep the values from psutil then and only replace the values if they are zero.

Edit:
Did some testing and that seems to be the case, It was showing 0 initially because I wasn't using any swap :P

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So yes you are right for the computation:
Screenshot 2020-05-25 at 16 38 39

@aristocratos
Copy link
Owner

Added all fixes in v0.9.4
Hopefully everything should be in working order now :)

@gwarf
Copy link
Author

gwarf commented May 25, 2020

So from latest master it works great, well done, thanks!

Screenshot 2020-05-25 at 17 41 51

So now it's only missing a brew formula ;)

@aristocratos
Copy link
Owner

Noticed i missed filtering out drives with 0 total capacity, will be fixed in next update.

Hopefully somebody who has experience in homebrew will create one, otherwise it will take a while before I get to it.

@gwarf
Copy link
Author

gwarf commented May 25, 2020

I'm not sure I would have time to dig into homebrew, but you can ping me if needed to test some stuff on MacOS X.

@Justinzobel
Copy link
Contributor

By the way with molokai theme it's really nice, but it would be great to get a nord theme too:

Somebody started making a nord theme #116 but I don't know if he gave up.

Sorry been a busy few days. I'm still working on it. :)

@daolou
Copy link

daolou commented Aug 13, 2020

@gwarf

Are you using Iterm2? And could you share the them?

@gwarf
Copy link
Author

gwarf commented Aug 13, 2020

@gwarf
Are you using Iterm2? And could you share the them?

Yes, I'm using iterm2. bashtop theme is Molokai, iTerm2 colors and tmux were with Nord theme by @arcticicestudio and ZSH prompt is powerlevel10k.

@daolou
Copy link

daolou commented Aug 13, 2020

@gwarf
Are you using Iterm2? And could you share the them?

Yes, I'm using iterm2. bashtop theme is Molokai, iTerm2 colors and tmux were with Nord theme by @arcticicestudio and ZSH prompt is powerlevel10k.

Extremely grateful!

@gwarf
Copy link
Author

gwarf commented Aug 13, 2020

And the fancy ll is in fact an alias to https://github.com/ogham/exa, see my messy ~/.zshrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants