sxiii

Bash OneLiner To Check SWAP Space And Email If Not In Use

Mar 18th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.70 KB | None | 0 0
  1. # This is oneliner to check that SWAP space on current PC is less than 20 of usage.
  2. # If it is less, then it sends email from [email protected] address to [email protected] address
  3. # via the smtp.aaanet.ru server (change to your favourite) with subject "email-topic"
  4. # and text "email text". It is useful to check if server load drops or some application exited incorrectly.
  5.  
  6.  
  7. a=$(free | grep Swap | awk -F" " '{print $2}');b=$(free | grep Swap | awk -F" " '{print $3}'); c=$(echo "scale=2; $b/$a*100" | bc | awk -F. '{print $1}'); if [ $c -lt 20 ]; then sendemail -f from@email.com -t to@email.com -u email-topic -m "email text" -s smtp.aaanet.ru; fi
  8.  
  9. # Don't forget to change email addresses and smtp server if needed.
Advertisement
Add Comment
Please, Sign In to add comment