Commit | Line | Data |
---|---|---|
aeb2545d DF |
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 | |
383bfacd | 18 | static char SccsId[] = "@(#)mailstats.c 5.3 (Berkeley) %G%"; |
aeb2545d | 19 | #endif not lint |
9064e1ea | 20 | |
383bfacd JB |
21 | # include "../src/sendmail.h" |
22 | # include "../src/mailstats.h" | |
9064e1ea EA |
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; | |
71df6b97 | 39 | char *sfile = "/usr/lib/sendmail.st"; |
9064e1ea | 40 | register int i; |
387e90c7 | 41 | extern char *ctime(); |
9064e1ea EA |
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 | { | |
aad3cd02 | 52 | (void) fprintf(stderr, "File size change\n"); |
9064e1ea EA |
53 | exit(EX_OSERR); |
54 | } | |
55 | ||
387e90c7 | 56 | printf("Statistics from %s", ctime(&stat.stat_itime)); |
9064e1ea EA |
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); | |
4b13af04 EA |
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]); | |
9064e1ea EA |
65 | } |
66 | } |