Skip to content

Instantly share code, notes, and snippets.

@snicol
Created December 20, 2011 16:50
Show Gist options
  • Save snicol/1502262 to your computer and use it in GitHub Desktop.
Save snicol/1502262 to your computer and use it in GitHub Desktop.
shell sidebar
# A activity monitor for weather, hd, ram and cpu. Cool using it as a tmux
# sidebar or something. Not great code, but fun to make! Change the
# weather function to whatever you need it.
#!/bin/sh
red='\e[0;31m'
RED='\e[1;31m'
blue='\e[0;34m'
BLUE='\e[1;34m'
cyan='\e[0;36m'
CYAN='\e[1;36m'
NC='\e[0m' # No colour
function weather {
wget http://www.google.com/ig/api?weather=banbury -O wr.dat -q
result=$(cat wr.dat | awk {'print substr($L, index($L,"temp_c data")+13, 2)"C in Banbury"'})
echo -e ${blue}$result${NC}
}
function hd_space {
result=$(df -H / | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }')
echo -e ${blue}$result${NC}
}
function cpu_usage {
result=$(uptime | awk -F'load average:' '{ print $2 }')
echo -e ${blue}$result${NC}
}
function memory_usage {
freemem=$(free -t -m | grep "Total" | awk '{ print $2 }')
freex=$(free -t -m | grep "Total" | awk '{ print $3 }')
freey=$(free -t -m | grep "Total" | awk '{ print $4 }')
echo -e ${blue}Total memory: $freemem MB${NC}
echo -e ${blue}Used memory: $freex MB${NC}
echo -e ${blue}Free memory: $freey MB${NC}
}
while [ 1 ]; do
clear
echo -e "${RED}Current weather:${NC}"
weather
echo -e ${RED}Disk usage:${NC}
hd_space
echo -e ${RED}Load averages:${NC}
cpu_usage
echo -e ${RED}Memory usage:${NC}
memory_usage
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment