FORUMS
Remove All Ads from XDA

A little sysinfo script for CLI

50 posts
Thanks Meter: 17
 
By oribunokiyuusou, Member on 10th May 2013, 10:42 AM
Post Reply Email Thread
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%)
The Following 10 Users Say Thank You to oribunokiyuusou For This Useful Post: [ View ] Gift oribunokiyuusou Ad-Free
 
 
10th May 2013, 07:30 PM |#2  
Member
Thanks Meter: 9
 
More
That is actually insanely useful. Wish I saw this a little earlier, it would of saved a lot of time.
13th May 2013, 02:07 PM |#3  
crancker's Avatar
Member
Thanks Meter: 31
 
More
Thumbs up
Thanks. This script just what I was looking for
The Following User Says Thank You to crancker For This Useful Post: [ View ] Gift crancker Ad-Free
30th July 2013, 11:07 AM |#4  
Junior Member
Flag Liverpool
Thanks Meter: 1
 
Donate to Me
More
Cheers i will try and get this to output via php for a little site i'm making for my pi.
2nd August 2013, 12:04 PM |#5  
Junior Member
Thanks Meter: 1
 
More
thx for sharing
29th September 2016, 11:04 PM |#6  
tgellen's Avatar
Junior Member
Thanks Meter: 22
 
More
Perfect
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes