You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
508 B

#!/bin/bash
# DANGER='\033[0;31m'
# WARNING='\033[1;33m'
# INFO='\033[0;34m'
# NC='\033[0m' # No Color
DANGER='#FF0000'
WARNING='#FFFF00'
INFO='#00FF00'
NC='' # No Color
topLine=$(top -b -n 1 | head -8 | tail -1)
topApp=$(echo -n $topLine | awk '{print $12}')
cpuLoad=$(echo -n $topLine | awk '{print $9}')
COLOR=$NC
cpuInt=$(printf "%.0f" $cpuLoad)
if [ $cpuInt -gt 80 ]; then
COLOR=$DANGER
elif [ $cpuInt -gt 50 ]; then
COLOR=$WARNING
fi
printf "${cpuLoad}%% ${topApp}\n${COLOR}\n"
exit 0