Cron Jobs - PHP Warning/Notices

Issue #539 resolved
Former user created an issue

Hi,

Using Piler 1.1.1 I'm getting PHP Warnings/Notices from the following Crojobs:

  • daily-report.php
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
PHP Warning:  file_get_contents(/var/piler/stat/cpu.stat): failed to open stream: No such file or directory in /usr/libexec/piler/daily-report.php on line 108
PHP Notice:  Undefined variable: ssize in /var/www/piler/model/stat/counter.php on line 20
PHP Notice:  Undefined offset: 1 in /usr/libexec/piler/daily-report.php on line 125
PHP Notice:  Undefined offset: 2 in /usr/libexec/piler/daily-report.php on line 126
PHP Notice:  Undefined index: rcvd in /usr/libexec/piler/daily-report.php on line 128
  • generate_stats.php
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30

Finished Executing Statistics Generation
*************************************************
Start Date: 2015.04.16
Stop Date: 2015.04.17
Removed 0 records
Added 0 records
Completed Run in 0.17446804046631 seconds

Thanks for looking into this.

Bye Frederik

P.S.: Are you merging PullRequest? Sometime ago I pushed pull request #3

Comments (24)

  1. Janos SUTO repo owner

    Hello Frederic, sorry, I overlooked your commit, I'll check it soon.

    To solve these issues, apply the following diffs:

    diff --git a/util/daily-report.php b/util/daily-report.php
    index 69af2bf..100c16e 100644
    --- a/util/daily-report.php
    +++ b/util/daily-report.php
    @@ -5,6 +5,8 @@ $verbose = 0;
    
     $archivesizeraw = $sqlsizeraw = $sphinxsizeraw = 0;
     $averagemessagesweekraw = $averagemessagesmonthraw = $averagemessagesizeraw = $averagesizedayraw = $averagesqlsizeraw = $averagesphinxsizeraw = 0;
    +
    +ini_set("session.save_path", "/tmp");
    
     $_SERVER['HTTP_USER_AGENT'] = "daily/cron";
    
    @@ -122,8 +124,8 @@ $mail = new ModelMailMail();
           $averagemessagesizeraw = $averagesqlsizeraw = $averagesphinxsizeraw = $daysleftatcurrentrate = 0;
    
              /* these next counters are for projecting space */
    -         $averagemessagesweekraw = ($processed_emails[1]) / 7;
    -         $averagemessagesmonthraw = ($processed_emails[2]) / 30;
    +         $averagemessagesweekraw = ($processed_emails['last_7_days_size']) / 7;
    +         $averagemessagesmonthraw = ($processed_emails['last_30_days_size']) / 30;
    
               if($counters['rcvd'] > 0) {
                  $averagemessagesizeraw = $archivesizeraw / $counters['rcvd'];
    @@ -175,8 +177,9 @@ $mail = new ModelMailMail();
    
           $rcpt = array(ADMIN_EMAIL);
    
    -      $x = $mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
    -
    +      if(SMARTHOST) {
    +         $x = $mail->send_smtp_email(SMARTHOST, SMARTHOST_PORT, SMTP_DOMAIN, SMTP_FROMADDR, $rcpt, $msg);
    +      }
    
    diff --git a/util/generate_stats.php b/util/generate_stats.php
    index fd585e4..2f4ff1a 100644
    --- a/util/generate_stats.php
    +++ b/util/generate_stats.php
    @@ -6,6 +6,8 @@ $start = NULL;
     $stop = NULL;
     $timestart = microtime(true);
    
    +ini_set("session.save_path", "/tmp");
    +
     // get options from command line
     $opts = 'h::';
     $lopts = array(
    
  2. Former user Account Deleted

    Hi, unluckily it does not fix the warnings. In the daily-report.php there are 3 Lines less, but the generate_stats.php is not changed.

    ~$ /usr/bin/php /usr/libexec/piler/daily-report.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Notice:  Undefined variable: ssize in /var/www/piler/model/stat/counter.php on line 20
    PHP Notice:  Undefined index: rcvd in /usr/libexec/piler/daily-report.php on line 130
    
    ~$ /usr/bin/php /usr/libexec/piler/generate_stats.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    '
    Finished Executing Statistics Generation
    *************************************************
    Start Date: 2015.04.26
    Stop Date: 2015.04.27
    Removed 0 records
    Added 0 records
    Completed Run in 0.02428412437439 seconds
    
  3. eXtremeSHOK

    set the following in your php.ini

    #!
    
    error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING
    
  4. Janos SUTO repo owner

    I think something is not right on your side. "Undefined variable: ssize " says your tables are not updated. Check if the util/db-upgrade-xxxx.sql scripts were actually applied.

  5. Former user Account Deleted

    Hi,

    it was a clean install of 1.1.1, so I initially executed the db-mysql.sql script.

    Also the Undefined variable: ssize comes from the memcached acces. The _piler:size key exists, but the _piler:counters_last_update does not (see line 14 in counter.php). Might that be a problem?

  6. Janos SUTO repo owner

    Just fixed these scripts again. Please try them, this time try turning off memcache support.

  7. Former user Account Deleted

    Sorry, I was onl holidays :-)

    I tried the newest scripts from master/HEAD - no visible change.

    With MEMCACHE disabled:

    piler@mailarchive:~$ /usr/bin/php daily-report-new.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    piler@mailarchive:~$ /usr/bin/php generate_stats-new.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    
    Finished Executing Statistics Generation
    *************************************************
    Start Date: 2015.05.21
    Stop Date: 2015.05.22
    Removed 0 records
    Added 0 records
    Completed Run in 0.039278030395508 seconds
    

    With MEMCACHE enabled:

    piler@mailarchive:~$ /usr/bin/php daily-report-new.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Notice:  Undefined variable: ssize in /var/www/piler/model/stat/counter.php on line 20
    PHP Notice:  Undefined index: rcvd in /var/archiv/daily-report-new.php on line 130
    piler@mailarchive:~$ /usr/bin/php generate_stats-new.php --webui /var/www/piler
    
    PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/piler/config-site.php:51) in /var/www/piler/system/request.php on line 30
    
    Finished Executing Statistics Generation
    *************************************************
    Start Date: 2015.05.21
    Stop Date: 2015.05.22
    Removed 0 records
    Added 0 records
    Completed Run in 0.083213090896606 seconds
    

    BTW: What exactly is Memcache used for? Is it usefull to enable? (actually I just did it, since I couldn't find any deeper explanation in the docs).

    Thanks a lot!

  8. Janos SUTO repo owner

    Please send me your config-site.php (obfuscate only passwords). See my email in piler -V

  9. Former user Account Deleted

    Arggggh... That on was too easy... Actually it works. Thanks!!!!

    The Memcache related error persists: Should I just disable memcache?

  10. Janos SUTO repo owner

    There must have been an extra line at the end of the file. I could have thought about it sooner, indeed. I'll check the memcached related issue, until then you may disable it.

    Btw. I've applied the init script fix recently (thanks for that anyway), though I didn't pull your your fork.

  11. Former user Account Deleted

    Thanks. Since it's just removing the memcache logic, it's working fine.

    Done.... :-)

  12. Log in to comment