#!/bin/bash
datetime=`date +%Y%m%d%H%M%S`
reportfile=/tmp/reportfile$datetime

IP=`ifconfig eth0 | grep "inet" | grep "netmask" |sed 's/^.*inet //g' |sed 's/ netmask.*$//g'`
echo "server IP (in): "$IP >> ${reportfile}
OIP=`curl ip.6655.com/ip.aspx`
echo "server IP (out): "$OIP >> ${reportfile}

WIP=`ifconfig wlan0 |grep "inet" | grep "netmask" |sed 's/^.*inet //g' |sed 's/ netmask.*$//g'`
echo "server IP (wlan): "$WIP >> ${reportfile}

cpu_idle=`top -b -n 1 | grep Cpu | awk '{print $6}' | cut -f 1 -d "."`
echo "server Cpu_idle : "$cpu_idle >> ${reportfile}

swap_total=`free -m | grep Swap | awk '{print $2}'`
echo "server swap_total : "$swap_total >> ${reportfile}

swap_free=`free -m | grep Swap | awk '{print $4}'`
echo "server swap_free : "$swap_free >> ${reportfile}

swap_used=`free -m | grep Swap | awk '{print $3}'`
echo "server swap_used : "$swap_used >> ${reportfile}

cat ${reportfile} | mutt -s "raspberry pi_report" frogchou@163.com

