Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # gather journal information in time frame
  4. export CRUFT=$(journalctl --since="$(date -d -1hours +\%F\ \%H):00:00" --until="$(date +\%F\ \%H):00:00" | grep -iE "Failed (pass|log)")
  5.  
  6. #email settings
  7. export EMAILFROM="From: Security Alert <yourmail@email.domain>"
  8. export EMAILSUBJECT="Subject: Failed login Summaries from $(date -d -1hours +\%H):00 to $(date +\%H):00"
  9. export EMAILALERTTO="your@email.domain"
  10.  
  11. if [ "x$CRUFT" != "x" ]; then
  12. echo -e "$EMAILFROM\n$EMAILSUBJECT\n\nFailed logins:\n$CRUFT" | ssmtp "$EMAILALERTTO"
  13. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement