Webalizer 在摘要頁面上僅顯示 2 個月(Ubuntu 14.04)

Webalizer 在摘要頁面上僅顯示 2 個月(Ubuntu 14.04)

Webalizer 過去常常在起始頁的摘要、圖形概述以及本月和之前 11 個月的連結清單中顯示 12 個月。這至少在 Ubuntu 10.04 和 12.04 中是開箱即用的,我只需要配置增量模式來處理我的每日(而不是每月)日誌檔案。

將兩個網站遷移到 14.04 後,我發現 webalizer 弄亂了摘要,在某種程度上它在圖形概述中只顯示了兩個月,其他月份的 10 個插槽是空的。連結列表僅顯示相同的兩個月(本月和上個月)。如果我省略五月和六月的日誌數據,我會得到三月和四月——同樣只有兩個月。

我嘗試省略增量模式(使用預設設定檔)並為 webalizer 提供一個包含 30 個月日誌的日誌檔案。這導致 webalizer 創建了 5 月 11 次和 6 月 1 次的摘要圖形和連結清單。

需要注意的是:每月的統計數據看起來都是正確的,即使是三個月或更長時間前的統計數據,我也只需手動輸入 2 個多月前的任何統計條目的 URL。

我在網上搜尋了“webalizer”、“兩個月”、“僅”等任意組合,只發現了一個這樣的問題 - 但沒有任何答案。

大家有什麼想法嗎,出了什麼問題或我可能做錯了什麼?

好的,當然您想更準確地了解我所嘗試的內容,因此我將提供我所嘗試的命令列範例:

$ logdir=/path-to-logdir
$ ls $logdir
...
2015.0617-access.log.gz
2015.0618-access.log.gz
2015.0619-access.log.gz
$ outputdir=/path-to-webroot/statistics
$ rm $outputdir/*
$ for logfile in $logdir/*-access.log.gz;  do webalizer -r http://$hostname -n $hostname -o $outputdir $logfile;  done
... lots of verbose output about webalizer's activity
... last of it being:
Webalizer V2.23-08 (Linux 3.13.0-55-generic x86_64) locale: htm*
Using logfile /path-to-logdir/2015.0619-access.log.gz (gzip-clf)
Creating output in /path-to-webroot/statistics
Hostname for reports is 'myhostname'
Reading history file... webalizer.hist
Reading previous run data.. webalizer.current
Saving current run data... [06/19/2015 23:27:09]
Generating report for June 2015
Saving history information...
Generating summary report
20 records in 1 seconds, 20/sec
$ 

這導致總共只有兩個月的摘要,但創建了每月摘要(即使是超過 2 個月的摘要)並可透過手動輸入的 URL 進行存取。

另一種嘗試(一次所有資料 - 非增量)是:

$ zcat $logdir/*-access.log.gz >/tmp/access.log
$ rm $outputdir/*
$ webalizer -r http://$hostname -n $hostname -o $outputdir /tmp/access.log
... lots of verbose output just as before
$ 

結果相似,但總摘要有 11 個 5 月條目和 1 個 6 月條目。

誰能幫助獲得正確的摘要?

謝謝你,湯姆湯姆湯姆

================================================== = =編輯:我已經糾正了一些拼寫錯誤,並且我做了更多測試

在超過 24 小時內沒有一個答案或評論 - 看起來這個 webalzer 的東西不是那麼突出。嗯,這就是我所做的:

  • 我將日誌檔案複製到全新安裝的 14.04 筆記本上 - 相同的結果
  • 我刪除了 14.04 的 apache 建立的日誌檔案 - 相同的結果
  • 我獲取了 webalizer 的源代碼並在兩台不同的 14.04 機器上編譯了它 - 這一台終於可以工作了。

這是否意味著 Ubuntu-14.04 的 webalizer 軟體包已損壞?現在已經超過一年了嗎?難以置信。

如果沒有人能解釋出了什麼問題,至少對於那些尋找 webalizer 摘要問題的人來說 - 你會發現這不是你一個人的問題。

我會很高興聽到其他人遇到類似的 webalizer 問題 - 當然更高興的是,如果有人能給我指出一個不需要編譯 webalizer 原始碼的解決方案。

謝謝你!

湯姆湯姆湯姆

答案1

這是一個已知的錯誤,並且有一個補丁:https://bugs.launchpad.net/ubuntu/+source/webalizer/+bug/1471387

答案2

好吧,我也有同樣的問題,不過是 Fedora 盒子。而且也沒有解決方法。我使用基於我在以下位置找到的腳本的“解決方法”http://stevehavelka.com/rebuilding-broken-webalizer-history-tcl/,用它重新建立歷史文件。它很髒,是複製貼上式的,但它確實有效。至少一個月(即,直到 webalizer 重新建立索引頁並覆蓋歷史文件):

#!/bin/sh
#Using this script is straightforward:
#
# 1. Run it within the folder that has your old webalizer files, and it produces as much historical data as it can.
# 2. Copy/paste that historical data into your webalizer.hist file, and rerun Webalizer.
# 3. That’s it!  You should have all your stats back.
#
# the next line restarts using tclsh \
exec tclsh "$0" "$@"

# first, find the right files
foreach file [lsort -decreasing [glob usage_*.html]] {

    # and get the date from the files
    regexp {usage_(\d{4})(\d\d).html} $file -> year month

    # open the file to get some data from it
    set fh [open $file r]
    set text [list]
    while { ![eof $fh] } {
        lappend text [gets $fh]
    }
    close $fh

    # now start pulling out data with Total Hits
    set idx [lsearch -glob $text {*Total Hits*}]
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalHits

    # Total Files
    set idx [lsearch -glob $text {*Total Files*}]
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalFiles

    # Total Unique Sites
    set idx [lsearch -glob $text {*Total Unique Sites*}]
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalUniques

    # Total kB Files
    set idx [lsearch -glob $text {*Total kB Files*}]
    if { $idx == -1 } {
        set idx [lsearch -glob $text {*Total KBytes*}]
    }
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalKb

    # Process days
    set first [lsearch -glob $text {*Daily Statistics for*}]
    set last [lsearch -glob $text {*Hourly Statistics for*}]
    set subtext [lrange $text $first $last]
    set dates [lsearch -glob -all -inline $subtext {<TR*><TD ALIGN=center><FONT SIZE="-1"><B>*</B></FONT></TD>}]

    # First day processed
    regexp {<B>(\d+)</B>} [lindex $dates 0] -> firstDay

    # Last day processed
    regexp {<B>(\d+)</B>} [lindex $dates end] -> lastDay

    # Total Pages
    set idx [lsearch -glob $text {*Total Pages*}]
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalPages

    # Total Visits
    set idx [lsearch -glob $text {*Total Visits*}]
    regexp {<B>(\d+)</B>} [lindex $text $idx+1] -> totalVisits

    # and that's it!
    puts "[string trimleft $month 0] $year $totalHits $totalFiles $totalUniques $totalKb $firstDay $lastDay $totalPages $totalVisits"

}

如上所述,將此腳本放入包含統計摘要的目錄中,執行它並將結果複製並貼上到 webalizer.hist 檔案中。就這樣吧。

這可能意味著將歷史記錄寫回歷史文件中無法如預期運作。由於我不知道在原始程式碼中應該在哪裡查看,我希望其他人可以對這個問題有更多的了解......歡迎任何建議。

相關內容