/[pkg-mixmaster]/trunk/Mix/Src/stats.c
ViewVC logotype

Diff of /trunk/Mix/Src/stats.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 391 by weaselp, Wed Oct 9 20:53:32 2002 UTC revision 392 by weaselp, Sun Dec 8 00:56:23 2002 UTC
# Line 6  Line 6 
6     details.     details.
7    
8     Remailer statistics     Remailer statistics
9     $Id: stats.c,v 1.16 2002/10/09 20:53:32 weaselp Exp $ */     $Id: stats.c,v 1.17 2002/12/08 00:56:23 weaselp Exp $ */
10    
11    
12  #include "mix3.h"  #include "mix3.h"
# Line 59  int stats(BUFFER *b) Line 59  int stats(BUFFER *b)
59    long now, today, then;    long now, today, then;
60    time_t t;    time_t t;
61    long updated = 0, havestats = 0;    long updated = 0, havestats = 0;
62    int msgd[3][24], msg[3][80];    int msgd[7][24], msg[7][80];
63      /* 0 .. Unencrypted
64       * 1 .. Type I PGP
65       * 2 .. Mix
66       *
67       * 3 .. intermediate
68       * 4 .. final hop mail
69       * 5 .. final hop news
70       * 6 .. randhopped (will get counted in intermediate again)
71       */
72    int poold[2][24], pool[2][80];    int poold[2][24], pool[2][80];
73    int i, num, type, assigned, daysum;    int i, num, type, assigned, daysum;
74    char c;    char c;
# Line 69  int stats(BUFFER *b) Line 78  int stats(BUFFER *b)
78    today = (now / SECONDSPERDAY) * SECONDSPERDAY;    today = (now / SECONDSPERDAY) * SECONDSPERDAY;
79    
80    for (i = 0; i < 24; i++)    for (i = 0; i < 24; i++)
81      msgd[0][i] = msgd[1][i] = msgd[2][i] = poold[0][i] = poold[1][i] = 0;      msgd[0][i] = msgd[1][i] = msgd[2][i] = msgd[3][i] = msgd[4][i] = msgd[5][i] = msgd[6][i]= poold[0][i] = poold[1][i] = 0;
82    for (i = 0; i < 80; i++)    for (i = 0; i < 80; i++)
83      msg[0][i] = msg[1][i] = msg[2][i] = pool[0][i] = pool[1][i] = 0;      msg[0][i] = msg[1][i] = msg[2][i] = msg[3][i] = msg[4][i] = msg[5][i] = msg[6][i] = pool[0][i] = pool[1][i] = 0;
84    
85    s = mix_openfile(STATS, "r");    s = mix_openfile(STATS, "r");
86    if (s != NULL) {    if (s != NULL) {
# Line 82  int stats(BUFFER *b) Line 91  int stats(BUFFER *b)
91        case '0':        case '0':
92        case '1':        case '1':
93        case '2':        case '2':
94          case '3':
95          case '4':
96          case '5':
97          case '6':
98          c = '\0';          c = '\0';
99          assigned = sscanf(line, "%d %d %ld %c", &type, &num, &then, &c);          assigned = sscanf(line, "%d %d %ld %c", &type, &num, &then, &c);
100          daysum = (assigned == 4 && c == 'd');          daysum = (assigned == 4 && c == 'd');
# Line 146  int stats(BUFFER *b) Line 159  int stats(BUFFER *b)
159    lock(s);    lock(s);
160    fprintf(s, "%ld\n", (long) time(NULL));       /* time of stats.log update */    fprintf(s, "%ld\n", (long) time(NULL));       /* time of stats.log update */
161    for (i = 0; i < 24; i++) {    for (i = 0; i < 24; i++) {
162      for (type = 0; type < 3; type++)      for (type = 0; type < 7; type++)
163        if (msgd[type][i] > 0)        if (msgd[type][i] > 0)
164          fprintf(s, "%d %d %ld\n", type, msgd[type][i], now - i * 60 * 60);          fprintf(s, "%d %d %ld\n", type, msgd[type][i], now - i * 60 * 60);
165      if (poold[0][i] > 0)      if (poold[0][i] > 0)
166        fprintf(s, "p %d %d %ld\n", poold[0][i], poold[1][i], now - i * 60 * 60);        fprintf(s, "p %d %d %ld\n", poold[0][i], poold[1][i], now - i * 60 * 60);
167    }    }
168    for (i = 0; i < 80; i++) {    for (i = 0; i < 80; i++) {
169      for (type = 0; type < 3; type++)      for (type = 0; type < 7; type++)
170        if (msg[type][i] > 0)        if (msg[type][i] > 0)
171          fprintf(s, "%d %d %ld d\n", type, msg[type][i],          fprintf(s, "%d %d %ld d\n", type, msg[type][i],
172                  today - i * 24 * 60 * 60);                  today - i * 24 * 60 * 60);
# Line 212  int stats(BUFFER *b) Line 225  int stats(BUFFER *b)
225          buf_appendf(b, "     Unencrypted:%4d", msg[0][i]);          buf_appendf(b, "     Unencrypted:%4d", msg[0][i]);
226        if (pool[0][i] > 0)        if (pool[0][i] > 0)
227          buf_appendf(b, "  [Pool size:%4d]", pool[1][i] / pool[0][i]);          buf_appendf(b, "  [Pool size:%4d]", pool[1][i] / pool[0][i]);
228          if (STATSDETAILS) {
229            buf_appendf(b, "  Intermediate:%4d", msg[3][i]);
230            buf_appendf(b, "  Mail:%4d", msg[4][i]);
231            buf_appendf(b, "  Postings:%4d", msg[5][i]);
232            if (MIDDLEMAN)
233              buf_appendf(b, "  Randhopped:%4d", msg[6][i]);
234          }
235  #if 0  #if 0
236        else        else
237          buf_appends(b, "  [ no remailing ]");          buf_appends(b, "  [ no remailing ]");

Legend:
Removed from v.391  
changed lines
  Added in v.392

  ViewVC Help
Powered by ViewVC 1.1.5