[Exim] eximstats and gzipped logfiles.

Pàgina inicial
Delete this message
Reply to this message
Autor: Hugh Sasse Staff Elec Eng
Data:  
A: EXIM users list
Assumpte: [Exim] eximstats and gzipped logfiles.
Eximstats doesn't cope wth gzipped log files on the command line,
despite them being fairly standard as a result of exicyclog.  A
search of the archives revealed that it can summarize the files on STDIN
so one can use gzip -dc to process them.   Gzip -d (or gunzip) won't
pass non-gzipped files straight through, it gives an error if the
files are not in gzip or compressed format.  So I wrote these few
lines of Ruby (I'm more fluent in Ruby than Perl these days :-))
to work around it.  This may help someone, so I'm posting it so those
searching the archives can find it.  I expect it can be improved,
but it did the job I needed to do.
        Hugh


#!/usr/local/bin/ruby -w

open("|/usr/local/exim/bin/eximstats -ne -t10 -q0 > eximstats.out", "w") {
    |eximstats|
    ARGV.each { |file|
        puts file
        if file =~ /\.gz/
           eximstats.print %x{/usr/local/bin/gunzip -c #{file}}
           eximstats.print "\n"
        else
           eximstats.print %x{/bin/cat #{file}}
           eximstats.print "\n"
        end
    }
}