Skip to content

Instantly share code, notes, and snippets.

@jeffballard
Forked from jakimfett/system-report.sh
Last active February 7, 2016 18:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffballard/bd4b4b0419fe9fd8f9f5 to your computer and use it in GitHub Desktop.
Save jeffballard/bd4b4b0419fe9fd8f9f5 to your computer and use it in GitHub Desktop.
#!/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