logmonitor.sh 1.6 KB

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. DIRLOG=$(tac /var/log/apache2/access.log* | sort -k4)
  3. NETLOG=$(cat /var/log/auth.log*)
  4. if [ "$1" = "--help" ]
  5. then
  6. echo "--ip all IP address connections to apache"
  7. echo "--get all get requests to apache"
  8. echo "--post all post requests to apache"
  9. echo "--last show last 25 lines of apache log"
  10. echo "--common count connections per ip to apache"
  11. echo "--owncloud file uploads from users"
  12. echo "--vichan activity of vi chan"
  13. echo "--invalid-logins invalid login attempts"
  14. echo "--logins valid login attempts"
  15. fi
  16. if [ "$1" = "--ip" ]; then echo "$DIRLOG" | egrep -o '\b[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\b'; fi
  17. if [ "$1" = "--get" ]; then echo "$DIRLOG" | egrep "GET" | cut -d\ -f 1,4,7; fi
  18. if [ "$1" = "--post" ]; then echo "$DIRLOG" | egrep "POST" | cut -d\ -f 1,4,7 ; fi
  19. if [ "$1" = "--last" ]; then echo "$DIRLOG" | tail -25; fi
  20. if [ "$1" = "--common" ]; then echo "$DIRLOG" | tail -10000 | awk '{print $1}' | sort | uniq -c | sort -n | tail; fi
  21. if [ "$1" = "--owncloud" ]; then echo "$DIRLOG" | egrep "owncloud" | egrep "PUT" | cut -d\ -f 1,4,7; fi
  22. if [ "$1" = "--vichan" ]; then echo "$DIRLOG" | egrep "vichan" | cut -d\ -f 1,4,7; fi
  23. if [ "$1" = "--invalid-logins" ]; then echo "$NETLOG" | grep "Invalid"; fi
  24. if [ "$1" = "--logins" ]; then echo "$NETLOG" | grep "Accepted password"; fi