/[mldonkey]/mldonkey/src/networks/bittorrent/bTStats.ml
ViewVC logotype

Diff of /mldonkey/src/networks/bittorrent/bTStats.ml

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

revision 1.3 by spiralvoice, Wed Aug 31 23:51:58 2005 UTC revision 1.4 by spiralvoice, Mon Sep 19 15:57:14 2005 UTC
# Line 89  let stats_by_brand = Array.init brand_co Line 89  let stats_by_brand = Array.init brand_co
89  let count_seen c =  let count_seen c =
90    stats_all.brand_seen <- stats_all.brand_seen + 1;    stats_all.brand_seen <- stats_all.brand_seen + 1;
91    (match c.client_brand with    (match c.client_brand with
       Brand_unknown -> () (* be careful, raising an exception here will  
 abort all other operations after that point for this client...*)  
92      | b ->      | b ->
93        stats_by_brand.(brand_to_int b).brand_seen <-        stats_by_brand.(brand_to_int b).brand_seen <-
94          stats_by_brand.(brand_to_int b).brand_seen + 1;          stats_by_brand.(brand_to_int b).brand_seen + 1;
# Line 100  abort all other operations after that po Line 98  abort all other operations after that po
98  let count_banned c =  let count_banned c =
99    stats_all.brand_banned <- stats_all.brand_banned + 1;    stats_all.brand_banned <- stats_all.brand_banned + 1;
100    (match c.client_brand with    (match c.client_brand with
       Brand_unknown -> ()  
101      | b ->      | b ->
102        stats_by_brand.(brand_to_int b).brand_banned <-        stats_by_brand.(brand_to_int b).brand_banned <-
103          stats_by_brand.(brand_to_int b).brand_banned + 1;          stats_by_brand.(brand_to_int b).brand_banned + 1;
# Line 110  let count_banned c = Line 107  let count_banned c =
107  let count_filerequest c =  let count_filerequest c =
108    stats_all.brand_filerequest <- stats_all.brand_filerequest + 1;    stats_all.brand_filerequest <- stats_all.brand_filerequest + 1;
109    (match c.client_brand with    (match c.client_brand with
       Brand_unknown -> ()  
110      | b ->      | b ->
111        stats_by_brand.(brand_to_int b).brand_filerequest <-        stats_by_brand.(brand_to_int b).brand_filerequest <-
112          stats_by_brand.(brand_to_int b).brand_filerequest + 1;          stats_by_brand.(brand_to_int b).brand_filerequest + 1;
# Line 123  let count_download c f v = Line 119  let count_download c f v =
119    stats_all.brand_download <- Int64.add stats_all.brand_download v;    stats_all.brand_download <- Int64.add stats_all.brand_download v;
120    bt_download_counter := Int64.add !bt_download_counter v;    bt_download_counter := Int64.add !bt_download_counter v;
121    (match c.client_brand with    (match c.client_brand with
       Brand_unknown -> ()  
122      | b ->      | b ->
123        stats_by_brand.(brand_to_int b).brand_download <-        stats_by_brand.(brand_to_int b).brand_download <-
124          Int64.add stats_by_brand.(brand_to_int b).brand_download v;          Int64.add stats_by_brand.(brand_to_int b).brand_download v;
# Line 136  let count_upload c f v = Line 131  let count_upload c f v =
131    stats_all.brand_upload <- Int64.add stats_all.brand_upload v;    stats_all.brand_upload <- Int64.add stats_all.brand_upload v;
132    bt_upload_counter := Int64.add !bt_upload_counter v;    bt_upload_counter := Int64.add !bt_upload_counter v;
133    (match c.client_brand with    (match c.client_brand with
       Brand_unknown -> ()  
134      | b ->      | b ->
135        stats_by_brand.(brand_to_int b).brand_upload <-        stats_by_brand.(brand_to_int b).brand_upload <-
136          Int64.add stats_by_brand.(brand_to_int b).brand_upload v;          Int64.add stats_by_brand.(brand_to_int b).brand_upload v;
# Line 169  let print_stats buf = Line 163  let print_stats buf =
163      Printf.bprintf buf "You haven't connected to any client yet\n"      Printf.bprintf buf "You haven't connected to any client yet\n"
164    else begin    else begin
165      Printf.bprintf buf "\n     Successful Connections: %18d\n" stats_all.brand_seen;      Printf.bprintf buf "\n     Successful Connections: %18d\n" stats_all.brand_seen;
166      for i=1 to brand_count-1 do      for i=0 to brand_count-1 do
167        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"
168          (brand_to_string (brand_of_int i))          (brand_to_string (brand_of_int i))
169          stats_by_brand.(i).brand_seen          stats_by_brand.(i).brand_seen
# Line 181  let print_stats buf = Line 175  let print_stats buf =
175      Printf.bprintf buf "You weren't asked for any file yet\n"      Printf.bprintf buf "You weren't asked for any file yet\n"
176    else begin    else begin
177      Printf.bprintf buf "\nTotal filerequests received: %18d\n" stats_all.brand_filerequest;      Printf.bprintf buf "\nTotal filerequests received: %18d\n" stats_all.brand_filerequest;
178      for i=1 to brand_count-1 do      for i=0 to brand_count-1 do
179        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"
180          (brand_to_string (brand_of_int i))          (brand_to_string (brand_of_int i))
181          stats_by_brand.(i).brand_filerequest          stats_by_brand.(i).brand_filerequest
# Line 195  let print_stats buf = Line 189  let print_stats buf =
189        Printf.bprintf buf "\n            Total downloads: %18s (%5.1f KB/s)\n"        Printf.bprintf buf "\n            Total downloads: %18s (%5.1f KB/s)\n"
190        (Int64.to_string stats_all.brand_download)        (Int64.to_string stats_all.brand_download)
191        ((Int64.to_float stats_all.brand_download) /. (float_of_int uptime) /. 1024.0);        ((Int64.to_float stats_all.brand_download) /. (float_of_int uptime) /. 1024.0);
192      for i=1 to brand_count-1 do      for i=0 to brand_count-1 do
193        Printf.bprintf buf "%27s: %18s (%5.1f %%)\n"        Printf.bprintf buf "%27s: %18s (%5.1f %%)\n"
194          (brand_to_string (brand_of_int i))          (brand_to_string (brand_of_int i))
195          (Int64.to_string stats_by_brand.(i).brand_download)          (Int64.to_string stats_by_brand.(i).brand_download)
# Line 209  let print_stats buf = Line 203  let print_stats buf =
203        Printf.bprintf buf "\n              Total uploads: %18s (%5.1f KB/s)\n"        Printf.bprintf buf "\n              Total uploads: %18s (%5.1f KB/s)\n"
204        (Int64.to_string stats_all.brand_upload)        (Int64.to_string stats_all.brand_upload)
205        ((Int64.to_float stats_all.brand_upload) /. (float_of_int uptime) /. 1024.0);        ((Int64.to_float stats_all.brand_upload) /. (float_of_int uptime) /. 1024.0);
206      for i=1 to brand_count-1 do      for i=0 to brand_count-1 do
207        Printf.bprintf buf "%27s: %18s (%5.1f %%)\n"        Printf.bprintf buf "%27s: %18s (%5.1f %%)\n"
208          (brand_to_string (brand_of_int i))          (brand_to_string (brand_of_int i))
209          (Int64.to_string stats_by_brand.(i).brand_upload)          (Int64.to_string stats_by_brand.(i).brand_upload)
# Line 221  let print_stats buf = Line 215  let print_stats buf =
215      Printf.bprintf buf "You didn't ban any client yet\n"      Printf.bprintf buf "You didn't ban any client yet\n"
216    else begin    else begin
217        Printf.bprintf buf "\n                 Total bans: %18d\n" stats_all.brand_banned;        Printf.bprintf buf "\n                 Total bans: %18d\n" stats_all.brand_banned;
218      for i=1 to brand_count-1 do      for i=0 to brand_count-1 do
219        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"        Printf.bprintf buf "%27s: %18d (%5.1f %%)\n"
220          (brand_to_string (brand_of_int i))          (brand_to_string (brand_of_int i))
221          stats_by_brand.(i).brand_banned          stats_by_brand.(i).brand_banned
# Line 314  let new_print_stats buf o = Line 308  let new_print_stats buf o =
308        let counter = ref 0 in        let counter = ref 0 in
309        let showTotal = ref false in        let showTotal = ref false in
310    
311        for i=1 to brand_count do        for i=0 to brand_count do
312          if i=brand_count then showTotal := true;          if i=brand_count then showTotal := true;
313          if !showTotal || ( stats_by_brand.(i).brand_seen > 0 ) then begin          if !showTotal || ( stats_by_brand.(i).brand_seen > 0 ) then begin
314            incr counter;            incr counter;
# Line 406  let new_print_stats buf o = Line 400  let new_print_stats buf o =
400        stats_html_header buf;        stats_html_header buf;
401    
402        showTotal := false;        showTotal := false;
403        for i=1 to brand_count do        for i=0 to brand_count do
404         if i=brand_count then showTotal := true;         if i=brand_count then showTotal := true;
405         if !showTotal || ( !!gstats_by_brand.(i).brand_seen > 0 ) then begin         if !showTotal || ( !!gstats_by_brand.(i).brand_seen > 0 ) then begin
406            incr counter;            incr counter;
# Line 481  let new_print_stats buf o = Line 475  let new_print_stats buf o =
475        Printf.bprintf buf "Client Brand|    seen      |     Downloads      |      Uploads       |   Banned   |  Requests\n";        Printf.bprintf buf "Client Brand|    seen      |     Downloads      |      Uploads       |   Banned   |  Requests\n";
476        Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n";        Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n";
477    
478        for i=1 to brand_count-1 do        for i=0 to brand_count-1 do
479          if stats_by_brand.(i).brand_seen > 0 then (* dont print server stats *)          if stats_by_brand.(i).brand_seen > 0 then (* dont print server stats *)
480            let brandstr = brand_to_string (brand_of_int i) in            let brandstr = brand_to_string (brand_of_int i) in
481    
# Line 522  let new_print_stats buf o = Line 516  let new_print_stats buf o =
516        Printf.bprintf buf "Client Brand|    seen      |     Downloads      |      Uploads       |   Banned   |  Requests\n";        Printf.bprintf buf "Client Brand|    seen      |     Downloads      |      Uploads       |   Banned   |  Requests\n";
517        Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n";        Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n";
518    
519        for i=1 to brand_count-1 do        for i=0 to brand_count-1 do
520          if !!gstats_by_brand.(i).brand_seen > 0 then (* dont print server stats *)          if !!gstats_by_brand.(i).brand_seen > 0 then (* dont print server stats *)
521            let brandstr = brand_to_string (brand_of_int i) in            let brandstr = brand_to_string (brand_of_int i) in
522    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26