Awstat not working

Discussion in 'Installation/Configuration' started by francoisPE, Apr 8, 2022.

  1. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Hello,
    I have a multiserver setup ispc3.2.7p1
    I have exactly that same problem
    https://www.howtoforge.com/community/threads/awstats-not-working.85904/
    Calling
    Code:
    php cron_debug.php --cronjob=150-awstats.inc.php
    returns with no delay and no error messages ("finished cron debug.") and no stats are written. There are no error messages in /var/log/syslog, /var/log/messages, /var/log/ispconfig/cron.log, /var/log/ispconfig/cron.log or /var/log/ispconfig/ispconfig.log.
    There are config files for the webhosts in /etc/awstats and when I run AWStats directly on its own with
    Code:
    /usr/share/awstats/tools/awstats_buildstaticpages.pl -config=MYDOMAIN.COM -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=/var/www/clients/clientXX/webXX/web/stats
    AWStats generates the reports.

    in 2020, there were a problem of webserver.
    I don't have any...

    Any idea where to look at ?
     
  2. Taleman

    Taleman Well-Known Member HowtoForge Supporter

  3. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Hello,
    That's true, awstats start to bug with upgrade to v3.2.7p1.
    So I checked what Jesse said : "You might check what server plugins are enabled, perhaps there's one for awstats that hasn't been enabled?". I looked system> server config > awstats. It seems to be configured correctly.
    upload_2022-4-8_21-34-7.png

    I try `grep -r awstat /var/log/*` Empty answer.
    How can I check debug log in that particular case?
    I don't know how is managed awstat process...
    As I said,
    Code:
    /usr/share/awstats/tools/awstats_buildstaticpages.pl -config=MYDOMAIN.COM -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=/var/www/clients/clientXX/webXX/web/stats
    works
    It seems ispconfig manage it with a cron.d, but,
    more /etc/cron.d/awstats
    gives
    Code:
    #MAILTO=root
    #
    #*/10 * * * * www-data [ -x /usr/share/awstats/tools/update.sh ] && /usr/share/awstats/tools/update.sh
    #
    ## Generate static reports:
    #10 03 * * * www-data [ -x /usr/share/awstats/tools/buildstatic.sh ] && /usr/share/awstats/tools/buildstatic.sh
    
    and grep -r awstats_buildstaticpages /etc/cron.d/* gives nothing...

    It seems to be in server/lib/classes/cron.d/150-awstats.inc.php
    But clearly above my php level...
     
    Last edited: Apr 8, 2022
  4. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Today it no more works !
    Any idea to re configure ? Run ispc update ?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Are the acces logs visible and contain recent data in the folder /var/www/yourdomain.tld/log/ ?
     
  6. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Yes
    when I run
    Code:
    /usr/share/awstats/tools/awstats_buildstaticpages.pl -config=MYDOMAIN.COM -update -awstatsprog=/usr/lib/cgi-bin/awstats.pl -dir=/var/www/clients/clientXX/webXX/web/stats
    it builds 23 files...

    Can I move to webalizer and move back to awstats without killing everything ?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Stats will get reset when you change the web statistics software.
     
  8. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Is there another way to "reinstall" awstat ?
    Currently, I have no stats...
    May be I can copy files to keep datas ?
     
    Last edited: Apr 11, 2022
  9. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Change it to a different stats package, then back to awstats.
     
  10. francoisPE

    francoisPE Active Member HowtoForge Supporter

    I am doing that.
    Let's see !
     
  11. francoisPE

    francoisPE Active Member HowtoForge Supporter

    Unfortunately, I move to webalizer. Stay one day. But I have no webalizer results... In folder, still awstat results !

    I set back awstats : I'll wait 24h more but I am not very optimistic !

    Is there a way to reset, such as `rm /stats/ directory`
     
    Last edited: Apr 12, 2022
  12. francoisPE

    francoisPE Active Member HowtoForge Supporter

    I did a lot of tests, restarts and so on. It still doesn't work.

    I am to the conclusion that something in not working on a daily basis.
    I run
    Code:
     php /usr/local/ispconfig/server/cron_debug.php  --cronjob=150-awstats.inc.php
    It generates awstats results
    I turn server log to DEBUG and I see that
    Code:
    root@ns:/var/log/ispconfig# ls -lrt
    total 3472
    drwxr-xr-x 5 root      root         4096 Jul  1  2021 httpd
    -rw-r--r-- 1 root      root           34 Mar 14 00:04 ispconfig.log.9.gz
    -rw-r--r-- 1 root      root         4484 Mar 14 00:04 cron.log.9.gz
    -rw-r--r-- 1 root      root           29 Mar 14 00:04 auth.log.9.gz
    -rw-r--r-- 1 root      root           34 Mar 15 00:04 ispconfig.log.8.gz
    -rw-r--r-- 1 root      root         4646 Mar 15 00:04 cron.log.8.gz
    -rw-r--r-- 1 root      root           29 Mar 15 00:04 auth.log.8.gz
    -rw-r--r-- 1 root      root           34 Mar 16 00:04 ispconfig.log.7.gz
    -rw-r--r-- 1 root      root         4517 Mar 16 00:04 cron.log.7.gz
    -rw-r--r-- 1 root      root           29 Mar 16 00:04 auth.log.7.gz
    -rw-r--r-- 1 root      root           34 Mar 17 00:05 ispconfig.log.6.gz
    -rw-r--r-- 1 root      root         4508 Mar 17 00:05 cron.log.6.gz
    -rw-r--r-- 1 root      root           29 Mar 17 00:05 auth.log.6.gz
    -rw-r--r-- 1 root      root           34 Mar 18 00:06 ispconfig.log.5.gz
    -rw-r--r-- 1 root      root         4529 Mar 18 00:06 cron.log.5.gz
    -rw-r--r-- 1 root      root           29 Mar 18 00:06 auth.log.5.gz
    -rw-r--r-- 1 root      root           34 Mar 19 00:06 ispconfig.log.4.gz
    -rw-r--r-- 1 root      root         4484 Mar 19 00:06 cron.log.4.gz
    -rw-r--r-- 1 root      root           29 Mar 19 00:06 auth.log.4.gz
    -rw-r--r-- 1 root      root           34 Mar 20 00:07 ispconfig.log.3.gz
    -rw-r--r-- 1 root      root         4491 Mar 20 00:07 cron.log.3.gz
    -rw-r--r-- 1 root      root           29 Mar 20 00:07 auth.log.3.gz
    -rw-r--r-- 1 root      root           34 Mar 21 00:06 ispconfig.log.2.gz
    -rw-r--r-- 1 root      root         4528 Mar 21 00:06 cron.log.2.gz
    -rw-r--r-- 1 root      root           29 Mar 21 00:06 auth.log.2.gz
    -rw-r--r-- 1 root      root           34 Mar 22 00:05 ispconfig.log.1.gz
    -rw-r--r-- 1 root      root         4496 Mar 22 00:05 cron.log.1.gz
    -rw-r--r-- 1 root      root           29 Mar 22 00:05 auth.log.1.gz
    -rw-rw---- 1 ispconfig ispconfig       0 Mar 22 00:05 auth.log
    -rw------- 1 root      root       688664 Apr 14 17:17 ispconfig.log
    -rw-rw---- 1 root      root      2696797 Apr 14 17:17 cron.log
    
    You can see that there is no gzipped log from 22th of march (like my issue with awstats)
    ispconfig.log file contains several day of log...

    Digging cron.log,
    Code:
    grep -v finished server.php cron.log | grep -v ispconfig_lock | grep -v webserver_plugin | grep -v 'return code: 0'
    I found
    Code:
    cron.log:Tue 22 Mar 2022 02:01:11 AM CET W: Failed to fetch https://packaging.gitlab.io/janus/focal/dists/focal/InRelease  Temporary failure resolving 'packaging.gitlab.io'
    cron.log:Tue 22 Mar 2022 02:01:11 AM CET W: Some index files failed to download. They have been ignored, or old ones used instead.
    cron.log:Tue 22 Mar 2022 03:00:27 AM CET Saving debug log to /var/log/letsencrypt/letsencrypt.log
    cron.log:Tue 22 Mar 2022 03:00:27 AM CET Cert not yet due for renewal
    cron.log:Tue 22 Mar 2022 03:00:27 AM CET Cert not yet due for renewal
    cron.log:Tue 22 Mar 2022 03:00:27 AM CET Cert not yet due for renewal
    cron.log:Sat 02 Apr 2022 05:24:01 PM CEST /usr/local/ispconfig/server/server.sh: line 22: 3721085 Segmentation fault      /usr/bin/php -q -d disable_classes= -d disable_functions= -d open_basedir= /usr/local/ispconfig/server/server.php
    cron.log:Mon 04 Apr 2022 10:11:02 AM CEST /usr/local/ispconfig/server/server.sh: line 29: 30895 Segmentation fault      /usr/bin/php -q -d disable_classes= -d disable_functions= -d open_basedir= /usr/local/ispconfig/security/check.php
    cron.log:Tue 05 Apr 2022 04:48:01 AM CEST /usr/bin/php: /lib/x86_64-linux-gnu/libicuuc.so.66: no version information available (required by /lib/x86_64-linux-gnu/libxml2.so.2)
    cron.log:Tue 05 Apr 2022 04:48:01 AM CEST /usr/bin/php: symbol lookup error: /lib/x86_64-linux-gnu/libxml2.so.2: undefined symbol: lzma_properties_decode, version XZ_5.0
    cron.log:Wed 06 Apr 2022 07:25:01 PM CEST /usr/local/ispconfig/server/cron.sh: line 17: 746732 Segmentation fault      $(which php) -q -d disable_classes= -d disable_functions= -d open_basedir= /usr/local/ispconfig/server/cron.php
    
    First failure is probably linked to an apt update. Nothing to do with ispconfig...
    janus is working properly (tested)

    Can you tell me how to test ispc daily cron if that exists... ?
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    /usr/bin/php /usr/local/ispconfig/server/cron_debug.php --cronjob=150-awstats.inc.php
     
  14. francoisPE

    francoisPE Active Member HowtoForge Supporter

    As I said, I did that and it works...
    But it is like if there a no cronjob launched
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    You asked how to test the awstats cronjob and that's the command how to test it. So what does it mean that awstats don't get created nightly and don't get created when you run it manually? It shows you that the issue is not that the statistics cronjob is not executed. So if you want to get further into debugging this, you must look at the code, add some debug code like echo commands, to see which code segments and commands get run with which parameters inside the cronjob.
     
  16. michelangelo

    michelangelo Active Member

    These php lines don't look healthy.
    What have you done to the base PHP version of the OS?

    OS Upgrade? PHP Upgrade?
     
  17. francoisPE

    francoisPE Active Member HowtoForge Supporter

    @michelangelo
    I don't know because it is quite far from now and I didn't see it before today.
    What is sure is that, there is no ubuntu upgrade, nor php upgrade... (php7.4)

    @till
    Sorry for being confusing and for insisting so much on that.
    I was not clear.
    At the very beginning
    Code:
    php /usr/local/ispconfig/server/cron_debug.php --cronjob=150-awstats.inc.php
    doesn't work.
    But, after all the tests, cleaning (etc...) I did it works finally.
    This is to say, when running cron_debug.php, it creates data.

    What is not running is : during the night nothing happens... nor awstats update, nor ispconfig.log rotate and gzipped...

    What I did tonight is that I run
    Code:
    ispconfig_update.sh
    Let see tomorrow morning if something happens
     
    till and Jesse Norell like this.
  18. francoisPE

    francoisPE Active Member HowtoForge Supporter

    ispconfig update had no effect.
    But, I found that :
    ps -aux | grep cron
    Code:
    root      300843  0.0  0.0   9492  3284 ?        Ss   Mar22   0:00 /bin/bash -c /usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    root      300848  0.0  0.0   9492  3208 ?        S    Mar22   0:00 /bin/bash /usr/local/ispconfig/server/cron.sh
    root      300849  0.0  0.0   9492   224 ?        S    Mar22   0:00 /bin/bash -c /usr/local/ispconfig/server/cron.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    root      300855 99.8  0.4 641076 38044 ?        R    Mar22 34735:19 /bin/php -q -d disable_classes= -d disable_functions= -d open_basedir= /usr/local/ispconfig/server/cron.php
    root     1336448  0.0  0.0   9512  2964 ?        Ss   Apr08   0:29 /usr/sbin/cron -f
    root     1801159  0.0  0.0   9492  3300 ?        Ss   Feb18   0:00 /bin/bash -c /usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    root     1801165  0.0  0.0   9492  1904 ?        S    Feb18   0:00 /bin/bash -c /usr/local/ispconfig/server/server.sh 2>&1 | while read line; do echo `/bin/date` "$line" >> /var/log/ispconfig/cron.log; done
    root     3289955  0.0  0.0   9032   724 pts/0    S+   08:00   0:00 grep --color=auto cron
    
    and
    grep -r WARNING /var/log/*
    Code:
    /var/log/ispconfig/cron.log:Thu 14 Apr 2022 01:41:01 AM CEST 14.04.2022-01:41 - WARNING - There is already a lockfile set, but no process running with this pid (2906709). Continuing.
    
    I kill all that processes.
    Let's see tomorrow...
     
  19. francoisPE

    francoisPE Active Member HowtoForge Supporter

    My cron is back to life !
    I will setup a daily mail to check Warning in my ispc cron.log...
     
  20. Dascos

    Dascos New Member

    That's a problem I get just today!!
    I got a solution but don't know why I have to do this, supposing all the system is unchanged since 6 month (only regular ubuntu updates)
    I rewrote the buildstatic.sh in /usr/share/awstats/tools and now there are no problems at all

    Code:
    #!/bin/sh
    ##
    ## buildstatic.sh, written by Sergey B Kirpichev <[email protected]>
    ##
    ## Build all static html reports from AWStats data (Debian specific)
    ##
    
    set -e
    
    DEFAULT=/etc/default/awstats
    AWSTATS=/usr/lib/cgi-bin/awstats.pl
    BUILDSTATICPAGES=/usr/share/awstats/tools/awstats_buildstaticpages.pl
    ERRFILE=`mktemp --tmpdir awstats.XXXXXXXXXX`
    YEAR=`date +%Y`
    MONTH=`date +%m`
    
    trap 'rm -f $ERRFILE' INT QUIT TERM EXIT
    
    [ -f $AWSTATS -a -f $BUILDSTATICPAGES ] || exit 1
    
    # Set default
    AWSTATS_NICE=10
    AWSTATS_ENABLE_BUILDSTATICPAGES="yes"
    AWSTATS_LANG=""
    [ ! -r "$DEFAULT" ] || . "$DEFAULT"
    
    # For compatibility: handle empty AWSTATS_ENABLE_CRONTABS as "yes":
    [ "${AWSTATS_ENABLE_CRONTABS:-yes}" = "yes" -a \
      "$AWSTATS_ENABLE_BUILDSTATICPAGES" = "yes" ] || exit 0
    
    cd /etc/awstats
    
    for c in `/bin/ls -1 awstats.*.conf 2>/dev/null | \
              /bin/sed 's/^awstats\.\(.*\)\.conf/\1/'` \
             `[ -f /etc/awstats/awstats.conf ] && echo awstats`
    do
      mkdir -p /var/www/$c/web/stats/$YEAR/$MONTH/
    
      if ! nice -n $AWSTATS_NICE $BUILDSTATICPAGES \
        -config=$c \
            -year=$YEAR \
            -month=$MONTH \
            -lang=$AWSTATS_LANG \
            -staticlinksext=html \
            -dir=/var/www/$c/web/stats/$YEAR/$MONTH/ >$ERRFILE 2>&1
      then
        cat $ERRFILE >&2 # an error occurred
      else
        ln -fs /var/www/$c/web/stats/$YEAR/$MONTH/awstats.$c.html \
            /var/www/$c/web/stats/$YEAR/$MONTH/awsindex.html
      fi
    USER=$(stat -c '%U' /var/www/$c/web/stats) 
     GROUP=$(stat -c '%G' /var/www/$c/web/stats) 
     chown -R $USER:$GROUP /var/www/$c/web/stats
    
    done
     
    Last edited: Jan 27, 2023

Share This Page