Forum Moderators: DixonJones

Message Too Old, No Replies

Dynamic Log Filename Problem

Filename changes daily

         

Busynut

2:19 pm on Oct 24, 2002 (gmt 0)

10+ Year Member



Hello all,
I'm new here and have been learning a lot reading through the forums. I'm hoping someone will be able to point me in the right direction concerning my log files.

My new host provides Webalizer but the reports have been useless (referrers and country of origin info isn't showing up) - my host reports there is a "bug" and hasn't resolved it. Therefore, I have installed AWStats - which seems to work fine except I have to manually edit the configuration file each time I want to look at my stats. This is because the filename of my logs changes daily and they look like this:
mydomain.com.1035122400

I understand this file naming convention to be in "seconds." After requesting help at the AWStats forum, I amended the configuration file to request this:
mydomain.com.%NS

When I attempt to update the report I receive an error message as follows:
Error: Couldn't open server log file "/path tologs/mydomain.com.1035122400" : No such file or directory

The problem seems to be that AWStats is seeking a filename which is 36000 seconds (numerically) different than the actual daily filename. I've monitored this for a few days and the 36000 difference is consistent.

I requested additional help at the AWStats forum and was advised to: Use %NS-x and change x until it works.

Unfortunately, I don't understand what I'm supposed to do. The "x" (from what I understand of the AWStats documentation) may be in 'hours' rather than seconds. I did attempt to amend the "x" to 10 (meaning 10 hours the equivalent of 36000 seconds) and that doesn't work. I'm not a coder or programmer and I don't understand why AWStats is looking for another filename in the first place.

If someone is familiar with this file naming convention and AWStats perhaps you could help me. Or perhaps suggest a log analysis program that would automatically seek/find the correct daily file logs without manual intervention. Thanks for any assistance offered.

jatar_k

9:05 am on Oct 25, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] Busynut

That is a strange situation. I haven't personally used AWStats so am not familiar. You said the x value may be in 'hours' rather than seconds. Does that mean it must be in hours? Have you messed around with that value to see if you could correct it?

Busynut

4:39 pm on Oct 25, 2002 (gmt 0)

10+ Year Member



Thank you for your response. I don't actually know if "x" is supposed to be in hours, seconds, minutes, etc. I'm struggling with the examples provided in the documentation. This is the info available to me:

This is available tags :
# %YYYY-n is replaced with 4 digits year we were n hours ago
# %YY-n is replaced with 2 digits year we were n hours ago
# %MM-n is replaced with month we were n hours ago
# %DD-n is replaced with day we were n hours ago
# %HH-n is replaced with hour we were n hours ago
# %NS-n is replaced with number of seconds at 00:00 since 1970
# %WM-n is replaced with the week number in month (1-5)
# %WY-n is replaced with the week number in year (1-52)
# %DW-n is replaced with the day number in week (1-7, 1=sunday)
# use n=24 if you need (1-7, 1=monday)
# Use 0 for n if you need current year, month, day, hour...
# Example: "/var/log/access_log.%YYYY-0%MM-0%DD-0.log"
# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-24%MM-24%DD-24.log"
# You can also use a pipe if log file come from a pipe.
# Example: "gzip -d </var/log/apache/access.log.gz ¦"

As far as trying different things, I've tried using %NS alone, %NS-0 (as in example above); %NS-10 (10 hours equivalent of 36000 seconds); and %NS-36000. I always get a similar error message that AWStats is looking for a different filename. My log filename format is definitely in "seconds" - so that means I need to either use the %NS option on the list, or manually insert the daily filename. The problem with continuing to throw numbers in there just to see if they will work - is that I don't understand what it is I'm supposed to be asking the program to do. i.e. when I insert %NS-anything... is the 'dash' just a dash, does it mean 'minus,' does it mean 'equivalent,'. Sorry for my ignorance, but I'm not a programmer and do my best to understand.

I would gladly switch to another program - but I'll still have the same obstacle with the filename.
Any suggestions?

jatar_k

5:06 pm on Oct 25, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



# %NS-n is replaced with number of seconds at 00:00 since 1970

