Skip to content

Instantly share code, notes, and snippets.

@koduki
Created January 10, 2010 17:11
Show Gist options
  • Save koduki/273618 to your computer and use it in GitHub Desktop.
Save koduki/273618 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# use
# watch ./top.sh
#
OUT="/tmp/topdata"
echo "---- cpu ----" >> $OUT
mpstat -P ALL|awk 'NR > 3 {print "CPU("$2"): \t"$3"% usr,\t"$4"% nice,\t"$5"% sys,\t"$6"% iowait"}' > $OUT
echo "---- memory ----" >> $OUT
free -m|awk '{print $1"\t"$2"MB total,\t"$3"MB used, \t"$4"MB free" }'|grep -e "Mem" -e "Swap" >> $OUT
echo "---- disk I/O ----" >> $OUT
iostat -k|awk 'NR > 5 && $1 != "" {print $_}' >> $OUT
echo "---- network ----" >> $OUT
netstat -i |awk 'NR > 1 {print $_}' >> $OUT
echo "---- process ----" >> $OUT
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND" >> $OUT
ps aux|sort -n -k 3 -r|head -5 >> $OUT
cat $OUT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment