122724Sdist /* 2*34914Sbostic * Copyright (c) 1983 Eric P. Allman 334047Sbostic * Copyright (c) 1988 Regents of the University of California. 434047Sbostic * All rights reserved. 534047Sbostic * 634047Sbostic * Redistribution and use in source and binary forms are permitted 7*34914Sbostic * provided that the above copyright notice and this paragraph are 8*34914Sbostic * duplicated in all such forms and that any documentation, 9*34914Sbostic * advertising materials, and other materials related to such 10*34914Sbostic * distribution and use acknowledge that the software was developed 11*34914Sbostic * by the University of California, Berkeley. The name of the 12*34914Sbostic * University may not be used to endorse or promote products derived 13*34914Sbostic * from this software without specific prior written permission. 14*34914Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 15*34914Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 16*34914Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 1734047Sbostic * 1834047Sbostic */ 1922724Sdist 2022724Sdist #ifndef lint 2122724Sdist char copyright[] = 2234047Sbostic "@(#) Copyright (c) 1988 Regents of the University of California.\n\ 2322724Sdist All rights reserved.\n"; 2434047Sbostic #endif /* not lint */ 2522724Sdist 2622724Sdist #ifndef lint 27*34914Sbostic static char sccsid[] = "@(#)mailstats.c 5.5 (Berkeley) 06/29/88"; 2834047Sbostic #endif /* not lint */ 294379Seric 3034047Sbostic #include <sys/file.h> 3134047Sbostic #include <sendmail.h> 3234047Sbostic #include <mailstats.h> 334379Seric 344379Seric main(argc, argv) 3534047Sbostic int argc; 3634047Sbostic char **argv; 374379Seric { 3834047Sbostic extern char *optarg; 3934047Sbostic extern int optind; 404379Seric struct statistics stat; 414379Seric register int i; 4234047Sbostic int ch, fd; 4334047Sbostic char *sfile, *ctime(); 444379Seric 4534047Sbostic sfile = "/usr/lib/sendmail.st"; 4634047Sbostic while ((ch = getopt(argc, argv, "f:")) != EOF) 4734047Sbostic switch((char)ch) { 4834047Sbostic case 'f': 4934047Sbostic sfile = optarg; 5034047Sbostic break; 5134047Sbostic case '?': 5234047Sbostic default: 5334047Sbostic fputs("usage: mailstats [-f file]\n", stderr); 5434047Sbostic exit(EX_USAGE); 5534047Sbostic } 5634047Sbostic argc -= optind; 5734047Sbostic argv += optind; 5834047Sbostic 5934047Sbostic if ((fd = open(sfile, O_RDONLY)) < 0) { 6034047Sbostic fputs("mailstats: ", stderr); 614379Seric perror(sfile); 624379Seric exit(EX_NOINPUT); 634379Seric } 6434047Sbostic if (read(fd, &stat, sizeof(stat)) != sizeof(stat) || 6534047Sbostic stat.stat_size != sizeof(stat)) { 6634047Sbostic fputs("mailstats: file size changed.\n", stderr); 674379Seric exit(EX_OSERR); 684379Seric } 694379Seric 704380Seric printf("Statistics from %s", ctime(&stat.stat_itime)); 714379Seric printf(" M msgsfr bytes_from msgsto bytes_to\n"); 724379Seric for (i = 0; i < MAXMAILERS; i++) 7334047Sbostic if (stat.stat_nf[i] || stat.stat_nt[i]) 7434047Sbostic printf("%2d %6ld %10ldK %6ld %10ldK\n", i, 7534047Sbostic stat.stat_nf[i], stat.stat_bf[i], 7634047Sbostic stat.stat_nt[i], stat.stat_bt[i]); 7734047Sbostic exit(0); 784379Seric } 79