1 # include "sendmail.h" 2 3 SCCSID(@(#)mailstats.c 4.1 07/25/83); 4 5 /* 6 ** MAILSTATS -- print mail statistics. 7 ** 8 ** Flags: 9 ** -Ffile Name of statistics file. 10 ** 11 ** Exit Status: 12 ** zero. 13 */ 14 15 main(argc, argv) 16 char **argv; 17 { 18 register int fd; 19 struct statistics stat; 20 char *sfile = "/usr/lib/sendmail.st"; 21 register int i; 22 extern char *ctime(); 23 24 fd = open(sfile, 0); 25 if (fd < 0) 26 { 27 perror(sfile); 28 exit(EX_NOINPUT); 29 } 30 if (read(fd, &stat, sizeof stat) != sizeof stat || 31 stat.stat_size != sizeof stat) 32 { 33 (void) sprintf(stderr, "File size change\n"); 34 exit(EX_OSERR); 35 } 36 37 printf("Statistics from %s", ctime(&stat.stat_itime)); 38 printf(" M msgsfr bytes_from msgsto bytes_to\n"); 39 for (i = 0; i < MAXMAILERS; i++) 40 { 41 if (stat.stat_nf[i] == 0 && stat.stat_nt[i] == 0) 42 continue; 43 printf("%2d ", i); 44 printf("%6ld %10ldK ", stat.stat_nf[i], stat.stat_bf[i]); 45 printf("%6ld %10ldK\n", stat.stat_nt[i], stat.stat_bt[i]); 46 } 47 } 48