x70b1 / motd-on-acid

This MOTD has so many colors!
The Unlicense
67 stars 7 forks source link

bad math expression for SWAP-Partition #1

Closed brthld closed 4 years ago

brthld commented 4 years ago

Hi, thank you for the good and beautiful work so far.

While setting it up on my server, i experienced an issue. Everything worked good out of the box, except on line in the "Diskspace:" area. After displaying correctly my hard drives, i get this on zsh : generate_bar_disk:11: bad math expression: operand expected at end of string

after switching to bash, it seems to be an issue where the SWAP-Partition is counted as seperate disk: bash: [: Used: integer expression expected [SWAP] UsedM used / 1M available

x70b1 commented 4 years ago

Thanks for that! I will take a look whats wrong there. But I guess it needs some days. So if you remove the --swap command everything works until then, right?

brthld commented 4 years ago

zsh stops the execution with the error message, bash continues the execution and prints Services, Updates and Logins just nicely after the displayed error.

--swap is displayed correctly in every case, the problem is contained in --diskspace and if i remove this module, then everything is ok in both bash and zsh, generally i prefer zsh

x70b1 commented 4 years ago

Ok, i will check it with zsh and try to find out whats wrong.

x70b1 commented 4 years ago

Unfortunately, I cant reproduce it. I found some other problems on zsh. But nothing in the diskspace module.

You could run

set -x
source .bashrc_motd
bash_motd --diskspace

and look into it, or post the output here.

x70b1 commented 4 years ago

I found it. We have to exclude the swap from the disks in diskusage. Can you replace line 317 with:

lsblk -Jlo NAME,MOUNTPOINT | jq  -c '.blockdevices | sort_by(.mountpoint) | .[] | select( .mountpoint != null and .mountpoint != "[SWAP]" )'

And test it?

Edit: the fix is now in the latest version: https://github.com/x70b1/motd-on-acid/commit/0435c9bfedc5e121415f0f5308a2845e893568ef

brthld commented 4 years ago

Confirmed! Now my bash_motd --banner --processor --memory --swap --diskspace --services --updates works flawlessly in zsh and bash - I appreciate your work :) !