]> git.ipfire.org Git - thirdparty/sarg.git/blob - topuser.c
Normalize the messages to have less messages to translate.
[thirdparty/sarg.git] / topuser.c
1 /*
2 * SARG Squid Analysis Report Generator http://sarg.sourceforge.net
3 * 1998, 2013
4 *
5 * SARG donations:
6 * please look at http://sarg.sourceforge.net/donations.php
7 * Support:
8 * http://sourceforge.net/projects/sarg/forums/forum/363374
9 * ---------------------------------------------------------------------
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
24 *
25 */
26
27 #include "include/conf.h"
28 #include "include/defs.h"
29
30 extern struct globalstatstruct globstat;
31 extern bool smartfilter;
32
33 /*!
34 Save the total number of users. The number is written in sarg-users and set
35 in a global variable for further reference.
36
37 \param totuser The total number of users.
38 */
39 static void set_total_users(int totuser)
40 {
41 char tusr[1024];
42 FILE *fp_ou;
43
44 snprintf(tusr,sizeof(tusr),"%s/sarg-users",outdirname);
45 if((fp_ou=fopen(tusr,"w"))==NULL) {
46 debuga(_("Cannot open file \"%s\": %s\n"),tusr,strerror(errno));
47 exit(EXIT_FAILURE);
48 }
49 fprintf(fp_ou,"%d\n",totuser);
50 if (fclose(fp_ou)==EOF) {
51 debuga(_("Write error in \"%s\": %s\n"),tusr,strerror(errno));
52 exit(EXIT_FAILURE);
53 }
54 globstat.totuser=totuser;
55 }
56
57 void topuser(void)
58 {
59 FILE *fp_in = NULL, *fp_top1 = NULL, *fp_top2 = NULL, *fp_top3 = NULL;
60 long long int ttnbytes=0, ttnacc=0, tnacc=0;
61 long long int tnbytes=0, ttnelap=0, tnelap=0;
62 long long int tnincache=0, tnoucache=0, ttnincache=0, ttnoucache=0;
63 long long int nbytes;
64 long long int nacc;
65 long long int elap, incac, oucac;
66 double perc=0.00;
67 double perc2=0.00;
68 double inperc=0.00, ouperc=0.00;
69 int posicao=0;
70 char olduser[MAX_USER_LEN], csort[MAXLEN];
71 char wger[MAXLEN], top1[MAXLEN], top2[MAXLEN], top3[MAXLEN];
72 char user[MAX_USER_LEN];
73 const char *sfield="-n -k 2,2";
74 const char *order;
75 const char *sort_field;
76 const char *sort_order;
77 char title[80];
78 char *warea;
79 int totuser=0;
80 int topcount=0;
81 int cstatus;
82 struct getwordstruct gwarea;
83 longline line;
84 struct generalitemstruct item;
85 struct userinfostruct *uinfo;
86
87 if (debugz>=LogLevel_Process)
88 debuga(_("Creating top users report...\n"));
89 ntopuser = 0;
90 snprintf(wger,sizeof(wger),"%s/sarg-general",outdirname);
91 if((fp_in=fopen(wger,"r"))==NULL) {
92 debuga(_("Cannot open file \"%s\": %s\n"),wger,strerror(errno));
93 exit(EXIT_FAILURE);
94 }
95
96 snprintf(top2,sizeof(top2),"%s/top.tmp",outdirname);
97 if((fp_top2=fopen(top2,"w"))==NULL) {
98 debuga(_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
99 exit(EXIT_FAILURE);
100 }
101
102 olduser[0]='\0';
103 totuser=0;
104
105 if ((line=longline_create())==NULL) {
106 debuga(_("Not enough memory to read the file %s\n"),wger);
107 exit(EXIT_FAILURE);
108 }
109
110 while((warea=longline_read(fp_in,line))!=NULL) {
111 ger_read(warea,&item,wger);
112 if(item.total) continue;
113 if(strcmp(olduser,item.user) != 0) {
114 totuser++;
115
116 if (olduser[0] != '\0') {
117 /*
118 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
119 to print a long long int unless it is exactly 64-bits long.
120 */
121 fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap,(uint64_t)tnincache,(uint64_t)tnoucache);
122
123 ttnbytes+=tnbytes;
124 ttnacc+=tnacc;
125 ttnelap+=tnelap;
126 ttnincache+=tnincache;
127 ttnoucache+=tnoucache;
128 }
129 strcpy(olduser,item.user);
130 tnbytes=0;
131 tnacc=0;
132 tnelap=0;
133 tnincache=0;
134 tnoucache=0;
135 }
136
137 tnbytes+=item.nbytes;
138 tnacc+=item.nacc;
139 tnelap+=item.nelap;
140 tnincache+=item.incache;
141 tnoucache+=item.oucache;
142 }
143 fclose(fp_in);
144 longline_destroy(&line);
145
146 if (olduser[0] != '\0') {
147 /*
148 This complicated printf is due to Microsoft's inability to comply with any standard. Msvcrt is unable
149 to print a long long int unless it is exactly 64-bits long.
150 */
151 fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap,(uint64_t)tnincache,(uint64_t)tnoucache);
152
153 ttnbytes+=tnbytes;
154 ttnacc+=tnacc;
155 ttnelap+=tnelap;
156 ttnincache+=tnincache;
157 ttnoucache+=tnoucache;
158 }
159 if (fclose(fp_top2)==EOF) {
160 debuga(_("Write error in \"%s\": %s\n"),top2,strerror(errno));
161 exit(EXIT_FAILURE);
162 }
163
164 #ifdef ENABLE_DOUBLE_CHECK_DATA
165 if (ttnacc!=globstat.nacc || ttnbytes!=globstat.nbytes || ttnelap!=globstat.elap ||
166 ttnincache!=globstat.incache || ttnoucache!=globstat.oucache) {
167 debuga(_("Total statistics mismatch when reading %s to produce the top users\n"),wger);
168 exit(EXIT_FAILURE);
169 }
170 #endif
171
172 set_total_users(totuser);
173
174 if((TopuserSort & TOPUSER_SORT_USER) != 0) {
175 sfield="-k 1,1";
176 sort_field=_("user");
177 } else if((TopuserSort & TOPUSER_SORT_CONNECT) != 0) {
178 sfield="-n -k 3,3";
179 sort_field=_("connect");
180 } else if((TopuserSort & TOPUSER_SORT_TIME) != 0) {
181 sfield="-n -k 4,4";
182 sort_field=pgettext("duration","time");
183 } else {
184 sort_field=_("bytes");
185 }
186
187 if((TopuserSort & TOPUSER_SORT_REVERSE) == 0) {
188 order="";
189 sort_order=_("normal");
190 } else {
191 order="-r";
192 sort_order=_("reverse");
193 }
194
195 snprintf(top1,sizeof(top1),"%s/top",outdirname);
196 if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" %s %s -o \"%s\" \"%s\"", tmp, order, sfield, top1, top2)>=sizeof(csort)) {
197 debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),top2,top1);
198 exit(EXIT_FAILURE);
199 }
200 cstatus=system(csort);
201 if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
202 debuga(_("sort command return status %d\n"),WEXITSTATUS(cstatus));
203 debuga(_("sort command: %s\n"),csort);
204 exit(EXIT_FAILURE);
205 }
206
207 if((fp_top1=fopen(top1,"r"))==NULL) {
208 debuga(_("Cannot open file \"%s\": %s\n"),top1,strerror(errno));
209 exit(EXIT_FAILURE);
210 }
211
212 if (!KeepTempLog && unlink(top2)) {
213 debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
214 exit(EXIT_FAILURE);
215 }
216
217 snprintf(top3,sizeof(top3),"%s/"INDEX_HTML_FILE,outdirname);
218 if((fp_top3=fopen(top3,"w"))==NULL) {
219 debuga(_("Cannot open file \"%s\": %s\n"),top3,strerror(errno));
220 exit(EXIT_FAILURE);
221 }
222
223 snprintf(title,sizeof(title),_("SARG report for %s"),period.text);
224 write_html_header(fp_top3,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,title,HTML_JS_SORTTABLE);
225 fputs("<tr><td class=\"header_c\">",fp_top3);
226 fprintf(fp_top3,_("Period: %s"),period.html);
227 fputs("</td></tr>\n",fp_top3);
228 if ((ReportType & REPORT_TYPE_TOPUSERS) != 0) {
229 fputs("<tr><td class=\"header_c\">",fp_top3);
230 fprintf(fp_top3,_("Sort: %s, %s"),sort_field,sort_order);
231 fputs("</td></tr>\n",fp_top3);
232 fprintf(fp_top3,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Top users"));
233 } else {
234 /* TRANSLATORS: This is the title of the main report page when no
235 * top users list are requested.
236 */
237 fprintf(fp_top3,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Table of content"));
238 }
239 close_html_header(fp_top3);
240
241 if (!indexonly) {
242 fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\">\n",fp_top3);
243 if((ReportType & REPORT_TYPE_TOPSITES) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"topsites.html\">%s</a></td></tr>\n",_("Top sites"));
244 if((ReportType & REPORT_TYPE_SITES_USERS) != 0 && !Privacy) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"siteuser.html\">%s</a></td></tr>\n",_("Sites & Users"));
245 if(dansguardian_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"dansguardian.html\">%s</a></td></tr>\n",_("DansGuardian"));
246 if(redirector_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"redirector.html\">%s</a></td></tr>\n",_("Redirector"));
247 if (is_download()) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"download.html\">%s</a></td></tr>\n",_("Downloads"));
248 if (is_denied()) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"denied.html\">%s</a></td></tr>\n",_("Denied accesses"));
249 if (is_authfail()) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"authfail.html\">%s</a></td></tr>\n",_("Authentication Failures"));
250 if(smartfilter) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"smartfilter.html\">%s</a></td></tr>\n",_("SmartFilter"));
251 if(UserAgentLog[0] != '\0' && useragent_count) fprintf(fp_top3,"<tr><td class=\"link\" colspan=\"0\"><a href=\"useragent.html\">%s</a></td></tr>\n",_("Useragent"));
252 fputs("<tr><td></td></tr>\n</table></div>\n",fp_top3);
253 }
254
255 if ((ReportType & REPORT_TYPE_TOPUSERS) == 0) {
256 fputs("</body>\n</html>\n",fp_top3);
257 if (fclose (fp_top3)==EOF) {
258 debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
259 exit(EXIT_FAILURE);
260 }
261 if (debugz>=LogLevel_Process) debugaz(_("No top users report because it is not configured in report_type\n"));
262 return;
263 }
264
265 fputs("<div class=\"report\"><table cellpadding=\"1\" cellspacing=\"2\"",fp_top3);
266 if (SortTableJs[0])
267 fputs(" class=\"sortable\"",fp_top3);
268 fputs(">\n<thead><tr>",fp_top3);
269
270 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
271 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("NUM"));
272 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly) {
273 fputs("<th class=\"header_l",fp_top3);
274 if (SortTableJs[0]) fputs(" sorttable_nosort",fp_top3);
275 fputs("\"></th>",fp_top3);
276 }
277 if((TopUserFields & TOPUSERFIELDS_USERID) != 0) {
278 fputs("<th class=\"header_l",fp_top3);
279 if (SortTableJs[0]) fputs(" sorttable_alpha",fp_top3);
280 fprintf(fp_top3,"\">%s</th>",_("USERID"));
281 }
282 if((TopUserFields & TOPUSERFIELDS_USERIP) != 0) {
283 fputs("<th class=\"header_l",fp_top3);
284 if (SortTableJs[0]) fputs(" sorttable_alpha",fp_top3);
285 fprintf(fp_top3,"\">%s</th>",_("USERIP"));
286 }
287 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
288 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("CONNECT"));
289 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
290 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("BYTES"));
291 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
292 fprintf(fp_top3,"<th class=\"header_l\">%%%s</th>",_("BYTES"));
293 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
294 fprintf(fp_top3,"<th class=\"header_c\" colspan=\"2\">%s</th><th style=\"display:none;\"></th>",_("IN-CACHE-OUT"));
295 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
296 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("ELAPSED TIME"));
297 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
298 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("MILLISEC"));
299 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0)
300 fprintf(fp_top3,"<th class=\"header_l\">%%%s</th>",pgettext("duration","TIME"));
301
302 fputs("</tr></thead>\n",fp_top3);
303
304 greport_prepare();
305
306 ntopuser = 0;
307
308 if ((line=longline_create())==NULL) {
309 debuga(_("Not enough memory to read the downloaded files\n"));
310 exit(EXIT_FAILURE);
311 }
312
313 while((warea=longline_read(fp_top1,line))!=NULL) {
314 getword_start(&gwarea,warea);
315 if (getword(user,sizeof(user),&gwarea,'\t')<0) {
316 debuga(_("There is a broken user in file %s\n"),top1);
317 exit(EXIT_FAILURE);
318 }
319 if (getword_atoll(&nbytes,&gwarea,'\t')<0) {
320 debuga(_("There is a broken number of bytes in file %s\n"),top1);
321 exit(EXIT_FAILURE);
322 }
323 if (getword_atoll(&nacc,&gwarea,'\t')<0) {
324 debuga(_("There is a broken number of access in file %s\n"),top1);
325 exit(EXIT_FAILURE);
326 }
327 if (getword_atoll(&elap,&gwarea,'\t')<0) {
328 debuga(_("There is a broken elpased time in file %s\n"),top1);
329 exit(EXIT_FAILURE);
330 }
331 if (getword_atoll(&incac,&gwarea,'\t')<0) {
332 debuga(_("There is a broken in-cache size in file %s\n"),top1);
333 exit(EXIT_FAILURE);
334 }
335 if (getword_atoll(&oucac,&gwarea,'\n')<0) {
336 debuga(_("There is a broken out-of-cache size in file %s\n"),top1);
337 exit(EXIT_FAILURE);
338 }
339 if(nacc < 1)
340 continue;
341 ntopuser = 1;
342 if(TopUsersNum > 0 && topcount >= TopUsersNum) break;
343 tnbytes=nbytes;
344 tnelap=elap;
345
346 uinfo=userinfo_find_from_id(user);
347 if (!uinfo) {
348 debuga(_("Unknown user ID %s in file %s\n"),user,top1);
349 exit(EXIT_FAILURE);
350 }
351 uinfo->topuser=1;
352
353 fputs("<tr>",fp_top3);
354
355 posicao++;
356 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
357 fprintf(fp_top3,"<td class=\"data\">%d</td>",posicao);
358
359 if (!indexonly) {
360 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0) {
361 fputs("<td class=\"data2\">",fp_top3);
362 #ifdef HAVE_GD
363 if(Graphs && GraphFont[0]!='\0') {
364 greport_day(uinfo);
365 //fprintf(fp_top3,"<a href=\"%s/graph_day.png\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
366 fprintf(fp_top3,"<a href=\"%s/graph.html\"><img src=\"%s/graph.png\" title=\"%s\" alt=\"G\"></a>&nbsp;",uinfo->filename,ImageFile,_("Graphic"));
367 }
368 #endif
369 report_day(uinfo);
370 fprintf(fp_top3,"<a href=\"%s/d%s.html\"><img src=\"%s/datetime.png\" title=\"%s\" alt=\"T\"></a></td>",uinfo->filename,uinfo->filename,ImageFile,_("date/time report"));
371 day_deletefile(uinfo);
372 }
373 }
374 if((TopUserFields & TOPUSERFIELDS_USERID) != 0) {
375 if((ReportType & REPORT_TYPE_USERS_SITES) == 0 || indexonly)
376 fprintf(fp_top3,"<td class=\"data2\">%s</td>",uinfo->label);
377 else
378 fprintf(fp_top3,"<td class=\"data2\"><a href=\"%s/%s.html\">%s</a></td>",uinfo->filename,uinfo->filename,uinfo->label);
379 }
380 if((TopUserFields & TOPUSERFIELDS_USERIP) != 0) {
381 fprintf(fp_top3,"<td class=\"data2\">%s</td>",uinfo->ip);
382 }
383 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0) {
384 fputs("<td class=\"data\"",fp_top3);
385 if (SortTableJs[0]) fprintf(fp_top3," sorttable_customkey=\"%"PRId64"\"",(int64_t)nacc);
386 fprintf(fp_top3,">%s</td>",fixnum(nacc,1));
387 }
388 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0) {
389 fputs("<td class=\"data\"",fp_top3);
390 if (SortTableJs[0]) fprintf(fp_top3," sorttable_customkey=\"%"PRId64"\"",(int64_t)tnbytes);
391 fprintf(fp_top3,">%s</td>",fixnum(tnbytes,1));
392 }
393 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0) {
394 perc=(ttnbytes) ? tnbytes * 100. / ttnbytes : 0.;
395 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc);
396 }
397 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0) {
398 inperc=(tnbytes) ? incac * 100. / tnbytes : 0.;
399 ouperc=(tnbytes) ? oucac * 100. / tnbytes : 0.;
400 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td><td class=\"data\">%3.2lf%%</td>",inperc,ouperc);
401 #ifdef ENABLE_DOUBLE_CHECK_DATA
402 if ((inperc!=0. || ouperc!=0.) && fabs(inperc+ouperc-100.)>=0.01) {
403 debuga(_("The total of the in-cache and cache-miss is not 100%% at position %d (user %s)\n"),posicao,uinfo->label);
404 }
405 #endif
406 }
407 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0) {
408 fputs("<td class=\"data\"",fp_top3);
409 if (SortTableJs[0]) fprintf(fp_top3," sorttable_customkey=\"%"PRId64"\"",(int64_t)tnelap);
410 fprintf(fp_top3,">%s</td>",buildtime(tnelap));
411 }
412 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0) {
413 fputs("<td class=\"data\"",fp_top3);
414 if (SortTableJs[0]) fprintf(fp_top3," sorttable_customkey=\"%"PRId64"\"",(int64_t)tnelap);
415 fprintf(fp_top3,">%s</td>",fixnum2(tnelap,1));
416 }
417 if((TopUserFields & TOPUSERFIELDS_PTIME) != 0) {
418 perc2=(ttnelap) ? elap * 100. / ttnelap : 0.;
419 fprintf(fp_top3,"<td class=\"data\">%3.2lf%%</td>",perc2);
420 }
421
422 fputs("</tr>\n",fp_top3);
423
424 topcount++;
425 }
426 fclose(fp_top1);
427 if (!KeepTempLog && unlink(top1)) {
428 debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
429 exit(EXIT_FAILURE);
430 }
431 longline_destroy(&line);
432
433 if((TopUserFields & TOPUSERFIELDS_TOTAL) != 0) {
434 fputs("<tfoot><tr>",fp_top3);
435 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
436 fputs("<td></td>",fp_top3);
437 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly)
438 fputs("<td></td>",fp_top3);
439 if((TopUserFields & TOPUSERFIELDS_USERIP) != 0)
440 fprintf(fp_top3,"<th class=\"header_l\" colspan=\"2\">%s</th>",_("TOTAL"));
441 else
442 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("TOTAL"));
443
444 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
445 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum(ttnacc,1));
446 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0)
447 fprintf(fp_top3,"<th class=\"header_r\">%15s</th>",fixnum(ttnbytes,1));
448 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
449 fputs("<td></td>",fp_top3);
450 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
451 {
452 inperc=(ttnbytes) ? ttnincache * 100. / ttnbytes : 0.;
453 ouperc=(ttnbytes) ? ttnoucache *100. / ttnbytes : 0.;
454 fprintf(fp_top3,"<th class=\"header_r\">%3.2lf%%</th><th class=\"header_r\">%3.2lf%%</th>",inperc,ouperc);
455 #ifdef ENABLE_DOUBLE_CHECK_DATA
456 if (fabs(inperc+ouperc-100.)>=0.01) {
457 debuga(_("The total of the in-cache and cache-miss is not 100%%\n"));
458 }
459 #endif
460 }
461 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
462 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",buildtime(ttnelap));
463 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
464 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum2(ttnelap,1));
465
466 fputs("</tr>\n",fp_top3);
467 }
468 greport_cleanup();
469
470 if(ntopuser && (TopUserFields & TOPUSERFIELDS_AVERAGE) != 0) {
471 fputs("<tr>",fp_top3);
472 if((TopUserFields & TOPUSERFIELDS_NUM) != 0)
473 fputs("<td></td>",fp_top3);
474 if((TopUserFields & TOPUSERFIELDS_DATE_TIME) !=0 && (ReportType & REPORT_TYPE_DATE_TIME) != 0 && !indexonly)
475 fputs("<td></td>",fp_top3);
476 if((TopUserFields & TOPUSERFIELDS_USERIP) != 0)
477 fprintf(fp_top3,"<th class=\"header_l\" colspan=\"2\">%s</th>",_("AVERAGE"));
478 else
479 fprintf(fp_top3,"<th class=\"header_l\">%s</th>",_("AVERAGE"));
480
481 if((TopUserFields & TOPUSERFIELDS_CONNECT) != 0)
482 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum(ttnacc/totuser,1));
483 if((TopUserFields & TOPUSERFIELDS_BYTES) != 0) {
484 tnbytes=(totuser) ? ttnbytes / totuser : 0;
485 fprintf(fp_top3,"<th class=\"header_r\">%15s</th>",fixnum(tnbytes,1));
486 }
487 if((TopUserFields & TOPUSERFIELDS_SETYB) != 0)
488 fputs("<td></td>",fp_top3);
489 if((TopUserFields & TOPUSERFIELDS_IN_CACHE_OUT) != 0)
490 fputs("<td></td><td></td>",fp_top3);
491 if((TopUserFields & TOPUSERFIELDS_USED_TIME) != 0)
492 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",buildtime(ttnelap/totuser));
493 if((TopUserFields & TOPUSERFIELDS_MILISEC) != 0)
494 fprintf(fp_top3,"<th class=\"header_r\">%s</th>",fixnum2(ttnelap/totuser,1));
495 fputs("</tr></tfoot>\n",fp_top3);
496 }
497
498 fputs("</table></div>\n",fp_top3);
499 if (write_html_trailer(fp_top3)<0)
500 debuga(_("Write error in top user list %s\n"),top3);
501 if (fclose(fp_top3)==EOF) {
502 debuga(_("Write error in \"%s\": %s\n"),top3,strerror(errno));
503 exit(EXIT_FAILURE);
504 }
505
506 return;
507 }