• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

contrib/H16-Oct-2003-1,105924

docs/H07-May-2022-748746

regex/H28-Dec-2002-3,7752,636

BUGSH A D28-Dec-2002527 1610

COPYRIGHTH A D01-Jan-20031.3 KiB2721

HISTORYH A D16-Oct-20036.3 KiB209166

MakefileH A D28-Dec-2002515 2815

Makefile.msvcpH A D28-Dec-2002649 2816

Makefile.w32H A D28-Dec-2002455 2514

READMEH A D02-Apr-200313 KiB391277

TODOH A D03-May-2003185 114

ascii.cH A D01-Jan-200313.9 KiB396321

conf.hH A D28-Dec-20021.4 KiB6318

getopt.cH A D28-Dec-20023.7 KiB11165

hash.cH A D03-Apr-200315 KiB660516

html.cH A D22-Mar-200326.8 KiB758663

init.cH A D03-May-20228 KiB279216

install-shH A D28-Dec-20025.5 KiB251152

parse.cH A D27-Apr-200323.4 KiB1,050744

sma.cH A D03-May-202212.3 KiB598483

sma.confH A D02-Apr-20034.5 KiB20829

sma.hH A D03-May-202210.4 KiB530305

utils.cH A D03-May-202217.9 KiB655473

README

1#
2# Copyright (c) 2000, 2001, 2002 Jarkko Turkulainen. All rights reserved.
3#
4# SMA is copyrighted software. See the file COPYRIGHT which can be found
5# at the top level of the sma distribution.
6#
7# $Id: README,v 1.8.1 2003/04/02 18:45:33 jt Exp $
8#
9
10		SMA - SENDMAIL LOG ANALYSER
11
12PLEASE READ THIS CAREFULLY BEFORE YOU START USING THIS SOFTWARE
13
14In many countries, including Finland and many other European countries,
15it might be illegal to read mail logs and produce mail log summaries.
16Or, at least, it is illegal to use mail logs for anything else but problem
17solving. Of course, if you run a mail service of your own, nobody's
18interested in what you do with your logs. But on the other hand, if you
19run a mail service that is used by other persons (no matter how many)
20you simply cannot publish the names and top lists. You cannot even show
21the report to your clients!!
22
23If you are not sure about the law in your country, make sure that you run
24SMA always with command line option (-d) or configuration file keyword
25"ShowUsers no" (default in 1.3.2 or later). Or even better, disable all the
26envelope analyses.
27
28
291. OVERVIEW
30
31SMA is a program than analyses mail log files and produces a nice summary
32of mail activity. It works by taking its input from files or standard input
33and outputting the results to standard output or file. All error messages and
34debugging information are printed to standard error.
35
36Starting as of version 0.12.0, SMA prints the results as a nifty formatted
37ASCII report. The HTML report can still be produced with the command line
38option (-w). The HTML report uses heavily tables, so lynx is not the best
39browser for the job. If you MUST use a text browser, try using links
40instead.
41
42Recent SMA versions (1.3.3+) also support postix logs. At least the following
43features work:
44
45* Envelope senders/recipients/relays
46* Status messages
47* Time distribution
48
49
50
512. SOURCE INSTALLATION
52
53Unpack the distribution. Copy one of the Makefiles (Makefile, Makefile.w32
54or Makefile.mscp) as Makefile. Modify Makefile and conf.h as needed. Type
55
56$ make
57(or nmake or gmake or whatever your system requires)..
58
59at the top level of the distribution. After successful compilation, just
60copy the binary file sma to your favourite directory or type
61
62# make install
63
64as root. This also installs the manpage as MANPATH/sma.8. You can also copy
65the default configuration file "sma.conf" as defined in conf.h.
66
67The program is small and simple, and it should compile on most UNIX-style
68environments. At least following systems are known to be working:
69
70	AIX 4.1.3, 4.3 (gcc)
71	Digital Unix 4.0 (gcc, DECcc)
72	FreeBSD/i386 3.4, 3.5.1, 4.x (gcc)
73	HP-UX 10.20 (gcc, HPcc)
74	IRIX 6.5 (gcc)
75	NetBSD/sparc 1.4.2 (gcc)
76	OpenBSD/i386 2.7 - 3.2 (gcc)
77	Red Hat Linux 5.2 - 7.2 (gcc)
78	Solaris 2.5.1, 2.6, 7 and 8 (gcc)
79	Solaris/i386 8 (gcc)
80	Mac OS X (Darwin 6.2)
81	Win32 (cygwin-1.3.3)
82	Win32 (mingw-1.1) (*)
83	Win32 (MS Visual C++) (**)
84
85(*) Compile with Makefile.w32
86(**) Compile with Makefile.msvcp
87
88Systems with known problems:
89
90	o on Tru64 UNIX cluster (DECcc) malloc() returns errno 22 (EINVAL)
91	  which indicates that the requested space is out of range.
92
93The flag -DUSE_REGEXP in CFLAGS may introduce some problems with systems
94not conforming to XPG3 definition of regular expressions. In that case,
95modify Makefile and try to recompile. If USE_REGEXP is not defined, the
96standard strstr() function is used with filtering routines.
97
98RPM BUILDING
99
100The RPM spec-file (contrib/sma.spec) can be used to compile RPM binary
101package. Here are the instructions:
102
103- Copy sma-x.tar.gz to /usr/src/RPM/SOURCES/ (x refers to sma version,
104  for example 1.3)
105- Unpack sma-x.tar.gz
106  $ tar zxvf sma-x.tar.gz
107- Build RPM
108  # rpm -bb sma-x/contrib/sma.spec
109- Install RPM from /usr/src/RPM/RPMS/
110
111Note that you may need to replace /usr/src/RPM with /usr/src/redhat on
112some Red Hat -based systems.
113
114
1153. WIN32 BINARY INSTALLATION
116
117Win32 binary distribution is compiled with MinGW, see
118http://www.mingw.org for more information. SMA binary should run
119on all 32-bit Windows versions (95, 98, NT, 2000, XP, ...) that
120use Microsoft's standard C runtime library (MSVCRT.DLL).
121
122Here are the general instuctions on how to get SMA binary working.
123
124- Unpack the distribution sma-x-win32.zip where 'x'
125  refers to version number of the sma distribution.
126
127- Make a directory (C:\sma etc.)
128  If you run Sendmail for NT, it might be easiest to install
129  the binary in that directory (C:\Program Files\Sendmail etc.)
130
131- Copy sma.exe and sma.conf to your directory. Edit sma.conf
132  with your favourite text editor. Make sure your editor can
133  handle ASCII files correctly. MS Word doesn't.
134
135If you run Sendmail for NT, you must enable logging to files. SMA
136cannot read NT event log. At Sendmail Control Panel, set sendmail
137logging level as '9' (or higher) and define the log file (propably
138C:\Program Files\Sendmail\smlog.txt or something).
139
140
1414. HOW TO USE
142
143sma [-Fcdhinpsqvw] [-D date1,date2] [-b color] [-f file]
144    [-o file] [-l num] [-r num] [-t value] [files ...]
145
146Generally, SMA reads one or more log files from /var/log (or wherever
147they are) and redirect the output to file. The program tries to open
148configuration file named "sma.conf" from the current working directory.
149This can be overriden with the flags (-f and -F) or with a compile
150time option DEFAULT_CONF, defined in file conf.h.
151
152Note that the behavior of sendmail logging has changed with the 8.12 so
153that the MSP and MTA deliveries are logged as a separate entries. The
154syslog tag should be set with the option (-L) in both sendmail and SMA.
155
156
157Command line options:
158
159-b color	Set the background color of the HTML report as "color".
160		This is a six-digit RGB value.
161
162-C string	Set report header as "string".
163
164-c		Print the copyright notice and exit.
165
166-D date1,date2  Process log entry only if the date is between "date1"
167		and "date2". The format of the date is as follows:
168
169		[[[[[cc]yy]mm]dd]HH]MM[.SS] where
170
171		   yy      Year in abbreviated form (for years 1969-2068).
172                           The format ccyymmddHHMM is also permitted, for
173			   non-ambiguous years.
174                   mm      Numeric month, a number from 1 to 12.
175                   dd      Day, a number from 1 to 31.
176                   HH      Hour, a number from 0 to 23.
177                   MM      Minute, a number from 0 to 59.
178                   SS      Second, a number from 0 to 61 (59 plus a maximum of
179                           two leap seconds).
180
181		Everything but the minute is optional. The dates must be
182		separated using a colon, without any whitespace characters.
183		If either of the dates is missing, current date is used.
184
185-d		Analyse sender/receiver domains instead of full
186		e-mail addresses; eg. domain.com instead of
187		joe@domain.com.
188
189-f file		Read the configuration from "file" instead of the default
190		configuration (./sma.conf). Some of the configuration
191		options are only available from the configuration file.
192		You should read the file "sma.conf" for more information.
193
194-F		Do not use default configuration file even if it exists.
195
196-h 		Print help message and exit.
197
198-i 		Include the ASCII report in HTML comment field. This option
199		requires HTML reporting (-w, -O html or "Format html").
200
201-L string	Process only lines with syslog tag "string".
202
203-n 		Do not report the time distribution.
204
205-o file		Print the report as file. If not given, print to stdout.
206
207-O format	Output format. ascii, html or clog. See CUSTOM LOGGING for
208		more information on clog format.
209
210-p 		Print current configuration to stdout.
211
212-s 		Sort by transfers. Default is by number of messages.
213
214-q		Do not print any warning messages. Sometimes SMA may
215		be noisy. Use this switch if you see too many
216		"skipping useless line.." messages.
217
218-l num		Number of the senders/recipients that are printed
219		in the summary. Default is 10.
220
221-r num		Number of the input/output relay domains that are
222		printed in the summary. Defaults to 5.
223
224-t va1ue        Adjust the internal hash table size. Possible values are:
225		"normal", "big", "huge" and custom, comma separated values.
226
227-v		Print some debugging information for each parsed line.
228		Be careful with big files and slow terminals..
229
230-w		Print the report in HTML.
231
232Examples:
233
234- Print the results in txtdocs/report.txt:
235  $ sma maillog > txtdocs/report.txt
236
237- Print only relay domains and sort them by transfers.
238  Output format is HTML:
239  $ sma -nsw -l 0 maillog > wwwdocs/report.html
240
241- Print the ASCII report to file report.txt and errors/debugging to
242  file debug.txt:
243  $ sma -v maillog > report.txt 2> debug.txt
244
245- Read configuration from file /usr/local/etc/sma.conf and read the
246  output file name from command line:
247  $ sma -f /usr/local/etc/sma.conf -o report.html maillog
248
249- Read log file smlog.txt and write output to file
250  WebUI\reports\index.html:
251  C:\Program Files\Sendmail> sma -o WebUI\reports\index.html smlog.txt
252
253- Read from stdin and write to stdout :-)
254  $ sma
255
256- Read only logs between minutes 15 and 45 this hour
257  $ sma -D 15,45 maillog
258
259- Read only logs between 16:30 and 16:50 today
260  $ sma -D 1630,1650 maillog
261
262- Read only logs before 25th day this month
263  $ sma -D ,250000 maillog
264
265- Read only logs after 15:25:10 (hour is 15, minute 25 and second 10)
266  $ sma -D 1525.10 maillog
267
268- Read logs between 2001 and 2002, with full dates
269  $ sma -D 200101010000.00,200201010000.00
270
271- Print configuration to file sma.conf
272  $ sma -p [your favourite command line options] > sma.conf
273
274- Use big hash tables
275  $ sma -t big
276
277- Set address hash table size as 10000 and relay table size as 3000:
278  $ sma -t 10000,3000
279
280
2815. FILTERS
282
283SMA filters help you to get an answer to questions like "how many
284messages are passed through a specific relay host?" or "how many
285messages were sent to @some.domain.com at certain time interval"?
286
287Filters are invoked from the configuration file with the following keys:
288
289Key				Value
290---------------------------------------------------
291EnvelopeSenderFilter		*
292EnvelopeRecipientFilter		*
293RelaySenderFilter		*
294RelayRecipientFilter		*
295StartTime			YYYY/MM/DD-MM:HH:SS
296EndTime				YYYY/MM/DD-MM:HH:SS
297
298The meaning of the keys should be clear - four keys are for envelopes
299and relays (input and ouput) and the rest of the six are for start -and
300end times. The values are tested as a simple substring match. Only
301regexp is (*) which means "any". If compiled with USE_REGEXP, all the
302standard, egrep-style extended regular expressions may be used.
303
304All filters are ANDed together - you cannot generate a report with filter
305"all mails sent to some.domain OR all mails sent from some.domain".
306But you can always run the same file several times with different set
307of filters. If complied with USE_REGEXP, filters may contain also
308conditionals (|).
309
310The meaning of filter can be reversed by placing '!' as a first character.
311All other '!'-characters are taken literally (or part of the regexp).
312
313
314
3156. CUSTOM LOGGING
316
317Custom log format (clog) is one of the output formatting options. Unlike
318ASCII and HTML, which are reporting formats, clog is a sort of log file
319filter. It's main function is to convert the multi-line sendmail log file
320to a simple, one-line-per-delivery format. This simple log file may then
321be further analysed with another log analyzer, for example the excellent
322analog (http://www.statslab.cam.ac.uk/~sret1/analog).
323
324Custom logging is invoked with command line option (-O clog) and/or
325configured using the following configuration file keywords:
326
327Format		clog
328ClogFormat	FORMATSTRING
329
330The value FORMATSTRING controls the information and how it is formatted.
331It consists of ordinary characters and various two-character sequencies which
332are replaced with built-in variables as follows:
333
334	%U time in UNIX time format
335	%D time in form "Wed Jun 30 21:49:08 1993"
336	%y year, four digits
337	%m month, in digits
338	%M month, three letter English
339	%n minute
340	%s second
341	%d day
342	%h hour
343	%H hostname
344	%z size in bytes
345	%f envelope sender
346	%t envelope recipient
347	%F relay sender
348	%T relay recipient
349	%S status (1 = sent, 0 = error)
350	%i message id
351	%% %-character
352	\n newline
353	\t tab stop
354	\\ single backslash
355
356For example, the following format string
357
358  ClogFormat	"%D: from=%f, to=%t, size=%z"
359
360looks at the output side like
361
362  Thu Oct 25 04:24:56 2001: from=sender1, to=recipient1, size=10
363  Thu Oct 25 04:24:57 2001: from=sender2, to=recipient2, size=20
364  Thu Oct 25 04:24:58 2001: from=sender3, to=recipient3 size=30
365
366Unlike ASCII and HTML, Custom logging is done in real-time and it runs with
367a very small memory footprint. Piping the output of running sendmail daemon
368might be a very interesting application:
369
370$ tail -f /var/log/maillog | sma -O clog
371
372
373
3747. ACKNOWLEDGEMENTS
375
376Adam Beaumont <admin at a-q dot co dot uk> - thanks for constructive ideas
377Dirk Meyer <dirk dot meyer at dinoex dot sub dot org> - code cleanup patch
378Nicos Nicolaou <nicosn at logosnet dot cy dot net> - ideas and feedback
379Mario Pino Uceda <mpino at cica dot es> - support for big log files
380Pekka Honkanen <phonkane at cc dot hut dot fi> - testing and feedback
381Stephane Lentz <Stephane dot Lentz at ansf dot alcatel dot fr> - RPM spec file
382
383And many others not mentioned here (see the file HISTORY) for reporting bugs,
384giving feedback, etc.
385
386
3878. CONTACT
388
389All comments/suggestions/diffs via email to sma@klake.org
390
391