Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
DISKAVAILABLE=$(df / | awk '{ a = $3 } END { print a }');
DISKUSED=$(df / | awk '{ a = $2 } END { print a }');
DISKTOTAL=$((DISKAVAILABLE+DISKUSED));
DISKPERCENTUSED=$(df / | awk '{ a = $5 } END { print a }');
MEMUSE=$(free -m | head -n 2 | tail -n 1 | awk {'print $3'});
MEMTOTAL=$(free -m | head -n 2 | tail -n 1 | awk {'print $2'});
SWAPUSE=$(free -m | head -n 3 | tail -n 1 | awk {'print $3'});
SWAPTOTAL=$(free -m | head -n 3 | tail -n 1 | awk {'print $2'});
# TODO - Execute curl command once per day via cron, cat file here
# TODAYSEXCUSE=$(cat ~/.daily_excuse)
#TODAYSEXCUSE=$(curl -silent http://pages.cs.wisc.edu/~ballard/bofh/bofhserver.pl | grep "The cause of the problem is"| { read x; echo "${x:198}"; });
TODAYSEXCUSE=$(nc bofh.jeffballard.us 666 | grep -v === | cut -f 4- -d " ")
echo "
System Summary (collected `date`)
- CPU Usage (average) = `top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}'`
- Memory Usage = $MEMUSE/$MEMTOTAL MB
- Swap Usage = $SWAPUSE/$SWAPTOTAL MB
- System Uptime/Load =`uptime`
- Disk Space (MB/GB/%) = `echo $(($DISKUSED/1024))`/`echo $(($DISKTOTAL/1024))` MB Used | `echo $(($DISKUSED/1024/1024))`/`echo $(($DISKTOTAL/1024/1024))` GB Used | `echo $DISKPERCENTUSED` Used
- Today's excuse = $TODAYSEXCUSE
" > ~/.system_report
sysreport() {
cat ~/.system_report
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment