1 /*
2 **  Sendmail
3 **  Copyright (c) 1983  Eric P. Allman
4 **  Berkeley, California
5 **
6 **  Copyright (c) 1983 Regents of the University of California.
7 **  All rights reserved.  The Berkeley software License Agreement
8 **  specifies the terms and conditions for redistribution.
9 */
10 
11 #ifndef lint
12 char copyright[] =
13 "@(#) Copyright (c) 1980 Regents of the University of California.\n\
14  All rights reserved.\n";
15 #endif not lint
16 
17 #ifndef lint
18 static char	SccsId[] = "@(#)mailstats.c	5.2 (Berkeley) 05/02/86";
19 #endif not lint
20 # include "sendmail.h"
21 
22 SCCSID(@(#)mailstats.c	5.2		05/02/86);
23 
24 /*
25 **  MAILSTATS -- print mail statistics.
26 **
27 **	Flags:
28 **		-Ffile		Name of statistics file.
29 **
30 **	Exit Status:
31 **		zero.
32 */
33 
34 main(argc, argv)
35 	char  **argv;
36 {
37 	register int fd;
38 	struct statistics stat;
39 	char *sfile = "/usr/lib/sendmail.st";
40 	register int i;
41 	extern char *ctime();
42 
43 	fd = open(sfile, 0);
44 	if (fd < 0)
45 	{
46 		perror(sfile);
47 		exit(EX_NOINPUT);
48 	}
49 	if (read(fd, &stat, sizeof stat) != sizeof stat ||
50 	    stat.stat_size != sizeof stat)
51 	{
52 		(void) fprintf(stderr, "File size change\n");
53 		exit(EX_OSERR);
54 	}
55 
56 	printf("Statistics from %s", ctime(&stat.stat_itime));
57 	printf(" M msgsfr bytes_from  msgsto   bytes_to\n");
58 	for (i = 0; i < MAXMAILERS; i++)
59 	{
60 		if (stat.stat_nf[i] == 0 && stat.stat_nt[i] == 0)
61 			continue;
62 		printf("%2d ", i);
63 		printf("%6ld %10ldK ", stat.stat_nf[i], stat.stat_bf[i]);
64 		printf("%6ld %10ldK\n", stat.stat_nt[i], stat.stat_bt[i]);
65 	}
66 }
67