Skip to content

Instantly share code, notes, and snippets.

@meresmclr
Created September 2, 2016 06:19
Show Gist options
  • Save meresmclr/b0900c3210430cda897132c39aa7c3d1 to your computer and use it in GitHub Desktop.
Save meresmclr/b0900c3210430cda897132c39aa7c3d1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# reference: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=23440
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm" "$days" "$hours" "$mins" `
# get the load averages
read one five fifteen rest < /proc/loadavg
#compute Available Free Memory
MemFreeMB=$(cat /proc/meminfo | grep MemFree | awk {'print int($2/1000)'})
MemBuffMB=$(cat /proc/meminfo | grep Buffers | awk {'print int($2/1000)'})
MemCachMB=$(cat /proc/meminfo | grep ^Cached | awk {'print int($2/1000)'})
AvailMemMB=$(($MemFreeMB + $MemBuffMB + $MemCachMB))
echo "
Uptime.............: ${UPTIME}
Memory.............: "$AvailMemMB"MB (Available) / `cat /proc/meminfo | grep MemTotal | awk {'print int($2/1000)'}`MB (Total)
Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
Running Processes..: `ps ax | wc -l | tr -d " "`
Free Disk Space....: `df -P -BM | grep -E -m 1 '^/dev/sda1 ' | awk '{print $4 }' | awk -F '.' '{ print $1 }'` on /dev/sda1
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment