eldy / AWStats

AWStats Log Analyzer project (official sources)
https://www.awstats.org
364 stars 121 forks source link

Path to conf files #156

Closed Olivier-Boudeville closed 4 years ago

Olivier-Boudeville commented 4 years ago

Hi, (using awstats 7.7 (build 20180105) from Arch Linux) a problem with awstats.pl is that its documentation states that:

Config files (awstats.virtualhostname.conf or awstats.conf) must be in /etc/awstats, /usr/local/etc/awstats, /etc or same directory than awstats.pl script file.

In my use case, these configuration files are generated by the webserver itself at startup, which runs on purpose with low privileges, and is thus unable to write in these system directories. Luckily the doc hints that:

If not found, awstats tries to read awstats.conf, and finally the full path passed to -config=

This is neat and using for example -config=/var/local/MY_APP/data/awstats-vhost-configs/awstats-for-foobar.org.conf works, yet in the corresponding generated HTML report some links are incorrect as the specified config path is included "as is", ex: http://URL/awstats./var/local/MY_APP/.data/awstats-vhost-configs/awstats-for-foobar.org.confallrobots.html; so they point to an HTML file that does not exist.

I guess the same problem prevents the generation of these files (nevertheless awstats.pl does not report any error then).

dariodsa commented 4 years ago

If you inspect the generated static html, then you can see that links are in relative form, not absolute. So if you place you generated html on the same server anywhere, links would work. <a href="/awstats/awstats.pl?config=/usr/local/awstats/awstats.Dario.conf&amp;output=lasthosts" target="awstatsbis">Last visit</a> If you want to generate them, that would be a huge problem. Imagine you have a statistics with a huge number of months. You would need to generate them, then for each month, list of users, browers, etc. Static html are useful if you want to for example make a automated generated PDF from it. Hope it helps.

Olivier-Boudeville commented 4 years ago

Hi, Thanks for your answer! Using the Awstats versions in Arch (7.7 - no reason to think they behave differently from the upstream ones), I definitively could see that absolute links such as the ones I copied-pasted in my first message were present in the generated links. I think you could not reproduce the problem because you must have specified -config=Dario; if instead you specify some absolute path (ex: -config=/var/www/something.conf) then you should see the problem. What I also wanted to achieve with Awstats was to avoid the use of cgi-bin scripts by running regularly (ex: every two days) the report generation, so that a "recent" version of it was always available. I was supposing that each access log was read once (i.e. that, once read, it was stored in Awstate state files such as awstats052020.*txt), and thus that only the HTML pages had to be generated every two days (which seems light, notably using the awstats_buildstaticpages.pl script which takes care of all pages at once). But maybe I am wrong and over time the generation of pages demands always-increasing efforts rather than rather constant ones (just to deal for the 2 additional days)? Last question I had was whether there was a risk if spawning multiple instances of Awstats (for different websites) simultaneously. Are the Awstats state files protected against concurrent accesses? (I am not completely sure but I would think it is not the case). I hope this additional information helps clarifying a bit the questions raised. Thanks again! Olivier.

dariodsa commented 4 years ago

Apply last two of my commits in my repo (https://github.com/dariodsa/awstats/commits/develop) and it should work. Dario

Olivier-Boudeville commented 4 years ago

Hi, Thanks for the update; it tried to do a bit of testing. After having just cloned dariodsa/awstats.git (git log tells me I have the commit 621d7e71f49) and used the 'develop' branch, I ran: $ /home/dilbert/Software/awstats/awstats-from-dariodsa/wwwroot/cgi-bin/awstats.pl -config=/usr/local/etc/awstats/awstats.foobar.localhost.conf -output -staticlinks

Apparently the links were still incorrect, for example I had in the generated HTML: Links from an external page (other web sites except search engines) a href="awstats./usr/local/etc/awstats/awstats.foobar.localhost.conf.refererpages.html" target="awstatsbis" Full list (I removed the markup, which was interpreted by Github and led to a scrambled output)

I also tried (still from /home/dilbert/Software/awstats/awstats-from-dariodsa/):

$ ./tools/awstats_buildstaticpages.pl -config=/usr/local/etc/awstats/awstats.foobar.localhost.conf -dir=/tmp/test-awstats -staticlinks -awstatsprog=/home/dilbert/Software/awstats/awstats-from-dariodsa/wwwroot/cgi-bin/awstats.pl
[...]
Error: Couldn't open config file "awstats./usr/local/etc/awstats/awstats.foobar.localhost.conf.conf" nor "awstats.conf" after searching in path "/home/dilbert/Software/awstats/awstats-from-dariodsa/wwwroot/cgi-bin,./tools/,/etc/awstats,/usr/local/etc/awstats,/etc,/etc/opt/awstats": No such file or directory.

So it looks the issue is still there. Hopefully I did not make any silly mistake!

BTW: was I right regarding the near-constant cost of performing update+generation periodically (supposing constant traffic) and the fact that concurrent runs of Awstats shall not be attempted?

Thanks, Olivier.

dariodsa commented 4 years ago

Try now.

Olivier-Boudeville commented 4 years ago

Hi, I performed only a brief test after a pull, yet the output of both scripts look good to me. Just the final line output by awstats_buildstaticpages.pl is still incorrect:

[...]
23 files built.
Main HTML page is 'awstats./usr/local/etc/awstats/awstats.foobar.localhost.conf.html'.

So I guess we can close this issue now. Thanks!