View Single Post
  #50  
Old 20th February 2011, 19:04
Undo Undo is offline
Junior Member
 
Join Date: Nov 2010
Posts: 19
Thanks: 4
Thanked 2 Times in 2 Posts
Default

Quote:
Originally Posted by hopoo View Post
This is my short Tip of traffic analysis.
debian + Nginx + vlogger + ispconfig3.0.3

]# vi /etc/nginx/conf.d/ispconfig.conf
log_format combined_ispconfig '$server_name $remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log /var/log/nginx/vhost.access.log combined_ispconfig;

]# vi /root/bin/my_nginx_log_analysis.sh
#!/bin/sh

VHOST_LOG_FILE=/var/log/nginx/vhost.access.log
LOG_DIR=/var/log/ispconfig/httpd

/usr/bin/tail -f $VHOST_LOG_FILE | /usr/local/ispconfig/server/scripts/vlogger -s access.log -f 300 -t "%Y%m%d-access.log" -d "/etc/vlogger-dbi.conf" $LOG_DIR

]# vi /etc/logrotate.d/nginx
/var/log/nginx/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
prerotate
/usr/bin/killall tail
endscript
postrotate
[ ! -f /var/run/nginx.pid ] || kill -USR1 `cat /var/run/nginx.pid`
/usr/bin/nohup /root/bin/my_nginx_log_analysis.sh&
endscript
}

Waiting for feedbacks.
I see a problem with your way to handle it : what happens if the tail -f process is being killed for any reason ? Especially, what happens if you reboot your server in the middle of the day ? It will stop logging for half a day ...
Reply With Quote