Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Store path to commands
  4. LOGGER=/usr/bin/logger
  5. FILE=/opt/app/ebanking/logs/bussines.log
  6.  
  7. # Store email settings
  8. AEMAIL="eder.marcel@slsp.sk"
  9. ASUB="ERROR LINE - $(hostname)"
  10. AMESS="Warning - errors found on $(hostname) @ $(date). See log file for the details /opt/app/ebanking/logs/error.log"
  11. OK_MESS="OK: NO ERROR Found."
  12. WARN_MESS="ERROR: Error Found."
  13.  
  14.  
  15. # Check if $FILE exists or not
  16. if test ! -f "$FILE"
  17. then
  18. echo "Error - $FILE not found or mcelog is not configured for 64 bit Linux systems."
  19. exit 1
  20. fi
  21.  
  22. # okay search for errors in file
  23. error.log=$(grep -c -i "ERROR" $FILE)
  24.  
  25. # error found or not?
  26. if [ $error.log -gt 0 ]
  27. then # yes error(s) found, let send an email
  28. echo "$AMESS" | email -s "$ASUB" $AEMAIL
  29. else # naa, everything looks okay
  30. echo "$OK_MESS"
  31. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement