![]() Run the AWStats logresolvemerge and update tool You can edit the files by hand or throw some fancy sed commands at the files to remove any extraneous data. You also need to make sure they only contain data for one month. Things to note: You need to make sure that each of the log files you have just copied use the same format. This puts all of the domains log files for the month into a directory that we can use in the AWStats update command cp /path/to/apache/logs/current/* /tmp/apachelogs/ If you are doing the current month, then copy in the current apache log for that domain. Move into the /tmp/apachelogs/ directory, and run the gunzip command. Now unzip those files so they are usable. find /path/to/apache/logs/archive/ -name "-*" -newer /tmp/start -not -newer /tmp/end -exec cp '' /tmp/apachelogs/ \ You may need to create the /tmp/apachelogs/ directory first. Now we can use those files in the actual find command. touch -date YYYY-MM-DD /tmp/start touch -date YYYY-MM-DD /tmp/end Before we construct that command, we’ll need to create a couple of files to use for our start and end dates. We’ll use the find command to find the correct files. Now, a quick one-liner to grab all of the files within a certain date range and put their content in a new file. So the first problem is how to get the correct file name without having to look in each file to see if it has the right day? Fortunately for me, nothing touches these files after they are created, so their mtime (the time stamp of when they were last modified) is intact and usable. For me, each domain archives the days logs in the following format -access_log-X.gz and -error_log-X.gz where the X is a sequential number. This will work out to about 30 or 31 files (if the month is already past), or however many days have past in the current month. Get the Apache logs for the month.įirst step is to get all of the logs for each domain for the month. So, if the missing dates are in June, and it is currently August, you’ll need to remove the data files for June, July, and August (they look like this where MM is the two digit month and YYYY is the four digit year) to a temporary directory so they are out of the way. So we’ll need to move the more recent month’s stats to a temporary location out of the way. Move the data files of newer monthsĪWStats can’t run the update on older months if there are more recent months located in the data directory. Looks like I need to write a script… Step 1. ![]() This means I’ll have to do this process about 140 times. ![]() We have our Apache logs rotate each day for each domain on the server (or sub-directory that is calculated separately). Here’s how I have Apache set up, and the process I went through to get the missing days back into AWStats.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |