Advertisement
Jailout2000

Apache/httpd Web Request Monitoring Script

Oct 29th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. LOG_DEFAULT_PATH="/var/log/httpd/access_log"
  4. LOG_PATH="$1"
  5.  
  6. if [ "$LOG_PATH" = "" ] && test -f "$LOG_DEFAULT_PATH"; then
  7.  
  8.   echo -e "\033[35mAuto-detected Log File: \033[32m$LOG_DEFAULT_PATH\033[0m"
  9.   LOG_PATH="$LOG_DEFAULT_PATH"
  10.  
  11. fi
  12.  
  13. if [ "$LOG_PATH" = "" ]; then
  14.  
  15.   echo -e "\033[32mUsage: $0 /path/to/apache/access_log\033[0m"
  16.  
  17. else
  18.  
  19.   # Without vhost:
  20.   (tail -n 500 -F $LOG_PATH | awk '{printf "\033[40;1;35m%s %s\033[0;37m %s %s \033[31m%s\033[36m %s\033[0m\n", $4, $5, $9, substr($6, 2), $7, $1}')
  21.   # With vhost:
  22.   #(tail -n 500 -F $LOG_PATH | awk '{printf "\033[40;1;35m%s %s\033[0;32m %s \033[37m%s %s \033[31m%s\033[36m %s\033[0m\n", $5, $6, $1, $10, substr($7, 2), $8, $2}')
  23.  
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement