diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-01-01 20:34:09 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-01-01 20:34:09 +0000 |
commit | eee2b4eb53e92b81e49de60573e674a396e7fabf (patch) | |
tree | 275b5f6fa0ac9e556790ec96876d3af0af4feaee /usr.sbin/sendmail/mailstats | |
parent | 73ee31937b7b4ae7257f3dc1da71e8072d535784 (diff) |
sendmail 8.9.2
Diffstat (limited to 'usr.sbin/sendmail/mailstats')
-rw-r--r-- | usr.sbin/sendmail/mailstats/Makefile.m4 | 6 | ||||
-rw-r--r-- | usr.sbin/sendmail/mailstats/mailstats.8 | 18 | ||||
-rw-r--r-- | usr.sbin/sendmail/mailstats/mailstats.c | 60 |
3 files changed, 68 insertions, 16 deletions
diff --git a/usr.sbin/sendmail/mailstats/Makefile.m4 b/usr.sbin/sendmail/mailstats/Makefile.m4 index ae5489c62ee..2de9904f9c3 100644 --- a/usr.sbin/sendmail/mailstats/Makefile.m4 +++ b/usr.sbin/sendmail/mailstats/Makefile.m4 @@ -1,7 +1,7 @@ # # This Makefile is designed to work on the old "make" program. # -# @(#)Makefile.m4 8.14 (Berkeley) 6/4/98 +# @(#)Makefile.m4 8.15 (Berkeley) 7/12/1998 # # C compiler @@ -34,7 +34,7 @@ LIBDIRS=confLIBDIRS LIBS= ifdef(`confLIBS', `confLIBS') # location of mailstats binary (usually /usr/sbin or /usr/etc) -BINDIR= ${DESTDIR}ifdef(`confSBINDIR', `confSBINDIR', `/usr/sbin') +SBINDIR=${DESTDIR}ifdef(`confSBINDIR', `confSBINDIR', `/usr/sbin') # additional .o files needed OBJADD= ifdef(`confOBJADD', `confOBJADD') @@ -82,7 +82,7 @@ mailstats.${MAN8SRC}: mailstats.8 install: install-mailstats install-docs install-mailstats: mailstats - ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} mailstats ${BINDIR} + ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} mailstats ${SBINDIR} install-docs: mailstats.${MAN8SRC} ifdef(`confNO_MAN_INSTALL', `dnl', diff --git a/usr.sbin/sendmail/mailstats/mailstats.8 b/usr.sbin/sendmail/mailstats/mailstats.8 index 3a8847a6f64..be2203d85fa 100644 --- a/usr.sbin/sendmail/mailstats/mailstats.8 +++ b/usr.sbin/sendmail/mailstats/mailstats.8 @@ -5,7 +5,7 @@ .\" the sendmail distribution. .\" .\" -.\" @(#)mailstats.8 8.5 (Berkeley) 5/19/98 +.\" @(#)mailstats.8 8.8 (Berkeley) 11/13/1998 .\" .Dd April 25, 1996 .Dt MAILSTATS 1 @@ -16,6 +16,7 @@ .Sh SYNOPSIS .Nm mailstats .Op Fl o +.if \nP .Op Fl p .Op Fl C Ar cffile .Op Fl f Ar stfile .Sh DESCRIPTION @@ -41,6 +42,10 @@ Kbytes from the mailer. Number of messages to the mailer. .It Sy bytes_to Kbytes to the mailer. +.It Sy msgsrej +Number of messages rejected. +.It Sy msgsdis +Number of messages discarded. .It Sy Mailer The name of the mailer. .El @@ -64,6 +69,11 @@ specified in the .Nm sendmail .Dq cf file. +.if \nP \ +\{ +.It Fl p +Output information in program-readable mode and clear statistics. +.\} .It Fl o Don't display the name of the mailer in the output. .El @@ -73,12 +83,14 @@ The utility exits 0 on success, and >0 if an error occurs. .Sh FILES .Bl -tag -width /var/log/sendmail.stXX -compact -.It Pa /etc/sendmail.cf +.ie \nP .It Pa /etc/mail/sendmail.cf +.el .It Pa /etc/sendmail.cf The default .Nm sendmail .Dq cf file. -.It Pa /var/log/sendmail.st +.ie \nP .It Pa /etc/mail/statistics +.el .It Pa /var/log/sendmail.st The default .Nm sendmail statistics file. diff --git a/usr.sbin/sendmail/mailstats/mailstats.c b/usr.sbin/sendmail/mailstats/mailstats.c index 6fda6db391a..5df3b95e39c 100644 --- a/usr.sbin/sendmail/mailstats/mailstats.c +++ b/usr.sbin/sendmail/mailstats/mailstats.c @@ -18,7 +18,7 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)mailstats.c 8.26 (Berkeley) 7/2/98"; +static char sccsid[] = "@(#)mailstats.c 8.28 (Berkeley) 9/14/1998"; #endif /* not lint */ #ifndef NOT_SENDMAIL @@ -45,17 +45,20 @@ main(argc, argv) char *cfile; FILE *cfp; bool mnames; + bool progmode; long frmsgs = 0, frbytes = 0, tomsgs = 0, tobytes = 0, rejmsgs = 0; long dismsgs = 0; char mtable[MAXMAILERS][MNAMELEN+1]; char sfilebuf[MAXLINE]; char buf[MAXLINE]; + time_t now; extern char *ctime(); cfile = _PATH_SENDMAILCF; sfile = NULL; mnames = TRUE; - while ((ch = getopt(argc, argv, "C:f:o")) != EOF) + progmode = FALSE; + while ((ch = getopt(argc, argv, "C:f:op")) != EOF) { switch (ch) { @@ -71,11 +74,22 @@ main(argc, argv) mnames = FALSE; break; +#if _FFR_MAILSTATS_PROGMODE + case 'p': + progmode = TRUE; + break; +#endif + case '?': default: usage: - fputs("usage: mailstats [-C cffile] [-f stfile] -o\n", +#if _FFR_MAILSTATS_PROGMODE + fputs("usage: mailstats [-C cffile] [-f stfile] -o -p\n", + stderr); +#else + fputs("usage: mailstats [-C cffile] [-f stfile] -o \n", stderr); +#endif exit(EX_USAGE); } } @@ -226,15 +240,29 @@ main(argc, argv) } } - printf("Statistics from %s", ctime(&stat.stat_itime)); - printf(" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis%s\n", - mnames ? " Mailer" : ""); + if (progmode) + { + time(&now); + printf("%ld %ld\n", (long) stat.stat_itime, (long) now); + } + else + { + printf("Statistics from %s", ctime(&stat.stat_itime)); + printf(" M msgsfr bytes_from msgsto bytes_to msgsrej msgsdis%s\n", + mnames ? " Mailer" : ""); + } for (i = 0; i < MAXMAILERS; i++) { if (stat.stat_nf[i] || stat.stat_nt[i] || stat.stat_nr[i] || stat.stat_nd[i]) { - printf("%2d %8ld %10ldK %8ld %10ldK %6ld %6ld", i, + char *format; + + if (progmode) + format = "%2d %8ld %10ld %8ld %10ld %6ld %6ld"; + else + format = "%2d %8ld %10ldK %8ld %10ldK %6ld %6ld"; + printf(format, i, stat.stat_nf[i], stat.stat_bf[i], stat.stat_nt[i], stat.stat_bt[i], stat.stat_nr[i], stat.stat_nd[i]); @@ -249,8 +277,20 @@ main(argc, argv) dismsgs += stat.stat_nd[i]; } } - printf("=============================================================\n"); - printf(" T %8ld %10ldK %8ld %10ldK %6ld %6ld\n", - frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + if (progmode) + { + printf(" T %8ld %10ld %8ld %10ld %6ld %6ld\n", + frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + close(fd); + fd = open(sfile, O_RDWR | O_TRUNC); + if (fd > 0) + close(fd); + } + else + { + printf("=============================================================\n"); + printf(" T %8ld %10ldK %8ld %10ldK %6ld %6ld\n", + frmsgs, frbytes, tomsgs, tobytes, rejmsgs, dismsgs); + } exit(EX_OK); } |