#!/bin/bash declare -A graph_chars_up='( [0_0]=⠀ [0_1]=⢀ [0_2]=⢠ [0_3]=⢰ [0_4]=⢸ [1_0]=⡀ [1_1]=⣀ [1_2]=⣠ [1_3]=⣰ [1_4]=⣸ [2_0]=⡄ [2_1]=⣄ [2_2]=⣤ [2_3]=⣴ [2_4]=⣼ [3_0]=⡆ [3_1]=⣆ [3_2]=⣦ [3_3]=⣶ [3_4]=⣾ [4_0]=⡇ [4_1]=⣇ [4_2]=⣧ [4_3]=⣷ [4_4]=⣿ )' # declare -A graph_chars_down='( # [0_0]=⠀ [0_1]=⠈ [0_2]=⠘ [0_3]=⠸ [0_4]=⢸ # [1_0]=⠁ [1_1]=⠉ [1_2]=⠙ [1_3]=⠹ [1_4]=⢹ # [2_0]=⠃ [2_1]=⠋ [2_2]=⠛ [2_3]=⠻ [2_4]=⢻ # [3_0]=⠇ [3_1]=⠏ [3_2]=⠟ [3_3]=⠿ [3_4]=⢿ # [4_0]=⡇ [4_1]=⡏ [4_2]=⡟ [4_3]=⡿ [4_4]=⣿ # )' # cntcpu=0 # CountCPU() { # local fld foo # while read fld foo;do # [ "$fld" = "processor" ] && ((cntcpu++)) # done =i*4)) ;then val[i]=4 elif ((crtpix<=(i*4-4))) ;then val[i]=0 else val[i]=$[crtpix%4] fi crtline[i]+=${graph_chars_up[${lval[i]}_${val[i]}]} ((${#crtline[i]}>width))&&crtline[i]=${crtline[i]:1} printf "\e[%d;%dH\e[K%s" \ $((height-i)) $((width+1-${#crtline[i]})) "${crtline[i]}" done ((evenodd=1-evenodd)) IFS=. read sec micro <<<$EPOCHREALTIME percent $[utcpu+lastidl-idlcpu-lastut] $[utcpu-lastut] prct printf "\e[%d;1H%(%T)T.%s %9s (last sleep: 0.%s sec)\e[K" \ $height $sec $micro $prct ${tosleep:1} done } trap readGrSizes WINCH crtstat height=24 width=80 lnnames=(even odd) declare -a graphline_even graphline_odd readGrSizes tput civis mainloop tput cnorm