A little sysinfo script for CLI - Raspberry Pi Development

EDIT: I've updated the script with a bit more info.
All you need is the additional package "bc".
Code:
#!/bin/bash
cpuUsageM=$(top -bn 1 | awk '{print $9}' | tail -n +8 | awk '{s+=$1} END {print s}')
cpuFreqM=$(echo "scale=0; " `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq` "/1000" | bc)
cpuTempM=$(echo "scale=1; " `cat /sys/class/thermal/thermal_zone0/temp` "/1000" | bc)
gpuTempM=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTempM=${gpuTempM//\'C/}
gpuTempM=${gpuTempM//temp\=/}
memTotalM=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
memTotal1=$memTotalM
memTotalM=$(echo "scale=1; $memTotal1 / 1024" | bc)
memUsageM=$(cat /proc/meminfo | grep MemFree | awk '{print $2}')
memUsageM=$(echo "scale=1; ($memTotal1 - $memUsageM) / 1024" | bc | sed 's/^\./0./')
memUsageP=$(echo "scale=1; (100/$memTotalM) * $memUsageM" | bc | sed 's/^\./0./')
rootTotalM=$(df -m / | grep / | awk '{print $2}')
rootTotalM=$(echo "scale=1; $rootTotalM / 1024" | bc)
rootUsageM=$(df -m / | grep / | awk '{print $3}')
rootUsageM=$(echo "scale=1; $rootUsageM / 1024" | bc | sed 's/^\./0./')
rootUsageP=$(echo "scale=1; (100/$rootTotalM) * $rootUsageM" | bc | sed 's/^\./0./')
echo "CPU Usage: $cpuUsageM%"
echo "CPU Freq: "$cpuFreqM"MHz"
echo "CPU Temp: $cpuTempM°C"
echo ""
echo "GPU Temp: $gpuTempM°C"
echo ""
echo "MEM Usage: "$memUsageM"MB/"$memTotalM"MB ($memUsageP%)"
echo "Root Usage: "$rootUsageM"GB/"$rootTotalM"GB ($rootUsageP%)"
The output is as follows:
Code:
~$ ./sysinfo
CPU Usage: 70.1%
CPU Freq: 800MHz
CPU Temp: 57.8°C
GPU Temp: 58.4°C
MEM Usage: 96.5MB/375.4MB (19.3%)
Root Usage: 0.9GB/7.2GB (12.4%)

That is actually insanely useful. Wish I saw this a little earlier, it would of saved a lot of time.

Thanks. This script just what I was looking for

Cheers i will try and get this to output via php for a little site i'm making for my pi.

thx for sharing

Perfect

Related

Need some help modding

Hello everyone i'm currently developing a rom based on froyo 2.2.2. His name is openOptimus.
How can i put dalvik-cache on SD? SOLVED
How i can change heap-size? SOLVED
How i can put jit and HWacc in my rom? SOLVED
How can i modify default settings?
How can i put mik_os kernel in my rom? SOLVED
For OC,i opened up init.qcom.post_boot.sh but how i can modify the frequency?
Here it is:
Code:
target=`getprop ro.product.device`
case "$target" in
"msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_surf" | "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "qsd8650a_st1x")
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
;;
esac
ciaox said:
Hello everyone i'm currently developing a rom based on froyo 2.2.2. His name is openOptimus.
How can i put dalvik-cache on SD?
How i can change heap-size?
How i can put jit and HWacc in my rom?
Click to expand...
Click to collapse
1.Choose "Add Apps2SD". You will then be asked whether you want to move dalvik-cache too.
2. Go to /kitchen/WORKING_RANDOM_NUMBERS/system/ and edit build.prop.
3. Same as #2.
Though I would advise not moving dalvik-cache on SD.
thanxs dawg. I will let u know.
For OC,i opened up init.qcom.post_boot.sh but how i can modify the frequency?
Here it is:
Code:
target=`getprop ro.product.device`
case "$target" in
"msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_surf" | "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "qsd8650a_st1x")
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
;;
esac
Ah yeah,how can i modify default settings?
I would leave jit since its default..
But I wouldn't suggest hw acc.
Its a known battery consumer ..and yields lil difference in performance.
Up guys please
To incorporate a kernel:
1. Go to kitchen's advanced options
2. Choose unpack/repack boot.img
3. Backup the boot.img-kernel file in BOOT-EXTRACTED folder (you will be replacing this. you may not back this up)
4. From a kernel's flashable zip file, extract the file and browse to kernel and copy the zImage file to the BOOT-EXTRACTED folder.
5. Delete the old one.
6. Rename zImage to boot.img-kernel
7. Then build.
For automatic OC, I don't know since I don't do that. I prefer SetCPU because of the profiles.
Thanks u r da man
Np. Try to ask DookMatt about the cpu frequency on boot thingy. If you know, please tell me.
Also, follow me back on twitter. hahahaha im kinda new.
Yea i'm asking it even to PaoloM70. All i know it's that you have to open init.qcom.post_boot.sh but i don't know what values to change
EDIT **** PaoloM70 won't answer me
ciaox said:
thanxs dawg. I will let u know.
For OC,i opened up init.qcom.post_boot.sh but how i can modify the frequency?
Here it is:
Code:
target=`getprop ro.product.device`
case "$target" in
"msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_surf" | "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "qsd8650a_st1x")
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
;;
esac
Click to expand...
Click to collapse
I'm not sure about this, i just started cooking my own rom 2 days ago, but i think that "echo 245760" is the minimum frequency, "echo 500000" is the max frequency and "echo 90" is the value of MHz by which the max frequency threshold is raised in case there is a demand for it, for example: from 500MHz to ~600MHz.
If i'm right it means that you only have to edit those values to whatever you want.
This example is for a min freq of 122MHz and a max freq of 724mhz, i took the values from setCPU.
Code:
target=`getprop ro.product.device`
case "$target" in
"msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_surf" | "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "qsd8650a_st1x")
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
echo 629600 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate
echo 122880 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
;;
esac
Again, i'm not sure if this is the right way, it just seems logical to me.
Hope a more experienced dev can check this and tell me if i am right or wrong.
Thhanks man but i need to change governor. How to do this?
ciaox said:
Thhanks man but i need to change governor. How to do this?
Click to expand...
Click to collapse
isn't this line the one for the governor setting?
Code:
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
if so, you could change "interactive" with "ondemand"
Yeah man PaoloM70 answered me
Do like this:
Code:
target=`getprop ro.product.device`
case "$target" in
"msm7201a_ffa" | "msm7201a_surf" | "msm7627_ffa" | "msm7627_surf" | "qsd8250_surf" | "qsd8250_ffa" | "msm7630_surf" | "qsd8650a_st1x")
echo "interactive" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 90 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/up_threshold
echo 500000 > /sys/devices/system/cpu/cpu0/cpufreq/interactive/sampling_rate
echo 729600 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo 245760 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq
;;
esac

[Q] How to flash boot.img in shell? (from phone's sdcard)

some kernel app can download and flash boot.img, restarts, how can I do that in terminal? (without the need of adb or Recovery... save hell lots of time)
I'm afraid thats impossible.
kurotsugi said:
I'm afraid thats impossible.
Click to expand...
Click to collapse
so this are dark magic?
Code:
#!/sbin/bb/busybox ash
# lkflash - flash latest leanKernel
#
# author - [email protected]
#
BB="/sbin/bb/busybox"
STABLE="http://imoseyon.host4droid.com/latest"
EXP180="http://imoseyon.host4droid.com/exp/latest180"
EXP230="http://imoseyon.host4droid.com/exp/latest230"
CUR=`$BB uname -a | $BB awk -F'-' '{ print \$3 }'`
while [ 1 ]; do
echo
echo "leanKernel flasher"
echo "------------------"
echo "1) latest stable (recommended)"
echo "2) latest experimental 180mhz-1.65ghz (notrim)"
echo "3) latest experimental 230mhz-1.65ghz (notrim)"
echo "4) check/display versions"
echo "9) latest stable franco (warning: no md5 check)"
echo
echo "FLASH AT YOUR OWN RISK. I'm not responsible for my mistakes or yours. ;)"
echo
echo -n "Please enter a number between 1 and 4 (or press enter to exit): "
read option
case $option in
1)
$BB wget -q -O /sdcard/lk $STABLE
echo; echo -n "Downloading stable "
break
;;
2)
$BB wget -q -O /sdcard/lk $EXP180
echo; echo -n "Downloading experimental 180mhz (notrim) "
break
;;
3)
$BB wget -q -O /sdcard/lk $EXP230
echo; echo -n "Downloading experimental 230mhz (notrim) "
break
;;
4)
echo "Please wait..."
vstable=`$BB wget -q -O - $STABLE | $BB awk '{ print \$3 }'`
v180=`$BB wget -q -O - $EXP180 | $BB awk '{ print \$3 }'`
v230=`$BB wget -q -O - $EXP230 | $BB awk '{ print \$3 }'`
echo; echo ">>> Current version: $CUR, Latest stable: $vstable, Exp: $v180 $v230"
sleep 2
;;
9)
$BB wget -q -O /sdcard/fboot.img http://minooch.com/franciscofranco/Galaxy%20Nexus/nightlies/appfiles/boot.img
$BB dd if=/sdcard/fboot.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot 2> /dev/null
echo "Latest Franco Kernel flashed. Reboot when you're ready."
exit
;;
*)
echo "BYE"
exit
;;
esac
done
[ ! -s "/sdcard/lk" ] && exit
MD5=`$BB awk '{ print \$2 }' /sdcard/lk`
VER=`$BB awk '{ print \$3 }' /sdcard/lk`
if [ "$CUR" == "$VER" ]; then
echo
echo "Aborted. You're already running $CUR."
exit
fi
echo "v$VER. Please wait..."
$BB wget -q -O /sdcard/lkboot.img `$BB awk '{ print \$1 }' /sdcard/lk`
[ ! -s "/sdcard/lkboot.img" ] && exit
SUM=`$BB md5sum /sdcard/lkboot.img | $BB awk '{ print \$1 }'`
echo
if [ "$MD5" == "$SUM" ]; then
echo "Download finished. Checksum verified. Flashing kernel to boot partition..."
$BB dd if=/sdcard/lkboot.img of=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot 2> /dev/null
echo; echo "leanKernel $VER flashed! Reboot when you're ready to run new kernel."
else
echo "md5sum check failed - please try again."
fi

