Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.47 KB | None | 0 0
  1. #!/bin/bash
  2. LOG_FILE=/var/log/sample.log
  3. ERROR_FILE=errors_$(date +%d-%m-%y).log
  4. TO_EMAIL_ADDRESS=ops@example.com
  5. FROM_EMAIL_ADDRESS=from@example.com
  6. LIMIT_SIZE=10240
  7. ERROR_FILE_SIZE=du $ERROR_FILE
  8.  
  9. function get_errors {
  10.  
  11. grep ERROR $LOG_FILE |while read line
  12. do
  13.   echo $line >> $ERROR_FILE
  14. done
  15.  
  16. }
  17.  
  18. function send_mail {
  19.    
  20. }
  21.  
  22. function send_error_mail {
  23.  
  24. }
  25.  
  26. get_errors
  27.  
  28. if [[ $ERROR_FILE_SIZE -lt $LIMIT_SIZE ]]
  29.   then send_mail
  30. else
  31.   send_error_mail
  32. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement