emonSD next steps: filesystem & logrotate

I already explained how the symlink and rotated files directory work with L2R in the “emonSD next steps: log2ram - #5 by pb66” thread.

If that folder is not there, then the rotation hasn’t run (correctly) yet. This is logrotation by logrotate and has nothing to do with L2R other than the additional config for logrotate is installed by the L2R installer as part of the L2R logging solution. I would like to see L2R and logrotate work closer, ie triggered as a single operation, check and rotate first, then sync just what’s left in ram and report stats (to log and/or emonhub too).

[edit - assuming you are using a emonSD/Pi/Base I think there are still some issues with the logrotation on that image. also assuming the image I have here in front of me is as intended, there seems to be a number of anomalies.

  1. The logrotation used to be hourly on the emonSD, it is currently daily

    pi@emonpi:~ $ sudo ls -la /etc/cron*/logrotate
    lrwxrwxrwx 1 root root 46 Apr 23 10:45 /etc/cron.daily/logrotate -> /var/www/html/emoncms/scripts/logger/logrotate
    

    It seems the symlink isn’t moved as per the instruction in the custom conf file (emoncms/scripts/logger/logrotate.conf at ddb08542b5ccb9ae29b2822cea32f3beb20733ed · emoncms/emoncms · GitHub)

  2. The logrotaion cron seems to try and use a custom logrotate.ststus file that “should” apparently be in /var/log.

    /usr/sbin/logrotate -v -s /var/log/logrotate/logrotate.status /etc/logrotate.conf 2>&1 | tee /var/log/logrotate/logrotate.log
    

    Since /var/log is in tmpfs and any file there will be lost on reboot, this logrotate command fails due to not being able to find the nominated ststus file, thus logrotate doesn’t run.

  3. The custom logrotate.conf file disables all other logrotate configurations provided by other packages, (including L2R). In fact it disables the inclusion twice! (emoncms/scripts/logger/logrotate.conf at ddb08542b5ccb9ae29b2822cea32f3beb20733ed · emoncms/emoncms · GitHub)

    # Don't nclude package specefic logrotate config
    #include /etc/logrotate.d
    
    # Include package specefic logrotate config
    #include /etc/logrotate.d
    
  4. Even though the config says

    # keep 2 rotations  worth of backlogs (size x 2)
    

    A recent change means we now only keep one rotation! So when running as an hourly rotation, only 1M per log is retained following each each hourly rotation.