If I were to make an educated guess I would say that this is the one you should use. Your offset of 36000 would need to be inserted in place of the n. I have looked at this and turned it over in my head and am not totally sure about it though.

Is the logfile produced at the same time every day? When you were getting a standard offset of 36000 were you always trying to execute it at the same time of day?

If the software is doing the calculation from the time at this exact moment then it will only work when you execute it 10 hrs after the logs were produced. If you can get the exact time the logs are produced every night (and it is always the same time on the server) you should be able to set your end up to run at a measurable offset.

ie
logs are produced at 12:01 am every night
you schedule your logs at a 12 hr offset
they run at 10:01 am every day
result- 36000 second offset is always valid

Does this make sense?

Busynut

6:37 pm on Oct 25, 2002 (gmt 0)

10+ Year Member



Oh, dear, I think my brain is getting frazzled.

You've raised good questions and I don't have answers. I haven't taken the time to notice the date/time when the logs are initially produced (didn't think of it). But when they are - the filename stays the same for the whole day... then it gets replaced the next day (whenever the 'day' starts) with a new filename which is 86400 seconds numerically different, e.g.(filenames are preceded with my domain name):
10/15 - 1034640000
10/16 - 1034726400
10/17 - 1034812800
and so on.

Then, the prior day's log gets gzipped (sp?) and renamed.

The program (AWStats) doesn't do anything until I call the page in my browser and hit the link for "update now." (which I've done at different times of day). That's when it gives me the error message that it's looking for a different filename (which oddly enough has been consistently 36000 digits higher than the actual log file for that day).

The only way I've been able to see my statistics is to first to verify the filename for the day, then change the config file manually with the specific filename, upload it, and finally to click the "update now" link on the AWStats page in my browser.

I did try using: %NS-36000
The actual filename was: 103550400 and the error message was seeking a filename that was 905954400 - a very big difference!

So, to answer your question 'does it make sense?' - well, yes it makes sense but I have no idea how to implement it because I still don't understand what is happening.

What I'm wondering is - if I know the exact filename of a log... and use that as my 'base' - could the filename parameter somehow be 'scripted' to numerically change based on the 'base' filename + number of seconds automatically increasing each day? Maybe that doesn't make sense, and I've no idea how to do it.

I really appreciate you putting thought into this. I won't be able to be online again until tomorrow so hopefully I can digest your questions and perhaps come to a better understanding.

Busynut

6:02 pm on Oct 26, 2002 (gmt 0)

10+ Year Member



Sorry, I think my post above was very confusing. I have a tendency to over-complicate things.

Here's what I'm wondering:
The %NS-0 appears to be the available and appropriate tag to use for my filelogs. And from what I understand it means: 'get the filename showing number of seconds TODAY'. But since for some strange reason when the program goes looking for that filename it's not finding it because it's looking for something 10 hours (36000 seconds) different (higher).

So wouldn't it work if I knew how to ask it to:
'get the filename showing number of seconds (TODAY, MINUS 10 hours)'? .... i.e. %NS-0-10

I'm not a programmer [having admitted in earlier post I don't even know what the 'dash' means :) ] ... so I don't know the appropriate way of stating this. Perhaps I should seek out a perl programming forum?

jatar_k

6:19 pm on Oct 26, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



So wouldn't it work if I knew how to ask it to:
'get the filename showing number of seconds (TODAY, MINUS 10 hours)'? .... i.e. %NS-0-10

yes, that was what I was getting at in my post.

It is the syntax and timing of the request that will be the key.

As opposed to today, I would guess it is looking for NOW. So if it is 11:16 am right now and the log file was produced at 12:01 am I would need to subtract 11 hours and 15 min to get the right filename, which is 40500 seconds.

make sense? This is still guessing from the info you have given me.

Busynut

7:17 pm on Oct 26, 2002 (gmt 0)

10+ Year Member



hehehe.

Yes, this is making sense. But how to do?

The log files are only generated daily, so wouldn't I only need to figure out how to code for a single 24-hour period? Unfortunately, in looking at the times when the logfiles seem to be produced, I'm not sure this list is showing consistency, and perhaps I have to monitor the timing for a couple more days.

