diff --git a/scripts/cpu_info.sh b/scripts/cpu_info.sh index c765d16..b96c399 100755 --- a/scripts/cpu_info.sh +++ b/scripts/cpu_info.sh @@ -16,7 +16,7 @@ get_percent() { case $(uname -s) in Linux) - percent=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') + percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}') echo $percent ;; diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 79b60f1..785cf8f 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -16,7 +16,7 @@ get_platform() { case $(uname -s) in Linux) - gpu=$(lspci -v | grep -i gpu | grep driver | awk '{print $5}') + gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}') echo $gpu ;; @@ -32,10 +32,12 @@ get_platform() get_gpu() { gpu=$(get_platform) - if [ $gpu == nvidia-gpu ]; then - usage=$(nvidia-smi | grep "%" | awk '{print $13}') - echo $usage + if [[ "$gpu" == NVIDIA ]]; then + usage=$(nvidia-smi | grep '%' | awk '{ sum += $13 } END { printf("%d%%\n", sum / NR) }') + else + usage='unknown' fi + echo $usage } main() { @@ -47,5 +49,3 @@ main() } # run the main driver main - -