As said in a recent comment, I use logwatch to look at the logs on my server. Every night logwatch send me a mail with a report of what has happen.

One thing lacking was logs analysis for ikiwiki: ikiwiki don't produce log per-se. Access are logged and reported because they are done by the http server, but modification are only seen in the git repository, and comment waiting moderation are only in the ikiwiki directory.

So I needed a way for logwatch to report specific ikiwiki activity.

  • First we need to have a file logging activity in the ikiwiki's git repository. So in cron.daily, before logwatch is run, I put:

    git --git-dir $IKIWIKI_MAIN_DIR/.git log --after="6 month ago" --format="%cd (%h) %an: %s" --date=iso > /var/log/ikiwiki.log
    

    of course a better way to do it would be to create a git hook that generate the logs when modification are done, and not once everyday just before the logs are generated.

  • Then we need to tell logwatch to look at this file, so in /etc/logwatch/conf/logfiles/ikiwiki.conf I put

    ########################################################
    # Define log file group for ikiwiki
    ########################################################
    
    
    # What actual file? Defaults to LogPath if not absolute path....
    
    
    LogFile = ikiwiki.log
    
    
    *ApplyEuroDate
    

    The ApplyEuroDate make ikiwiki read the date in iso format, so it will only report commit done today. I've found no way to tell logwatch to look at the output of a program instead of looking at a file.

  • We then must tell logwatch that it must generate the report for a new service, so in /etc/logwatch/conf/services/ikiwiki.conf

    ########################################################
    # Configuration file for ikiwiki filter
    ########################################################
    
    
    Title = "Ikiwiki"
    
    
    # Which logfile group...
    
    
    LogFile = ikiwiki
    
  • Finally, we have to taught to generate the report, in /etc/logwatch/scripts/services/ikiwiki

    #!/bin/bash
    
    
    # First look at pending comment
    
    
    find $IKIWIKI_MAIN_DIR/ -name "*_pending" -exec echo "Pending comment:" \; -quit
    ( 
        cd $IKIWIKI_MAIN_DIR/
        find . -name "*_pending" -exec echo "    {}" \;
    )
    
    
    # we then look at new commit
    
    
    fst=true
    while read d t tz j; do
        if [ $fst == true ]; then
            echo "New commit:"
            fst=false
        fi
        echo -n "  "
        echo $j
    done