summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/mailstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-01-12 12:26:57 +0000
committerpeter <peter@FreeBSD.org>1999-01-12 12:26:57 +0000
commit2a7bd60222ce3c09208a265ad3a5f1490ccb6768 (patch)
tree8d45e99e5e320ab4e55408b355a04b2be475a0ed /contrib/sendmail/mailstats
parent329949050501501c130d09efc3aee7c78c6d4f9c (diff)
downloadFreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.zip
FreeBSD-src-2a7bd60222ce3c09208a265ad3a5f1490ccb6768.tar.gz
Import sendmail-8.9.2 onto vendor branch (update from 8.9.1)
Obtained from: ftp.sendamil.org
Diffstat (limited to 'contrib/sendmail/mailstats')
-rw-r--r--contrib/sendmail/mailstats/Makefile.m46
-rw-r--r--contrib/sendmail/mailstats/mailstats.818
-rw-r--r--contrib/sendmail/mailstats/mailstats.c60
3 files changed, 68 insertions, 16 deletions
diff --git a/contrib/sendmail/mailstats/Makefile.m4 b/contrib/sendmail/mailstats/Makefile.m4
index ae5489c..2de9904 100644
--- a/contrib/sendmail/mailstats/Makefile.m4
+++ b/contrib/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/contrib/sendmail/mailstats/mailstats.8 b/contrib/sendmail/mailstats/mailstats.8
index 3a8847a..be2203d 100644
--- a/contrib/sendmail/mailstats/mailstats.8
+++ b/contrib/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/contrib/sendmail/mailstats/mailstats.c b/contrib/sendmail/mailstats/mailstats.c
index 6fda6db..5df3b95 100644
--- a/contrib/sendmail/mailstats/mailstats.c
+++ b/contrib/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);
}
OpenPOWER on IntegriCloud