mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
parent
d7d3501fda
commit
d943588bb4
|
|
@ -36,6 +36,8 @@ If format strings are added to `status-right`, they should now be visible.
|
|||
`iostat` or `sar` are the best way to get an accurate CPU percentage.
|
||||
A fallback is included using `ps -aux` but could be inaccurate.
|
||||
`nvidia-smi` is required for GPU information.
|
||||
For OSX, `cuda-smi` is required instead (but only shows GPU memory use rather
|
||||
than load).
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
@ -128,4 +130,3 @@ twitter if you want to hear about new tmux plugins or feature updates.
|
|||
### License
|
||||
|
||||
[MIT](LICENSE.md)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,13 +6,17 @@ source "$CURRENT_DIR/helpers.sh"
|
|||
|
||||
print_gpu_percentage() {
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(nvidia-smi | sed -nr 's/.*\s([0-9]+)%.*/\1/p')
|
||||
gpus=$(echo "$loads" | wc -l)
|
||||
load=$(echo "$loads" | awk '{count+=$1} END {print count}')
|
||||
echo "$load $gpus" | awk '{printf "%3.0f%%", $1/$2}'
|
||||
loads=$(nvidia-smi)
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cuda-smi)
|
||||
else
|
||||
echo "nvidia-smi not found"
|
||||
echo "nvidia-smi/cuda-smi not found"
|
||||
return
|
||||
fi
|
||||
loads=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)%.*/\1/p')
|
||||
gpus=$(echo "$loads" | wc -l)
|
||||
load=$(echo "$loads" | awk '{count+=$1} END {print count}')
|
||||
echo "$load $gpus" | awk '{printf "%3.0f%%", $1/$2}'
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue