Skip to content
Permalink
Browse files

Resume work on ODROID CloudShell 2

  • Loading branch information...
NEMS Linux
NEMS Linux committed Mar 2, 2019
1 parent cd501d1 commit 695a54f6f027df6c7d2e1be658163d6c82643bec
Showing with 267 additions and 26 deletions.
  1. +29 −26 cloudshell.sh
  2. +238 −0 info/cpuinfo
@@ -38,7 +38,7 @@
fi

# List of HW_MODEL are here: https://github.com/Fourdee/DietPi/blob/master/dietpi/dietpi-obtain_hw_model
HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model)
HW_MODEL=$(sed -n 1p /var/log/nems/hw_model)
CPU_CORES=$(nproc --all)

#Version
@@ -334,7 +334,7 @@

CPU_TOTALPROCESSES=$(( $(ps --ppid 2 -p 2 --deselect | wc -l) - 2 )) # - ps process and descriptions.
CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
CPU_TEMP=$(/DietPi/dietpi/dietpi-cpuinfo 1)
CPU_TEMP=$(/usr/local/share/nems/nems-scripts/info/cpuinfo 1)

if [[ $CPU_TEMP =~ ^-?[0-9]+$ ]]; then

@@ -479,7 +479,7 @@

df_failed=1

echo -e "$(date) | df failed to respond" >> /var/log/dietpi-cloudshell.log
echo -e "$(date) | df failed to respond" >> /var/log/nems/cloudshell.log

break

@@ -518,22 +518,22 @@
STORAGE_PERCENT[$i]=$C_PERCENT_GRAPH

#DEBUG John:
echo -e "Results success:\n" >> /var/log/dietpi-cloudshell.log
echo -e " - Index = $i" >> /var/log/dietpi-cloudshell.log
echo -e " - Path = ${STORAGE_PATH[$i]}" >> /var/log/dietpi-cloudshell.log
echo -e " - Total = ${STORAGE_TOTAL[$i]}" >> /var/log/dietpi-cloudshell.log
echo -e "Results success:\n" >> /var/log/nems/cloudshell.log
echo -e " - Index = $i" >> /var/log/nems/cloudshell.log
echo -e " - Path = ${STORAGE_PATH[$i]}" >> /var/log/nems/cloudshell.log
echo -e " - Total = ${STORAGE_TOTAL[$i]}" >> /var/log/nems/cloudshell.log

else

STORAGE_PERCENT[$i]="${STORAGE_PATH[$i]}"
STORAGE_FREE[$i]='Mount not active'

#DEBUG John:
echo -e "$(date) | Mount not found:\n" >> /var/log/dietpi-cloudshell.log
echo -e " - Index = $i" >> /var/log/dietpi-cloudshell.log
echo -e " - Path = ${STORAGE_PATH[$i]}\n" >> /var/log/dietpi-cloudshell.log
cat "$FP_TEMP" >> /var/log/dietpi-cloudshell.log
echo -e "\n" >> /var/log/dietpi-cloudshell.log
echo -e "$(date) | Mount not found:\n" >> /var/log/nems/cloudshell.log
echo -e " - Index = $i" >> /var/log/nems/cloudshell.log
echo -e " - Path = ${STORAGE_PATH[$i]}\n" >> /var/log/nems/cloudshell.log
cat "$FP_TEMP" >> /var/log/nems/cloudshell.log
echo -e "\n" >> /var/log/nems/cloudshell.log

fi

@@ -844,18 +844,21 @@

local aAnimation=(
' '
'i - c'
'P i - c l'
't P i - c l o'
'e t P i- c l o u'
'i e t Pi- c l o u d s'
'D i etPi- c l o u d s h'
' D ietPi-c l o u d s h e'
' DietPi-cl o u d s h e '
' DietPi-clou d s h e l '
' DietPi-clouds h e l l '
' DietPi-cloudshe l l '
' DietPi-cloudshell '
' N '
' N E '
' N E M '
' N E M S '
' N E M S '
' N E M S L '
' N E M S L i '
' N E M S L i n '
' N E M S L i n u '
' NE M S L i n u x '
' NEMS L i n u x '
' NEMS L i n u x '
' NEMS Lin u x '
' NEMS Linux '
' NEMS Linux '
)

local aBar=(
@@ -907,7 +910,7 @@

#Banner Modes
if (( $BANNER_MODE == 0 )); then
BANNER_PRINT="NEMS $DIETPI_CLOUDSHELL_VERSION"
BANNER_PRINT="NEMS Linux $DIETPI_CLOUDSHELL_VERSION"
elif (( $BANNER_MODE == 1 )); then
Obtain_DATE_TIME
BANNER_PRINT=$DATE_TIME
@@ -1264,7 +1267,7 @@ _EOF_
#Launch in blocking mode
if (( $output_current_screen == 1 )); then

/DietPi/dietpi/dietpi-cloudshell 1
/usr/local/share/nems/nems-scripts/cloudshell.sh 1

#Launch as service on main screen
else
@@ -0,0 +1,238 @@
#!/bin/bash
{
#////////////////////////////////////
# DietPi CPU Info Script
#
#////////////////////////////////////
# Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com
#
#////////////////////////////////////
#
# Info:
# - Prints CPU information
#
# Usage:
# - /DietPi/dietpi/dietpi-cpuinfo Obtain stats and print
# - /DietPi/dietpi/dietpi-cpuinfo 2 Generates file of available, ordered scaling freq's $FP_CPU_SCALINGAVAILABLE_FREQ
#////////////////////////////////////

#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
G_PROGRAM_NAME='DietPi-CPU_info'
G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------

#DietPi-Globals exit trap addition
G_EXIT_CUSTOM(){ unset aCPU_CURRENT_FREQ aCPU_MIN_FREQ aCPU_MAX_FREQ aCPU_SCALINGAVAILABLE_FREQ; }

#Grab Input
INPUT=0
disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1

aCPU_CURRENT_FREQ=()
aCPU_MIN_FREQ=()
aCPU_MAX_FREQ=()
Obtain_Cpu_Freq(){

for ((i=0; i<$(nproc --all); i++))
do

if [[ -f /sys/devices/system/cpu/cpu$i/cpufreq/scaling_cur_freq ]]; then

aCPU_CURRENT_FREQ[$i]=$(</sys/devices/system/cpu/cpu$i/cpufreq/scaling_cur_freq)

fi

if [[ -f /sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq ]]; then

aCPU_MIN_FREQ[$i]=$(</sys/devices/system/cpu/cpu$i/cpufreq/scaling_min_freq)

fi

if [[ -f /sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq ]]; then

aCPU_MAX_FREQ[$i]=$(</sys/devices/system/cpu/cpu$i/cpufreq/scaling_max_freq)

fi

done

}

aCPU_SCALINGAVAILABLE_FREQ=()
CPU_SCALINGSUPPORTED=1
FP_CPU_SCALINGAVAILABLE_FREQ='/tmp/dietpi-available_cpu_freqs'
Obtain_Cpu_Scaling_Freq(){

# - Intel
if [[ -f /sys/devices/system/cpu/intel_pstate/max_perf_pct ]]; then

local index=0
local value=10
while (( $value <= 100 ))
do

aCPU_SCALINGAVAILABLE_FREQ[$index]=$value
((index++))
value=$(( $value + 5 ))

done

# - Standard
elif [[ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies ]]; then

for ((i=0; i<$(nproc --all); i++))
do

aCPU_SCALINGAVAILABLE_FREQ[$i]=$(tr ' ' '\n' < /sys/devices/system/cpu/cpu$i/cpufreq/scaling_available_frequencies | sed 's/[^0-9]//g' | sed '/^$/d')

done

# - XU4 3.x
elif [[ -f /sys/devices/system/cpu/cpufreq/mp-cpufreq/cpu_freq_table ]]; then

aCPU_SCALINGAVAILABLE_FREQ[0]=$(tr ' ' '\n' < /sys/devices/system/cpu/cpufreq/mp-cpufreq/cpu_freq_table | sed 's/[^0-9]//g' | sed '/^$/d')

else

CPU_SCALINGSUPPORTED=0

fi

}

CPU_TEMP_CURRENT='N/A'
CPU_TEMP_PRINT='N/A'
Obtain_Cpu_Temp(){

CPU_TEMP_CURRENT=$(G_OBTAIN_CPU_TEMP)

if disable_error=1 G_CHECK_VALIDINT "$CPU_TEMP_CURRENT"; then

local cpu_temp_current_f=$(( $CPU_TEMP_CURRENT * 9/5 + 32 ))
if (( $CPU_TEMP_CURRENT >= 70 )); then

CPU_TEMP_PRINT="\e[1;31mWarning: $CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f | Reducing the life of your device.\e[0m"

elif (( $CPU_TEMP_CURRENT >= 60 )); then

CPU_TEMP_PRINT="\e[38;5;202m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[90m | Running hot, not recommended.\e[0m"

elif (( $CPU_TEMP_CURRENT >= 50 )); then

CPU_TEMP_PRINT="\e[1;33m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m \e[90m | Running warm, but safe.\e[0m"

elif (( $CPU_TEMP_CURRENT >= 40 )); then

CPU_TEMP_PRINT="\e[1;32m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Optimal temperature.\e[0m"

elif (( $CPU_TEMP_CURRENT >= 30 )); then

CPU_TEMP_PRINT="\e[1;36m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Cool runnings.\e[0m"

else

CPU_TEMP_PRINT="\e[1;36m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f \e[0m \e[90m| Who put me in the freezer!\e[0m"

fi

else

CPU_TEMP_PRINT=$CPU_TEMP_CURRENT

fi

}

CPU_GOV_CURRENT='N/A'
Obtain_Cpu_Gov(){

if [[ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]]; then

CPU_GOV_CURRENT=$(</sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)

fi

}

Print_Stats(){

echo -e "\n \e[38;5;154m─────────────────────────────────────────────────────\e[0m\n \e[1mDietPi CPU Info\n\e[90m Use dietpi-config to change CPU / performance options\e[0m\n \e[38;5;154m─────────────────────────────────────────────────────\e[0m"

#VM does not support most info
(( $G_HW_MODEL == 20 )) && echo -e '\n\e[90m[\e[93mWARNING\e[90m] \e[97mMost CPU information is not available on VM.\e[0m\n'

#Processor Arch
echo -e " Architecture \e[90m|\e[0m $(uname -m)"

#Current Temp
echo -e " Temperature \e[90m|\e[0m $CPU_TEMP_PRINT"

#Current Gov
echo -e " Governor \e[90m|\e[0m $CPU_GOV_CURRENT"

if [[ $CPU_GOV_CURRENT == 'ondemand' || $CPU_GOV_CURRENT == 'conservative' ]]; then

echo -e " Throttle up \e[90m|\e[0m $(grep -m1 '^[[:blank:]]*CONFIG_CPU_USAGE_THROTTLE_UP=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')% CPU usage"

fi

#Current Frequency
(( ${#aCPU_CURRENT_FREQ[@]} )) && echo -e '\n \e[90m Current Freq Min Freq Max Freq\e[0m'
for ((i=0; i<${#aCPU_CURRENT_FREQ[@]}; i++))
do

echo -e " \e[90mCPU$i |\e[0m $(( ${aCPU_CURRENT_FREQ[$i]:-0} / 1000 )) MHz \e[90m$(( ${aCPU_MIN_FREQ[$i]:-0} / 1000 )) MHz $(( ${aCPU_MAX_FREQ[$i]:-0} / 1000 )) MHz\e[0m"

done

echo ''

#CPU scaling may bump up with script
G_DIETPI-NOTIFY 2 'CPU current frequency, may be affected by this script, due to the processing required to run it.\n'

}

#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
#-----------------------------------------------------------------------------------

#Return mode
if (( $INPUT == 2 )); then

Obtain_Cpu_Scaling_Freq

# Export to file
> $FP_CPU_SCALINGAVAILABLE_FREQ

if (( $CPU_SCALINGSUPPORTED )); then

for i in ${aCPU_SCALINGAVAILABLE_FREQ[@]}
do

echo -e "$i" >> $FP_CPU_SCALINGAVAILABLE_FREQ

done

# Order, remove dupes
sort -u -n $FP_CPU_SCALINGAVAILABLE_FREQ -o $FP_CPU_SCALINGAVAILABLE_FREQ

fi

#Print all stats
else

Obtain_Cpu_Freq
Obtain_Cpu_Temp
Obtain_Cpu_Gov

Print_Stats

fi

#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}

0 comments on commit 695a54f

Please sign in to comment.
You can’t perform that action at this time.