### File sa_cache.3 of Package sendmailanalyzer

```.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\\$1\t\\n%\t"\\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "sa_cache 3"
.TH sa_cache 3 "2013-01-02" "8.6" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.nh
.SH "NAME"
SendmailAnalyzer Cache Statistic Creator \- Sendmail/Postfix log analyzer
.SH "DESCRIPTION"
SendmailAnalyzer collect maillog entries to write datas to flat files,
when you run the \s-1CGI\s0 script sa_report.cgi it had to read each data files
for the given period to compute statistics and output \s-1HTML\s0 reports.
This can be enought for day views but when you jump to month view it
cost a lot in \s-1CPU\s0 and memory usage unless you have a home \s-1MTA\s0.
.PP
To speed up things and free system resources you have to run the script
sa_cache each night by cron to create cache files. After that viewing
a month or year view take less than a second.
.PP
If you have set per domain report sa_cache will create cache files for each
domains. These cache files are name cache.pm for the \s-1MTA\s0 global statistics
and cache.pmYOURDOMAIM.DOM for each domain report. To lowered the memory
footprint of the sa_cache program, since version 8.0 it start computing cache
file per hours.
.PP
Since version 4.0 sa_report.cgi will warm you to avoid out of memory when
your entering a month view without caching.
.SH "USAGE"
.SS "Huge \s-1MTA\s0 activity"
.IX Subsection "Huge MTA activity"
On \s-1MTA\s0 server with very huge activity you can experience out of memory or
wait a very long time before seeing anything in day view. In this case you
must run by cron job the perl script sa_cache with the \-a option to build
cache files for the current day. Statistics will not be shown in realtime but
only at the time of the last sa_cache run. You can run it each five minute for
example as follow:
.PP
.Vb 1
\&    */5 * * * * /usr/sbin/sa_cache \-a
.Ve
.PP
or
.PP
.Vb 1
\&    */5 * * * * /usr/sbin/sa_cache \-\-actual\-day\-only
.Ve
.PP
It will only parse data stored in the current day so five minutes interval
may be enough for most case.
.SS "Archiving"
.IX Subsection "Archiving"
When sa_cache is run and following the value of the \s-1FREE_SPACE\s0 configuration
option it will try to archive data older than the current month. If \s-1FREE_SPACE\s0
is set to 'delete' sa_cache will simply remove the data file from disk. If you
set it to 'archive', sa_cache will build a gzipped tarball for all daily data
file into the corresponding month directory and the remove date file from disk.
.PP
If you set it to 'none', data file are kept.
.PP
If you're primary concerned in disk space saving set it to 'delete'. If you
want to preserve data for a year or more you can safely set it to 'archive'.
For your information one of my server has 100,000 inbound message a day and
a year of 'archive' storage take around 1Gb and a 'delete' storage around
250Mb.
.SS "Options"
.IX Subsection "Options"
sa_cache knows the following options:
.PP
.Vb 5
\&        \-c | \-\-config file
\&        \-d | \-\-date  "yyyy/mm"
\&        \-h | \-\-help
\&        \-s | \-\-syslog  hostname
\&        \-a | \-\-actual\-day\-only
.Ve
.IP "\fB\-\-config\fR \fIfile\fR" 4
.IX Item "--config file"
Path to sendmailanalyzer configuration file. Default: /etc/sendmailanalyzer.conf
.IP "\fB\-\-date\fR" 4
.IX Item "--date"
Year/month cache to proceed. Default is all month/year.
.IP "\fB\-\-syslog\fR" 4
.IX Item "--syslog"
syslog name of the host to proceed. Default all.
.IP "\fB\-\-actual\-day\-only\fR" 4
.IX Item "--actual-day-only"
Proceed only the current day, this option replace the old and obsolete day_cache script.
You still have to run it often like each five minutes.
.SH "AUTHOR"
Gilles Darold <gilles \f(CW@nospam\fR@ darold.net>
.PP
.Vb 4
\&    This program is free software: you can redistribute it and/or modify
\&    the Free Software Foundation, either version 3 of the License, or
\&    any later version.
\&
\&    This program is distributed in the hope that it will be useful,
\&    but WITHOUT ANY WARRANTY; without even the implied warranty of
\&    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
\&    GNU General Public License for more details.
\&
\&    You should have received a copy of the GNU General Public License
\&    along with this program.  If not, see < http://www.gnu.org/licenses/ >.
.Ve
.SH "BUGS"