Here's some info:
Oct 19 23:43 mydomain.com.1034985600.gz
Oct 20 23:59 mydomain.com.1035072000.gz
Oct 21 23:16 mydomain.com.1035158400.gz
Oct 22 23:59 mydomain.com.1035244800.gz
Oct 23 23:59 mydomain.com.1035331200.gz
Oct 24 23:59 mydomain.com.1035417600.gz
Oct 25 23:55 mydomain.com.1035504000
Oct 26 18:08 mydomain.com.1035590400

From my other domain with the same host:
Oct 19 23:57 myotherdomain.com.1034985600.gz
Oct 20 23:59 myotherdomain.com.1035072000.gz
Oct 21 23:08 myotherdomain.com.1035158400.gz
Oct 22 23:54 myotherdomain.com.1035244800.gz
Oct 23 23:39 myotherdomain.com.1035331200.gz
Oct 24 23:21 myotherdomain.com.1035417600.gz
Oct 25 23:55 myotherdomain.com.1035504000
Oct 26 18:08 myotherdomain.com.1035590400

I hate it when I try to force my brain into fuzzy areas I know nothing about, but ... since the numerical sequence of filenaming seems more predictable than when the files are processed, is there a way to code for:

filename = (mydomain.com.1035417600 + (mathmatical equasion to automatically increase number of seconds by 86400 every 24 hour period))

Your turn, if you wish, my friend (I wouldn't blame you at all for going on to something more interesting!).
And thank you for the dialog on this!

jatar_k

7:22 pm on Oct 26, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



your filename= equation is exactly what you need to do but how to do it within the program is what I don't know.

I could easily script all of this but needing it to interface with the program makes it more difficult.

Do they have any kind of wildcard where you could just get the most recent file in a given directory and use a name like

mydomain.com.*

The * would represent any ending.

Busynut

7:50 pm on Oct 26, 2002 (gmt 0)

10+ Year Member



This is the documentation concerning filelog:

# "LogFile" contains the web server logfile to analyze.
# You can use a full path or relative path from awstats.pl directory.
# Example: "/var/log/apache/access.log"
# Example: "../logs/mycombinedlog.log"
# You can also use tags in this filename if you need a dynamic file name
# depending on date or time (Replacement is made by AWStats at the beginning
# of its execution). This is available tags :
# %YYYY-n is replaced with 4 digits year we were n hours ago
# %YY-n is replaced with 2 digits year we were n hours ago
# %MM-n is replaced with month we were n hours ago
# %DD-n is replaced with day we were n hours ago
# %HH-n is replaced with hour we were n hours ago
# %NS-n is replaced with number of seconds at 00:00 since 1970
# %WM-n is replaced with the week number in month (1-5)
# %WY-n is replaced with the week number in year (1-52)
# %DW-n is replaced with the day number in week (1-7, 1=sunday)
# use n=24 if you need (1-7, 1=monday)
# Use 0 for n if you need current year, month, day, hour...
# Example: "/var/log/access_log.%YYYY-0%MM-0%DD-0.log"
# Example: "C:/WINNT/system32/LogFiles/W3SVC1/ex%YY-24%MM-24%DD-24.log"
# You can also use a pipe if log file come from a pipe.
# Example: "gzip -d #
LogFile="/var/log/httpd/mylog.log"

Based on the list of 'available' tags, I don't know what to suggest. It would be so much easier if I could just have the logfiles automatically renamed every day - and then I'd be able to use the existing tags. Hmmmm... would doing that create any kind of problem/issue on my server?

I'd ask my host some of these questions, but there is a language barrier - as I found out from already attempting detailed communication. e.g.

Me: I just installed AWStats on my website and wanted to let you know...
Host: I'm sorry, no, we cannot install AWStats for you.

:)
I'll also try posting again at the AWStats forum to see if I can possibly get another response.

Busynut

3:48 pm on Oct 29, 2002 (gmt 0)

10+ Year Member



Just wanted to say there's been no further support/response at the AWStats forum... I might fiddle with the log filename a little more but I'm searching for another program that might be able to recognize the filename without so much trouble. Thanks very much for your input!