1

Topic: AWStats does not have any data

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.6
- Linux/BSD distribution name and version: CentOS 7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Apache
- Manage mail accounts with iRedAdmin-Pro? No
- Related log if you're reporting an issue:
====

New CentOS 7 server setup with clean install of iRedmail 0.9.5 (since updated 0.9.5.1>0.9.6). AWStats has never worked properly. When trying to log in using the credentials from the initial setup sent to me in the email titled "Subject: Details of this iRedMail installation" it will not authenticate. After changing valid-user to all granted in awstats.conf, I can see the awstats pages, but there is no data -- everything is zero's.

I would also add that any of the .png files in the www.mydomain.com/awstatats/icons/ path do not display.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: AWStats does not have any data

Do you have hourly cron job to update the statistics?

3

Re: AWStats does not have any data

I have the following cron jobs:

# iRedMail: update Awstats statistics for web
1   */1   *   *   *   /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=web -update >/dev/null

# iRedMail: update Awstats statistics for smtp
1   */1   *   *   *   /usr/bin/perl /usr/share/awstats/wwwroot/cgi-bin/awstats.pl -config=smtp -update >/dev/null

This was from the default installation.

4

Re: AWStats does not have any data

Any error if you run them manually?

5 (edited by gargoyle_ir 2017-02-15 00:48:11)

Re: AWStats does not have any data

A bit of a "DUH!" moment here.

Ran the cron job manually and got

Create/Update database for config "/etc/awstats/awstats.web.conf" by AWStats version 7.4 (build 20150714)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Direct access to last remembered record is out of file.
So searching it from beginning of log file...
Jumped lines in file: 0
Parsed lines in file: 0
 Found 0 dropped records,
 Found 0 comments,
 Found 0 blank records,
 Found 0 corrupted records,
 Found 0 old records,
 Found 0 new qualified records.

I realized that after setting up the defaults during the iRedmail installation I had configured virtual hosts in Apache and pointed to individual log files for each host. Naturally the default access_log would stay empty. After pointing awstats.web.conf to the correct log file, I ran the cron jobs again and it found the records.

Unfortunately, my original problem still remains. If I have the config.d file for awstats set with Require valid-user, it won't accept my credentials, but if I change it to grant all i can see awstats but there is still no data.

6

Re: AWStats does not have any data

gargoyle_ir wrote:

Unfortunately, my original problem still remains. If I have the config.d file for awstats set with Require valid-user, it won't accept my credentials, but if I change it to grant all i can see awstats but there is still no data.

"require all grant" is available in Apache 2.4, "Require valid-user" for Apache 2.2 and earlier versions.

Again, the data is generated by cron, if no data, check cron task and related awstats config file again.

7

Re: AWStats does not have any data

Data now displaying and icons showing properly after tweaking the awstats.conf (See below). From what I found in the Apache 2.4 documentation Require valid-user is still proper syntax.

#
Alias /awstatsclasses "/usr/share/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/share/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/share/awstats/wwwroot/icon/"
ScriptAlias /awstats/ "/usr/share/awstats/wwwroot/cgi-bin/"

DBDriver mysql
# Important note: use 'pass=' for MySQL, 'password=' for PostgreSQL.
DBDParams "host=127.0.0.1 port=3306 dbname=vmail user=vmail pass=[redacted]"

<Directory /usr/share/awstats/wwwroot/>
    DirectoryIndex awstats.pl
    Options ExecCGI

    AuthType Basic
    AuthName "Authentication required"
    AuthBasicProvider dbd
    AuthDBDUserPWQuery "SELECT password FROM mailbox WHERE username = %s AND isglobaladmin=1 LIMIT 1"

    Require valid-user
    # Require all granted
</Directory>

If I uncomment Require all granted, I get no prompt for authorization. It is pretty much open to the world. If I leave it as shown I am prompted for a username and password but the credentials for the global admin don't work. I have verified the postmaster@server.domain.com is a valid account and the password works.

8

Re: AWStats does not have any data

gargoyle_ir wrote:

If I uncomment Require all granted, I get no prompt for authorization.

Did you use both "require valid-user" and "require all granted"? You must enable one and disable the other.

9

Re: AWStats does not have any data

I only use one or the other, but not both.

I think I've found the problem. The password in vmail is stored as {SSHA} and from what I read Apache doesn't support it.

10

Re: AWStats does not have any data

That did not fix the issue.

To test this I created a temporary global admin account and tried to log in. Login failed. I then changed the password to {PLAIN} and verified password was correct by logging into Roundcube. Tried awstats login and again failed. I then removed the isglobaladmin requirement from awstats.conf like this:

DBDriver mysql
# Important note: use 'pass=' for MySQL, 'password=' for PostgreSQL.
DBDParams "host=127.0.0.1 port=3306 dbname=vmail user=vmail pass=[redacted]"

<Directory /usr/share/awstats/wwwroot/>
    DirectoryIndex awstats.pl
    Options ExecCGI

    AuthType Basic
    AuthName "Authentication required"
    AuthBasicProvider dbd
    AuthDBDUserPWQuery "SELECT password FROM mailbox WHERE username = %s"

    Require valid-user
    # Require all granted
</Directory>

And then restarted httpd service. Still failed. If i set Require all granted and comment out valid-user, then I (or anyone else) can see awstats without authentication. FWIW, Awstats is now updating correctly.

What am I missing?

11

Re: AWStats does not have any data

gargoyle_ir wrote:

I then changed the password to {PLAIN} and verified password was correct by logging into Roundcube.

Please use a salted MD5 password for the account you want to login to Awstats. Because Apache basic auth doesn't support some other password hashes.

12

Re: AWStats does not have any data

Perfect. All working now.

Bought you a whole pot of coffee. wink

13

Re: AWStats does not have any data

Thanks for the coffee. smile