![]() This is unfortunate because our load balancer has two log files covering Timestamp processed to discard "already processed" records. $ cp -rf /usr/share/awstats/wwwroot/css /usr/share/awstats/wwwroot/icon/* /var/www/html/awstatsiconsĪnd store state on the filesystem between run. $ sudo chown awstats:awstats /var/lib/awstats To run the scripts as root) and copying the icon assets to the web server The setup by changing the permissions on /var/lib/awstats (we don't want We assume here the analyzer EC2 instance has read access to the $ sudo ausearch -ts today -i | grep 'denied.*' | audit2why Permission Denied when cron runs our upload script through logrotate. Might work fine when running from the command line and yet we get weird To S3 within the logrotate SE Linux context. One last step, we need to insure that our uploading script can connect + /usr/local/bin/dcopylogs -location s3:// mybucket -logsuffix=$INSTANCE_ID $LOGS We run more than one server in a load-balancer fashion, so we also addedĪn option to insert a log suffix on uploads, passing the Upload /var/log/nginx/ to s3://mybucket/var/log/nginx/ $ dcopylogs -location s3:// mybucket /var/log/nginx/mysite-access.log S3 bucket (see setup access control to S3 resources). We assume here the EC2 instance has write access to the mybucket Readily-available way to get that list of newly rotated files so we wrote What we really want is the list ofįiles created by the logrotate command. That's where we will put ourĪs the echo command shows, we will be passed the list of file Nginx as soon as possible and delay gzip afterwards. Since gzip might take a long time to complete, we want to re-up Postrotate script but we see here that it won't work since Many of the logrotate to S3 posts write to add your upload commands in the Renaming /var/log/nginx/mysite-access.log to /var/log/nginx/mysite-access.log-20160820Ĭreating new /var/log/nginx/mysite-access.log mode = 0664 uid = 995 gid = 992 $ sudo sh -c 'cat /var/log/nginx/~ | gzip -d > /var/log/nginx/mysite-access.log' $ sudo mv /var/log/nginx/ /var/log/nginx/~ Hence we restore the last rotated log, remove it, Our rotated log won't be compressed and we are not accurately testing thingsĪre working as expected. Furthermore inĭebug mode ( -d), no changes will be made to the logs, which means To test our setup we need a reliable way to trigger rotation. However, if none of the logs in the pattern require rotating, the scripts will The description of sharedscripts specifies bin/kill -USR1 `cat /run/nginx.pid 2>/dev/null` 2>/dev/null || true the names matching the patterns on the logrotate trigger) as $1 We find that the postrotate script is passed the names of the log files Searching for how to access the output file in postrotate That is rotated log filesĪre suffixed with the date of rotation, gzip compressed and the nginx Settings coming out of the box on Fedora. The nginx logs are currently rotated with logrotate using the default Nginx, in the open-source version, writes access requests to log files. The download those logs and process them with awstats. Today we are going to push the rotated logs to a S3 bucket,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |