| 6 |
details. |
details. |
| 7 |
|
|
| 8 |
Remailer statistics |
Remailer statistics |
| 9 |
$Id: stats.c,v 1.12 2002/08/22 08:13:36 weaselp Exp $ */ |
$Id: stats.c,v 1.13 2002/08/25 07:52:28 weaselp Exp $ */ |
| 10 |
|
|
| 11 |
|
|
| 12 |
#include "mix3.h" |
#include "mix3.h" |
| 58 |
long updated = 0, havestats = 0; |
long updated = 0, havestats = 0; |
| 59 |
int msgd[3][24], msg[3][80]; |
int msgd[3][24], msg[3][80]; |
| 60 |
int poold[2][24], pool[2][80]; |
int poold[2][24], pool[2][80]; |
| 61 |
int i, num, type; |
int i, num, type, assigned, daysum; |
| 62 |
|
char c; |
| 63 |
idlog_t idbuf; |
idlog_t idbuf; |
| 64 |
|
|
| 65 |
now = (time(NULL) / (60 * 60) + 1) * 60 * 60; |
now = (time(NULL) / (60 * 60) + 1) * 60 * 60; |
| 79 |
case '0': |
case '0': |
| 80 |
case '1': |
case '1': |
| 81 |
case '2': |
case '2': |
| 82 |
sscanf(line, "%d %d %ld", &type, &num, &then); |
c = '\0'; |
| 83 |
if (now - then < 0) |
assigned = sscanf(line, "%d %d %ld %c", &type, &num, &then, &c); |
| 84 |
|
daysum = (assigned == 4 && c == 'd'); |
| 85 |
|
|
| 86 |
|
if (now - then < 0 || (daysum && today - then < 0)) |
| 87 |
break; /* keep memory consistent even if the time |
break; /* keep memory consistent even if the time |
| 88 |
suddenly goes backwards :) */ |
suddenly goes backwards :) */ |
| 89 |
if (now - then < SECONDSPERDAY) |
if (now - then < SECONDSPERDAY && !daysum) |
| 90 |
msgd[type][(now - then) / (60 * 60)] += num; |
msgd[type][(now - then) / (60 * 60)] += num; |
| 91 |
else if (today - then < 80 * SECONDSPERDAY) |
else if (today - then < 80 * SECONDSPERDAY) |
| 92 |
msg[type][(today - then) / SECONDSPERDAY] += num; |
msg[type][(today - then) / SECONDSPERDAY] += num; |
| 94 |
havestats = then; |
havestats = then; |
| 95 |
break; |
break; |
| 96 |
case 'p': |
case 'p': |
| 97 |
sscanf(line, "p %d %d %ld", &num, &i, &then); |
c = '\0'; |
| 98 |
if (now - then < 0) |
assigned = sscanf(line, "p %d %d %ld %c", &num, &i, &then, &c); |
| 99 |
|
daysum = (assigned == 4 && c == 'd'); |
| 100 |
|
|
| 101 |
|
if (now - then < 0 || (daysum && today - then < 0)) |
| 102 |
break; |
break; |
| 103 |
if (now - then < SECONDSPERDAY) { |
if (now - then < SECONDSPERDAY && !daysum) { |
| 104 |
poold[0][(now - then) / (60 * 60)] += num; |
poold[0][(now - then) / (60 * 60)] += num; |
| 105 |
poold[1][(now - then) / (60 * 60)] += i; |
poold[1][(now - then) / (60 * 60)] += i; |
| 106 |
} else if (today - then < 80 * SECONDSPERDAY) { |
} else if (today - then < 80 * SECONDSPERDAY) { |
| 152 |
for (i = 0; i < 80; i++) { |
for (i = 0; i < 80; i++) { |
| 153 |
for (type = 0; type < 3; type++) |
for (type = 0; type < 3; type++) |
| 154 |
if (msg[type][i] > 0) |
if (msg[type][i] > 0) |
| 155 |
fprintf(s, "%d %d %ld\n", type, msg[type][i], |
fprintf(s, "%d %d %ld d\n", type, msg[type][i], |
| 156 |
today - i * 24 * 60 * 60); |
today - i * 24 * 60 * 60); |
| 157 |
if (pool[0][i] > 0) |
if (pool[0][i] > 0) |
| 158 |
fprintf(s, "p %d %d %ld\n", pool[0][i], pool[1][i], |
fprintf(s, "p %d %d %ld d\n", pool[0][i], pool[1][i], |
| 159 |
today - i * 24 * 60 * 60); |
today - i * 24 * 60 * 60); |
| 160 |
} |
} |
| 161 |
unlock(s); |
unlock(s); |