Ticket #135: diff-inn-2.2.x-artstat+list+overstat

File diff-inn-2.2.x-artstat+list+overstat, 15.1 KB (added by Julien ÉLIE, 8 years ago)
Line 
1diff -Nur inn/nnrpd/article.c inn-patched/nnrpd/article.c
2--- inn/nnrpd/article.c Mon Aug 30 19:17:39 1999
3+++ inn-patched/nnrpd/article.c Sat Mar 25 14:43:19 2000
4@@ -654,7 +654,7 @@
5                     SendIOb(".", 1);
6                 SendIOb(q, p - q);
7                 SendIOb("\r\n", 2);
8-                ARTgetsize += p - q + 2;
9+                bytecount += p - q + 2;
10                 q = p + 1;
11             }
12         }
13@@ -664,20 +664,20 @@
14     if (!WireFormat) {
15         SendIOb(".\r\n", 3);
16         PushIOb();
17-        ARTgetsize += 3;
18+        bytecount += 3;
19     } else {
20        SendIOv(q, p - q);
21-       ARTgetsize += p - q;
22+       bytecount += p - q;
23        if (what == SThead) {
24            SendIOv(".\r\n", 3);
25-           ARTgetsize += 3;
26+           bytecount += 3;
27        } else if (memcmp((ARTmem+ARTlen-5), "\r\n.\r\n", 5)) {
28            if (memcmp((ARTmem+ARTlen-2), "\r\n", 2)) {
29                SendIOv("\r\n.\r\n", 5);
30-               ARTgetsize += 5;
31+               bytecount += 5;
32                   } else {
33                SendIOv(".\r\n", 3);
34-               ARTgetsize += 3;
35+               bytecount += 3;
36                   }
37        }
38        PushIOv();
39@@ -685,6 +685,8 @@
40     
41     gettimeofday(&etv, NULL);
42     ARTget++;
43+    ARTgetsize+=bytecount;
44+    GRPartsize+=bytecount;
45     ARTgettime+=(etv.tv_sec - stv.tv_sec) * 1000;
46     ARTgettime+=(etv.tv_usec - stv.tv_usec) / 1000;
47 }
48@@ -713,20 +715,22 @@
49            break;
50        if (what == STbody)
51            continue;
52-       ARTgetsize+=Printf("%s%s\r\n", *p == '.' ? "." : "", p);
53+       bytecount+=Printf("%s%s\r\n", *p == '.' ? "." : "", p);
54     }
55     if (what == SThead) {
56        Printf(".\r\n");
57-       ARTgetsize+=3;
58+       bytecount+=3;
59         gettimeofday(&etv, NULL);
60         ARTget++;
61+       ARTgetsize+=bytecount;
62+       GRPartsize+=bytecount;
63         ARTgettime+=(etv.tv_sec - stv.tv_sec) * 1000;
64         ARTgettime+=(etv.tv_usec - stv.tv_usec) / 1000;
65        return;
66     }
67 
68     if (what == STarticle)
69-       ARTgetsize+=Printf("\r\n");
70+       bytecount+=Printf("\r\n");
71     for ( ; ; ) {
72        p = QIOread(ARTqp);
73        if (p == NULL) {
74@@ -734,11 +738,13 @@
75                continue;
76            break;
77        }
78-       ARTgetsize+=Printf("%s%s\r\n", *p == '.' ? "." : "", p);
79+       bytecount+=Printf("%s%s\r\n", *p == '.' ? "." : "", p);
80     }
81-    ARTgetsize+=Printf(".\r\n");
82+    bytecount+=Printf(".\r\n");
83     gettimeofday(&etv, NULL);
84     ARTget++;
85+    ARTgetsize+=bytecount;
86+    GRPartsize+=bytecount;
87     ARTgettime+=(etv.tv_sec - stv.tv_sec) * 1000;
88     ARTgettime+=(etv.tv_usec - stv.tv_usec) / 1000;
89 }
90@@ -1568,7 +1574,9 @@
91 
92        if (Opened && (p = OVERfind(ARTnumbers[i].ArtNum, &linelen)) != NULL) {
93            OVERhit++;
94+           GRPovercount++;
95            OVERsize+=linelen;
96+           GRPoversize+=linelen;
97            if ((innconf->storageapi && innconf->overviewmmap) || OVERmem) {
98                if (innconf->storageapi && innconf->overviewmmap) {
99                    (void)sprintf(buff, "%ld\t", ARTnumbers[i].ArtNum);
100@@ -1592,8 +1600,10 @@
101        (void)sprintf(buff, "%ld", ARTnumbers[i].ArtNum);
102        if ((p = OVERgen(buff)) != NULL) {
103            OVERmiss++;
104+           GRPovercount++;
105            linelen = strlen(p);
106            OVERsize+=linelen;
107+           GRPoversize+=linelen;
108            if (OVERmem) {
109                 SendIOb(p, linelen);
110                 SendIOb("\r\n", 2);
111diff -Nur inn/nnrpd/commands.c inn-patched/nnrpd/commands.c
112--- inn/nnrpd/commands.c        Tue May 11 07:18:13 1999
113+++ inn-patched/nnrpd/commands.c        Sat Mar 25 18:08:21 2000
114@@ -360,6 +360,7 @@
115     LISTINFO           *lp;
116     char               *wildarg = NULL;
117     char               savec;
118+    unsigned long      bytes = 0;
119 
120     p = av[1];
121     if (p == NULL || caseEQ(p, "active")) {
122@@ -382,11 +383,13 @@
123                grplist[1] = NULL;
124                Reply("%d list:\r\n", NNTP_LIST_FOLLOWS_VAL);
125                if (PERMmatch(PERMlist, grplist))
126-                       Printf("%s %ld %ld %c%s\r\n.\r\n",
127+                       bytes+=Printf("%s %ld %ld %c%s\r\n.\r\n",
128                                GPNAME(gp), (long)GPHIGH(gp), (long)GPLOW(gp),
129                                GPFLAG(gp), GPALIAS(gp) ? GPALIAS(gp) : "");
130                else
131-                       Printf(".\r\n");
132+                       bytes+=Printf(".\r\n");
133+               syslog(L_NOTICE, "%s list active bytes %ld",
134+                  ClientHost, bytes);
135                return;
136            }
137            wildarg = av[2];
138@@ -429,12 +432,16 @@
139     if ((qp = QIOopen(cpcatpath((char *)lp->Path, (char *)lp->File))) == NULL) {
140        if (!lp->Required && errno == ENOENT) {
141            Reply("%d %s.\r\n", NNTP_LIST_FOLLOWS_VAL, lp->Format);
142-           Printf(".\r\n");
143+           bytes+=Printf(".\r\n");
144+           syslog(L_NOTICE, "%s list %s bytes %ld",
145+               ClientHost, lp->File, bytes);
146        }
147        else {
148            syslog(L_ERROR, "%s cant fopen %s %m", ClientHost, lp->File);
149            Reply("%d No list of %s available.\r\n",
150                NNTP_TEMPERR_VAL, lp->Items);
151+           syslog(L_NOTICE, "%s list %s bytes 0",
152+               ClientHost, lp->File);
153        }
154        return;
155     }
156@@ -443,7 +450,9 @@
157     if (!PERMspecified) {
158        /* Optmize for unlikely case of no permissions and FALSE default. */
159        (void)QIOclose(qp);
160-       Printf(".\r\n");
161+       bytes+=Printf(".\r\n");
162+       syslog(L_NOTICE, "%s list %s bytes %ld",
163+           ClientHost, lp->File, bytes);
164        return;
165     }
166 
167@@ -453,7 +462,7 @@
168     /* Read lines, ignore long ones. */
169     while ((p = QIOread(qp)) != NULL) {
170        if (lp == &INFOmotd) {
171-           Printf("%s\r\n", p);
172+           bytes+=Printf("%s\r\n", p);
173            continue;
174        }
175        if (p[0] == '.' && p[1] == '\0') {
176@@ -477,13 +486,13 @@
177                    continue;
178                *save = ':';
179            }
180-           Printf("%s\r\n", p);
181+           bytes+=Printf("%s\r\n", p);
182            continue;
183        }
184        if (lp == &INFOdistribs || lp == &INFOmoderators ||
185            lp == &INFOschema) {
186            if (*p != '\0' && *p != '#' && *p != ';' && *p != ' ')
187-               Printf("%s\r\n", p);
188+               bytes+=Printf("%s\r\n", p);
189            continue;
190        }
191        savec = '\0';
192@@ -504,13 +513,14 @@
193            continue;
194        if (savec != '\0')
195            *save = savec;
196-       Printf("%s\r\n", p);
197+       bytes+=Printf("%s\r\n", p);
198     }
199     QIOclose(qp);
200 
201-    Printf(".\r\n");
202+    bytes+=Printf(".\r\n");
203+    syslog(L_NOTICE, "%s list %s bytes %ld",
204+       ClientHost, lp->File, bytes);
205 }
206-
207 
208 /*
209 **  Handle the "mode" command.
210diff -Nur inn/nnrpd/group.c inn-patched/nnrpd/group.c
211--- inn/nnrpd/group.c   Tue Jun 22 07:14:23 1999
212+++ inn-patched/nnrpd/group.c   Sat Mar 25 18:25:30 2000
213@@ -797,13 +797,19 @@
214     char               buff[SPOOLNAMEBUFF];
215     char               repbuff[1024], tmpbuff[80];
216 
217-    if (GRPlast[0] && GRParticles != 0) {
218+    if (GRPlast[0]) {
219        (void)strcpy(buff, GRPlast);
220        for (p = buff; *p; p++)
221            if (*p == '/')
222                *p = '.';
223-       syslog(L_NOTICE, "%s group %s %ld", ClientHost, buff, GRParticles);
224+       syslog(L_NOTICE,
225+         "%s group %s %ld articles %ld bytes %ld ovcount %ld ovbytes",
226+         ClientHost, buff, GRParticles, GRPartsize,
227+         GRPovercount, GRPoversize);
228        GRParticles = 0;
229+       GRPartsize = 0;
230+       GRPovercount = 0;
231+       GRPoversize = 0;
232        repbuff[0]='\0';
233        if (innconf->readertrack && (RARTcount > 0)) {
234                for (pp=0;pp<RARTcount; pp++) {
235diff -Nur inn/nnrpd/nnrpd.h inn-patched/nnrpd/nnrpd.h
236--- inn/nnrpd/nnrpd.h   Thu Oct 15 02:54:18 1998
237+++ inn-patched/nnrpd/nnrpd.h   Sat Mar 25 14:43:19 2000
238@@ -145,7 +145,10 @@
239 EXTERN char     (*OVERindex)[][OVERINDEXPACKSIZE];
240 EXTERN int      OVERicount;      /* Number of OVERINDEX entries at OVERindex */
241 EXTERN long    GRParticles;
242+EXTERN long    GRPartsize;
243 EXTERN long    GRPcount;
244+EXTERN long    GRPovercount;
245+EXTERN long    GRPoversize;
246 EXTERN char    GRPlast[SPOOLNAMEBUFF];
247 EXTERN long    POSTreceived;
248 EXTERN long    POSTrejected;
249diff -Nur inn/samples/inn.conf.in inn-patched/samples/inn.conf.in
250--- inn/samples/inn.conf.in     Sun Jan 31 07:25:58 1999
251+++ inn-patched/samples/inn.conf.in     Sat Mar 25 18:37:14 2000
252@@ -48,7 +48,7 @@
253 readerswhenstopped:    false
254 noreader:              false
255 extendeddbz:           false
256-nnrpdoverstats:                false
257+nnrpdoverstats:                true
258 storeonxref:           true
259 nnrpdcheckart:         true
260 storemsgid:            true
261diff -Nur inn/samples/innreport.conf.in inn-patched/samples/innreport.conf.in
262--- inn/samples/innreport.conf.in       Wed Dec 16 07:22:15 1998
263+++ inn-patched/samples/innreport.conf.in       Sat Mar 25 19:32:03 2000
264@@ -1459,6 +1459,116 @@
265         };
266 };
267 
268+section nnrpd_artstats {
269+        title   "NNRP article volume statistics:";
270+       data    "%nnrpd_artstats_size";
271+       sort    "$nnrpd_artstats_size{$b} <=> $nnrpd_artstats_size{$a}";
272+       numbering true;
273+        column {
274+                name          "System";
275+                format        "%-49.49s";
276+               value         "$key";
277+               format_total  "TOTAL: %-42.42s";
278+               total         "$num";
279+        };
280+        column {
281+                name          "kBytes";
282+                format_name   "%9s";
283+                format        "%9d";
284+               value         "$nnrpd_artstats_size{$key}/1024";
285+               total         "total(%nnrpd_artstats_size)/1024";
286+        };
287+        column {
288+                name          "Get";
289+                format_name   "%8s";
290+                format        "%8d";
291+               value         "$nnrpd_artstats_get{$key}";
292+               total         "total(%nnrpd_artstats_get)";
293+        };
294+        column {
295+                name          "Elapsed";
296+                format        "%10s";
297+               value         "time($nnrpd_artstats_time{$key})";
298+               total         "time(total(%nnrpd_artstats_time))";
299+        };
300+};
301+
302+section nnrpd_overstats {
303+        title   "NNRP overview statistics:";
304+       data    "%nnrpd_overstats_count";
305+       sort    "$nnrpd_overstats_count{$b} <=> $nnrpd_overstats_count{$a}";
306+       numbering true;
307+        column {
308+                name          "System";
309+                format        "%-36.36s";
310+               value         "$key";
311+               format_total  "TOTAL: %-29.29s";
312+               total         "$num";
313+        };
314+        column {
315+                name          "Count";
316+                format_name   "%6s";
317+                format        "%6d";
318+               value         "$nnrpd_overstats_count{$key}";
319+               total         "total(%nnrpd_overstats_count)";
320+        };
321+        column {
322+                name          "Hit";
323+                format_name   "%7s";
324+                format        "%7d";
325+               value         "$nnrpd_overstats_hit{$key}";
326+               total         "total(%nnrpd_overstats_hit)";
327+        };
328+        column {
329+                name          "Miss";
330+                format_name   "%7s";
331+                format        "%7d";
332+               value         "$nnrpd_overstats_miss{$key}";
333+               total         "total(%nnrpd_overstats_miss)";
334+        };
335+        column {
336+                name          "kBytes";
337+                format_name   "%9s";
338+                format        "%9d";
339+               value         "$nnrpd_overstats_size{$key}/1024";
340+               total         "total(%nnrpd_overstats_size)/1024";
341+        };
342+        column {
343+                name          "Elapsed";
344+                format        "%9s";
345+               value         "time($nnrpd_overstats_time{$key})";
346+               total         "time(total(%nnrpd_overstats_time))";
347+        };
348+};
349+
350+section nnrpd_list {
351+        title   "NNRP list commands:";
352+       data    "%nnrpd_list_count";
353+       sort    "$nnrpd_list_count{$b} <=> $nnrpd_list_count{$a}";
354+       numbering true;
355+        column {
356+                name          "List";
357+                format        "%-60.60s";
358+               value         "$key";
359+               format_total  "TOTAL: %-53.53s";
360+               total         "$num";
361+        };
362+        column {
363+                name          "Count";
364+                format_name   "%8s";
365+                format        "%8d";
366+               value         "$nnrpd_list_count{$key}";
367+               total         "total(%nnrpd_list_count)";
368+        };
369+        column {
370+                name          "kBytes";
371+                format_name   "%9s";
372+                format        "%9d";
373+               value         "$nnrpd_list_size{$key}/1024";
374+               total         "total(%nnrpd_list_size)/1024";
375+        };
376+};
377+
378 section nnrpd_curious {
379         title   "Curious NNRP server explorers:";
380        data    "%nnrpd_curious";
381@@ -1635,5 +1745,27 @@
382                 format        "%7d";
383                value         "$nnrpd_group{$key}";
384                total         "total(%nnrpd_group)";
385+        };
386+};
387+
388+section nnrpd_group_size {
389+        title   "Newsgroup request volume (by newsgroup):";
390+       data    "%nnrpd_group_size";
391+       sort    "$nnrpd_group_size{$b} <=> $nnrpd_group_size{$a}";
392+       top     50;
393+       numbering true;
394+        column {
395+                name          "Newsgroup";
396+                format        "%-69.69s";
397+               value         "$key";
398+               format_total  "TOTAL: %-62.62s";
399+               total         "$num";
400+        };
401+        column {
402+                name          "kBytes";
403+                format_name   "%9s";
404+                format        "%9d";
405+               value         "$nnrpd_group_size{$key}/1024";
406+               total         "total(%nnrpd_group_size)/1024";
407         };
408 };
409diff -Nur inn/samples/innreport_inn.pm inn-patched/samples/innreport_inn.pm
410--- inn/samples/innreport_inn.pm        Tue Nov  9 19:16:17 1999
411+++ inn-patched/samples/innreport_inn.pm        Sat Mar 25 18:55:13 2000
412@@ -961,7 +961,7 @@
413       $server =~ tr/A-Z/a-z/ unless ($CASE_SENSITIVE);
414       $innxmit_times{$server} += $elapsed;
415       return 1;
416-    }
417+    }
418     # connect & no space
419     if ($left =~ /(\S+) connect \S+ 400 No space/o)
420     {
421@@ -1267,12 +1267,18 @@
422       return 1;
423     }     
424     # group
425-    if ($left =~ /(\S+) group (\S+) (\d+)$/o)
426+    if ($left =~ /(\S+) group (\S+) (\d+) articles (\d+) bytes (\d+) ovcount (\d+) ovbytes$/o)
427     {
428-      my ($server, $group, $num) = ($1, $2, $3);
429+      my ($server, $group, $num, $bytes, $ovcount, $ovbytes) = ($1, $2, $3, $4, $5, $6);
430       $nnrpd_group{$group} += $num;
431+      $nnrpd_group_size{$group} += $bytes;
432+      $nnrpd_group_ovcount{$group} += $ovcount;
433+      $nnrpd_group_ovbytes{$group} += $ovbytes;
434       my ($hierarchy) = $group =~ /^([^\.]+).*$/o;
435       $nnrpd_hierarchy{$hierarchy} += $num;
436+      $nnrpd_hierarchy_bytes{$hierarchy} += $bytes;
437+      $nnrpd_hierarchy_ovcount{$hierarchy} += $ovcount;
438+      $nnrpd_hierarchy_ovbytes{$hierarchy} += $ovbytes;
439       return 1;
440     }
441     # post failed
442@@ -1317,6 +1323,13 @@
443       $nnrpd_no_permission{$server}++;
444       return 1;
445     }
446+    if ($left =~ /(\S+) list (\S+) bytes (\S+)$/o)
447+    {
448+      my ($server, $list, $size) = ($1, $2, $3);
449+      $nnrpd_list_count{$list}++;
450+      $nnrpd_list_size{$list}+=$size;
451+      return 1;
452+    }
453     # unrecognized + command
454     if ($left =~ /(\S+) unrecognized (.*)$/o)
455     {
456@@ -1344,6 +1357,33 @@
457       my ($server, $user, $system, $elapsed) = ($1, $2, $3, $4);
458       $server =~ tr/A-Z/a-z/ unless ($CASE_SENSITIVE);
459       $nnrpd_times{$server} += $elapsed;
460+      return 1;
461+    }
462+    # artstats
463+    if ($left =~ /(\S+) artstats get (\S+) time (\S+) size (\S+)$/o)
464+    {
465+      my ($server, $get, $time, $size) = ($1, $2, $3, $4);
466+      $server =~ tr/A-Z/a-z/ unless ($CASE_SENSITIVE);
467+      $nnrpd_artstats_get{$server} += $get;
468+      $nnrpd_artstats_time{$server} += $time;
469+      $nnrpd_artstats_size{$server} += $size;
470+      return 1;
471+    }
472+    # overstats
473+    if ($left =~ /(\S+) overstats count (\S+) hit (\S+) miss (\S+) time (\S+) size (\S+) read (\S+) dbz (\S+) seek (\S+) get (\S+) artcheck (\S+)$/o)
474+    {
475+      my ($server, $count, $hit, $miss, $time, $size, $read, $dbz, $seek, $get, $artcheck) = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);
476+      $server =~ tr/A-Z/a-z/ unless ($CASE_SENSITIVE);
477+      $nnrpd_overstats_count{$server} += $count;
478+      $nnrpd_overstats_hit{$server} += $hit;
479+      $nnrpd_overstats_miss{$server} += $miss;
480+      $nnrpd_overstats_time{$server} += $time;
481+      $nnrpd_overstats_size{$server} += $size;
482+      $nnrpd_overstats_read{$server} += $read;
483+      $nnrpd_overstats_dbz{$server} += $dbz;
484+      $nnrpd_overstats_seek{$server} += $seek;
485+      $nnrpd_overstats_get{$server} += $get;
486+      $nnrpd_overstats_artcheck{$server} += $artcheck;
487       return 1;
488     }
489     # timeout