[Q] Leaving getevent without “-c count”

Hi,
for catching events I found:
http://forum.xda-developers.com/showthread.php?t=2233865
Now I want to build a shell were I can look for devices and then catch them and bind them to a action...
It's my first time I tried to write a shell script...
The script works if I don't have any devices witch sends continuously there daters:
Code:
#!/system/bin/sh
[...]
device1="/dev/input/event4"
device2="/dev/input/event0"
while :; do
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
done
Result="$?"
if [[ "$Result" == "11" ]] then
input keyevent 85 #KEYCODE_MEDIA_PLAY_PAUSE
fi
done
..mapping looks like:
Code:
Mapping() { # "${ev_path/:}" "$ev_code" "$ev_value" "$deviceX1" "$deviceX2" (...)
if [[ "$1" == "$4" && "$2" == "0139" && "$3" == "00000001" ]] then
return 11 #Play/Pause
fi
# (…) and so on
}
is there any way to write
Code:
getevent -q -t -c 2 | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
to
Code:
getevent -q -t | grep -e "$device1" -e "$device2" | while IFS=' ' read -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2"
if [ -n "$?" ]; then
>>>> exit / break /what ever
fi
done
I tried it with “exit”, “break” and “return” (and “kill $PID”) but getevent didn't want to exit :'(
any ideas?
(pleas be clement with my grammar.. it's not my native language )
kind regards, Veit

[TERMINAL] Android 5.0+ am force-stop error !

Hi everyone !
When i write "am force-stop packagename" on terminal it gives this error. PLEASE HELP ME !
Try this:
ps | grep com.ps | grep nextapp.fx | awk '{print $2}' | xargs killpackage.name | awk '{print $2}' | xargs kill

Run bash script app

I' m trying to run a bash script.
I have a script and that script download 3 other scripts, and then, run them.
The first script, is the script where downloading 3 other scripts and running them.
The second script, is an example of the 3 other scripts.
So, which is the easiest way to do that ?
Is there any application where can do that ?
I use these scripts on android tv boxes.
The tv boxes are not rooted.
Also, i have an error with "wget: bad address"
Bash:
#!/bin/bash
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
sleep 1;
wget http://domain.com/files/script_2.sh -O /sdcard/scripts/script_2.sh
sleep 1;
wget http://domain.com/files/script_3.sh -O /sdcard/scripts/script_3.sh
sleep 1;
sh ./sdcard/scripts/script_1.sh
sleep 1;
sh ./sdcard/scripts/script_2.sh
sleep 1;
sh ./sdcard/scripts/script_3.sh
notify-send "Finish"
exit
Bash:
#!/bin/bash
wget https://domain.com/files/name.txt -O /sdcard/scripts/1.txt
cat 1.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 1_.txt
a=$(cat 1_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$a\[email protected]" /sdcard/scripts/file/filename1
sleep 2 ;
wget https://domain.com/files/name.txt -O /sdcard/scripts/2.txt
cat 2.txt | cut -c10- | awk -F "/a/" '{print $1}' | awk -F "/word" '{print $1}' | awk 'NR == 2' > 2_.txt
b=$(cat 2_.txt) && sed -i "[email protected]\(.*/a/\).*\(/word/.*m\)@\1$b\[email protected]" /sdcard/scripts/file/filename2
sleep 2 ;
find /sdcard/scripts/file/ -name "*.m" -printf '%T+ %p\n' | sort -r | xargs cat > /sdcard/scripts/file/filename.new
sleep 1 ;
sed -i '1i word' /sdcard/scripts/file/filename.new
sed -i '2i word' /sdcard/scripts/file/filename.new
sed -i '3i word' /sdcard/scripts/file/filename.new
sed -i '4i word' /sdcard/scripts/file/filename.new
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
DSA said:
domain.com is a web hosting site, so your http:// link is wrong - it needs to be your actual website
wget http://domain.com/files/script_1.sh -O /sdcard/scripts/script_1.sh
Click to expand...
Click to collapse
Sorry, i forgot to say that the "domain.com" is an example. I use correct domain in my script. Just i hide it in post, because i wouldn't to share it.
The script in linux works fine.
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
jwoegerbauer said:
May be the WGET what is implemented in your Android OS is faulty.
Here a workaround was shown.
Click to expand...
Click to collapse
Didn't work. Same error
"wget: bad address"

Categories

Resources