collect mail statistics; change minor configuration
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Sep 1981 12:21:48 +0000 (04:21 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Sep 1981 12:21:48 +0000 (04:21 -0800)
SCCS-vsn: usr.sbin/sendmail/src/conf.c 3.26
SCCS-vsn: usr.sbin/sendmail/src/deliver.c 3.32
SCCS-vsn: usr.sbin/sendmail/src/sendmail.h 3.35
SCCS-vsn: usr.sbin/sendmail/src/main.c 3.30

usr/src/usr.sbin/sendmail/src/conf.c
usr/src/usr.sbin/sendmail/src/deliver.c
usr/src/usr.sbin/sendmail/src/main.c
usr/src/usr.sbin/sendmail/src/sendmail.h

index 3094f19..53a11f7 100644 (file)
@@ -32,7 +32,7 @@
 
 
 
 
 
 
-static char SccsId[] = "@(#)conf.c     3.25    %G%";
+static char SccsId[] = "@(#)conf.c     3.26    %G%";
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
 
 
 # include <whoami.h>           /* definitions of machine id's at berkeley */
@@ -91,6 +91,18 @@ char Arpa_Fmsg[] =   "250";  /* mail successful (MLFL cmd) */
 char   Arpa_Syserr[] = "455";  /* some (transient) system error */
 char   Arpa_Usrerr[] = "450";  /* some (fatal) user error */
 # endif NEWFTP
 char   Arpa_Syserr[] = "455";  /* some (transient) system error */
 char   Arpa_Usrerr[] = "450";  /* some (fatal) user error */
 # endif NEWFTP
+
+
+
+
+
+/*
+**  Location of system files/databases/etc.
+*/
+
+char   *AliasFile =    "/usr/lib/aliases";     /* alias file */
+char   *ConfFile =     "/usr/lib/sendmail.cf"; /* runtime configuration */
+char   *StatFile =     "/usr/eric/mailstats";  /* statistics summary */
 \f
 # ifdef V6
 /*
 \f
 # ifdef V6
 /*
index e02f392..e1fe56f 100644 (file)
@@ -5,7 +5,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char SccsId[] = "@(#)deliver.c  3.31    %G%";
+static char SccsId[] = "@(#)deliver.c  3.32    %G%";
 
 /*
 **  DELIVER -- Deliver a message to a particular address.
 
 /*
 **  DELIVER -- Deliver a message to a particular address.
@@ -175,6 +175,10 @@ deliver(to, editfcn)
                if (bitset(QBADADDR, to->q_flags))
                        continue;
 
                if (bitset(QBADADDR, to->q_flags))
                        continue;
 
+               /* save statistics.... */
+               Stat.stat_nt[to->q_mailer]++;
+               Stat.stat_bt[to->q_mailer] += kbytes(MsgSize);
+
                /*
                **  See if this user name is "special".
                **      If the user name has a slash in it, assume that this
                /*
                **  See if this user name is "special".
                **      If the user name has a slash in it, assume that this
@@ -457,7 +461,6 @@ giveresponse(stat, force, m)
        extern char *SysExMsg[];
        register int i;
        extern int N_SysEx;
        extern char *SysExMsg[];
        register int i;
        extern int N_SysEx;
-       extern long MsgSize;
        char buf[30];
 
        i = stat - EX__BASE;
        char buf[30];
 
        i = stat - EX__BASE;
index 4a6f7dd..0a7e98f 100644 (file)
@@ -5,7 +5,7 @@
 # include <syslog.h>
 # endif LOG
 
 # include <syslog.h>
 # endif LOG
 
-static char    SccsId[] = "@(#)main.c  3.29    %G%";
+static char    SccsId[] = "@(#)main.c  3.30    %G%";
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
 
 /*
 **  SENDMAIL -- Post mail to a set of destinations.
@@ -160,8 +160,9 @@ main(argc, argv)
        char nbuf[MAXLINE];             /* holds full name */
        struct passwd *pw;
        extern char *arpadate();
        char nbuf[MAXLINE];             /* holds full name */
        struct passwd *pw;
        extern char *arpadate();
-       char *cfname;
-       char *aliasname;
+       extern char *AliasFile;         /* location of alias file */
+       extern char *ConfFile;          /* location of configuration file */
+       extern char *StatFile;          /* location of statistics summary */
        register int i;
        bool verifyonly = FALSE;        /* only verify names */
        bool safecf = TRUE;             /* this conf file is sys default */
        register int i;
        bool verifyonly = FALSE;        /* only verify names */
        bool safecf = TRUE;             /* this conf file is sys default */
@@ -205,8 +206,6 @@ main(argc, argv)
        */
 
        from = NULL;
        */
 
        from = NULL;
-       cfname = CONFFILE;
-       aliasname = ALIASFILE;
 
        /* process id */
        (void) sprintf(pbuf, "%d", getpid());
 
        /* process id */
        (void) sprintf(pbuf, "%d", getpid());
@@ -332,17 +331,17 @@ main(argc, argv)
 
                  case 'C':     /* select configuration file */
                        if (p[2] == '\0')
 
                  case 'C':     /* select configuration file */
                        if (p[2] == '\0')
-                               cfname = "sendmail.cf";
+                               ConfFile = "sendmail.cf";
                        else
                        else
-                               cfname = &p[2];
+                               ConfFile = &p[2];
                        safecf = FALSE;
                        break;
 
                  case 'A':     /* select alias file */
                        if (p[2] == '\0')
                        safecf = FALSE;
                        break;
 
                  case 'A':     /* select alias file */
                        if (p[2] == '\0')
-                               aliasname = "aliases";
+                               AliasFile = "aliases";
                        else
                        else
-                               aliasname = &p[2];
+                               AliasFile = &p[2];
                        break;
                
                  case 'n':     /* don't alias */
                        break;
                
                  case 'n':     /* don't alias */
@@ -408,7 +407,7 @@ main(argc, argv)
        **  Read control file.
        */
 
        **  Read control file.
        */
 
-       readcf(cfname, safecf);
+       readcf(ConfFile, safecf);
 
 # ifndef V6
        p = getenv("HOME");
 
 # ifndef V6
        p = getenv("HOME");
@@ -423,7 +422,7 @@ main(argc, argv)
        }
 # endif V6
 
        }
 # endif V6
 
