** Copyright (c) 1983 Eric P. Allman
** Copyright (c) 1983 Regents of the University of California.
** All rights reserved. The Berkeley software License Agreement
** specifies the terms and conditions for redistribution.
static char SccsId
[] = "@(#)stats.c 5.4 (Berkeley) %G%";
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 long kbytes(); /* for _bf, _bt */
** MARKSTATS -- mark statistics
Stat
.stat_nf
[e
->e_from
.q_mailer
->m_mno
]++;
Stat
.stat_bf
[e
->e_from
.q_mailer
->m_mno
] += kbytes(CurEnv
->e_msgsize
);
Stat
.stat_nt
[to
->q_mailer
->m_mno
]++;
Stat
.stat_bt
[to
->q_mailer
->m_mno
] += kbytes(CurEnv
->e_msgsize
);
** POSTSTATS -- post statistics in the statistics file
** sfile -- the name of the statistics file.
** merges the Stat structure with the sfile file.
(void) time(&Stat
.stat_itime
);
Stat
.stat_size
= sizeof Stat
;
if (read(fd
, (char *) &stat
, sizeof stat
) == sizeof stat
&&
stat
.stat_size
== sizeof stat
)
/* merge current statistics into statfile */
for (i
= 0; i
< MAXMAILERS
; i
++)
stat
.stat_nf
[i
] += Stat
.stat_nf
[i
];
stat
.stat_bf
[i
] += Stat
.stat_bf
[i
];
stat
.stat_nt
[i
] += Stat
.stat_nt
[i
];
stat
.stat_bt
[i
] += Stat
.stat_bt
[i
];
bcopy((char *) &Stat
, (char *) &stat
, sizeof stat
);
(void) lseek(fd
, (off_t
) 0, 0);
(void) write(fd
, (char *) &stat
, sizeof stat
);
** KBYTES -- given a number, returns the number of Kbytes.
** Used in statistics gathering of message sizes to try to avoid
** wraparound (at least for a while.....)
** bytes -- actual number of bytes.
** This function is actually a ceiling function to
** Honestly folks, floating point might be better.
** Or perhaps a "statistical" log method.
return ((bytes
+ 999) / 1000);