Setting up Webalizer log file analysis
Introduction
Webmin has a module for Webalizer that will report web usage on the linux system. Most often, the install of Webmin will already have a working module of Webalizer. However, there are times when the log files may change location or are become available after Webmin was setup.
In this topic, we will cover how to process web log files stored on a local host as well as web logs from a remote host. Once processed, we will then go through the steps on how to make the reports available through Apache.
Here are the steps to point Webalizer to the new log file locations.
Creating a report from local web log files not loaded by default.
Finding the log path for the Linux system can be located in the Apache Webserver module of Webmin, it is listed under Servers. From here the Existing virtual hosts tab will be available with a Default Server listed along with any additional virtual hosts.
In my example, I only have the Default Server, so I’ll click on it. In the upper section is a Log Files icon, I’ll click on that as well.
This will list all of the logs associated with the virtual host. I’ll be using the Ascess log files for Webalizer. Make a note of the path listed in File or program. Now we are ready to add that definition in Webalizer.
Click on the Webalizer Logfile Analysis module under Servers in Webmin. In the log file list, I can see that the path and log file I found just a moment ago isn’t listed. I do have another log file defined. Lets look at that first to use as a reference.
Now we’ll add our new log file to Webalizer.
Return to the log file list, there is a link at the bottom of the page in Webmin. You will see an option to Add a new log for analysis, click it.
Enter in the path found earlier in the Base logfile path. Set all other options to match the example found in the existing log file example and click Create.
Now the log entry should be available with the other logs listed in the Webalizer module. Let’s click on our newly created log entry. Now you should see the log files listed. At the bottom of the log file entry should be a Generate Report button, click it.
Webmin will process the log files and generate a report. You can view this report or look at it later. Return to the log file list.
Now we will view the report, click the log entry. Click the View Report button at the bottom of the page. The report should appear.
You can drill down through the months to get more granular information.
Generating log reports from external web hosts.
In this example, we will copy the web logs from a hosted Linux web site to the Webalizer system for analysis. Linux systems default to the Apache web log format, so in most cases these procedures should work. As always, be prepared to massage the data.
The web logs files I have to work with are stored on a hosted Linux web site in a folder that FTP and SFTP cannot reach. This is the 1st hurdle because I won’t be able to automate the process as easily. However, the log files can be access through the hosting providers web control panel and downloaded.
The log files in my example are retained for a month and one week. The 2nd hurdle is that I’m not able to bulk download all of the files. It takes about 10-15 minutes to download all of the log files.
Now that all the individual log files have been downloaded, they will need to be concatenated. This is the 3rd hurdle because Webalizer would need to be set to read each log file individually.
Once the log file has been created, copy it to the Webalizer host using SFTP. Now Webalizer can be pointed to the log file and setup like any locally stored web log. After generating the report, it can then be viewed to show all the obscured information.
Making the report available to view from a browser is the next step.
Web Reports
The Webalizer Logfile Analysis section in Webmin has our definition for what logs to process, were to store reports, how to process the logs, and at what interval to process them.
Defining the Write report to directory in our existing definition is key. Choose a directory that doesn’t have sensitive information in any sub folders. In this example, we’ll define this path as the directory to write the report to.
/var/www/webalizer
That’s all that needs to be configured on Webalizer. The reports are on a schedule, so the information should update accordingly.
Setting up Apache to display the reports on a browser is a matter of defining the report directory and creating an alias. Most information online steps through editing the Apache config file. We’ll use Webmin to do the same thing.
In Webmin go to Servers / Apache Webserver and click the Default Server. You could define the alias on other virtual hosts, but I wanted to keep this as simple as possible. However, the steps would be the same.
Create a Per-Directory Option and set the path. In our example it is
/var/www/webalizer
Next click the Alias and Redirects link. In the Document directory aliases, set the From and To fields as such. Then click Save.
The Apache web service will need to be restarted so that the changes on the Apache config will take place. You can reboot the system or restart the Apache service.
Once that is done, you should now be able to browse directly to the Webalizer reports. In our example, the web URL would be http://system_ip/webalizer.
That covers how to add additional web logs to the default instance of Webalizer.