-       initaliases(aliasname, aliasinit);
+       initaliases(AliasFile, aliasinit);
 # ifdef DBM
        if (aliasinit)
                exit(EX_OK);
 # ifdef DBM
        if (aliasinit)
                exit(EX_OK);
@@ -584,6 +583,10 @@ main(argc, argv)
        if (verifyonly && GrabTo)
                finis();
 
        if (verifyonly && GrabTo)
                finis();
 
+       /* collect statistics */
+       Stat.stat_nf[From.q_mailer]++;
+       Stat.stat_bf[From.q_mailer] += kbytes(MsgSize);
+
        /*
        **  Arrange that the person who is sending the mail
        **  will not be expanded (unless explicitly requested).
        /*
        **  Arrange that the person who is sending the mail
        **  will not be expanded (unless explicitly requested).
@@ -629,6 +632,7 @@ main(argc, argv)
                        break;
                }
        }
                        break;
                }
        }
+       poststats(StatFile);
        finis();
 }
 \f/*
        finis();
 }
 \f/*
index 5c0dbac..aec8fa2 100644 (file)
@@ -1,7 +1,7 @@
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
 /*
 **  SENDMAIL.H -- Global definitions for sendmail.
 **
-**     @(#)sendmail.h  3.34    %G%
+**     @(#)sendmail.h  3.35    %G%
 */
 
 
 */
 
 
@@ -12,7 +12,8 @@
 # include "useful.h"
 
 /*
 # include "useful.h"
 
 /*
-**  Manifest constants.
+**  Configuration constants.
+**     There shouldn't be much need to change these....
 */
 
 # define MAXLINE       256     /* maximum line length */
 */
 
 # define MAXLINE       256     /* maximum line length */
@@ -22,8 +23,6 @@
 # define MAXHOP                30      /* maximum value of HopCount */
 # define MAXATOM       15      /* max atoms per address */
 # define MAXMAILERS    10      /* maximum mailers known to system */
 # define MAXHOP                30      /* maximum value of HopCount */
 # define MAXATOM       15      /* max atoms per address */
 # define MAXMAILERS    10      /* maximum mailers known to system */
-# define ALIASFILE     "/usr/lib/aliases"      /* location of alias file */
-# define CONFFILE      "/usr/lib/sendmail.cf"  /* configuration file */
 
 /* values for ArpaMode -- these are ordered!! */
 # define ARPA_NONE     0       /* not in arpanet mode */
 
 /* values for ArpaMode -- these are ordered!! */
 # define ARPA_NONE     0       /* not in arpanet mode */
@@ -230,11 +229,30 @@ extern STAB       *stab();
 
 
 
 
 
 
+/*
+**  Statistics structure.
+*/
+
+struct statistics
+{
+       time_t  stat_itime;             /* file initialization time */
+       short   stat_size;              /* size of this structure */
+       long    stat_nf[MAXMAILERS];    /* # msgs from each mailer */
+       long    stat_bf[MAXMAILERS];    /* kbytes from each mailer */
+       long    stat_nt[MAXMAILERS];    /* # msgs to each mailer */
+       long    stat_bt[MAXMAILERS];    /* kbytes to each mailer */
+};
+
+extern struct statistics       Stat;
+extern long                    kbytes();       /* for _bf, _bt */
+
+
+
+
 /*
 **  Global variables.
 */
 
 /*
 **  Global variables.
 */
 
-extern int     ArpaMode;       /* ARPANET handling mode */
 extern bool    FromFlag;       /* if set, "From" person is explicit */
 extern bool    MailBack;       /* mail back response on error */
 extern bool    BerkNet;        /* called from BerkNet */
 extern bool    FromFlag;       /* if set, "From" person is explicit */
 extern bool    MailBack;       /* mail back response on error */
 extern bool    BerkNet;        /* called from BerkNet */
@@ -250,6 +268,8 @@ extern bool DontSend;       /* mark recipients as QDONTSEND */
 extern int     Debug;          /* debugging level */
 extern int     Errors;         /* set if errors */
 extern int     ExitStat;       /* exit status code */
 extern int     Debug;          /* debugging level */
 extern int     Errors;         /* set if errors */
 extern int     ExitStat;       /* exit status code */
+extern int     ArpaMode;       /* ARPANET handling mode */
+extern long    MsgSize;        /* size of the message in bytes */
 extern char    InFileName[];   /* input file name */
 extern char    Transcript[];   /* the transcript file name */
 extern FILE    *TempFile;      /* mail temp file */
 extern char    InFileName[];   /* input file name */
 extern char    Transcript[];   /* the transcript file name */
 extern FILE    *TempFile;      /* mail temp file */