1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 let stats_array = Array.init brand_count
(fun _
->
33 { dummy_stats
with brand_seen
= 0 }
37 let i = brand_to_int c
.client_brand
in
38 check_client_country_code c
;
39 CommonStats.country_seen c
.client_country_code
;
40 stats_array.(i).brand_seen
<- stats_array.(i).brand_seen
+ 1;
41 !!gstats_array
.(i).brand_seen
<- !!gstats_array
.(i).brand_seen
+ 1
44 let i = brand_to_int c
.client_brand
in
45 stats_array.(i).brand_banned
<- stats_array.(i).brand_banned
+ 1;
46 !!gstats_array
.(i).brand_banned
<- !!gstats_array
.(i).brand_banned
+ 1
48 let count_filerequest c
=
49 let i = brand_to_int c
.client_brand
in
50 stats_array.(i).brand_filerequest
<- stats_array.(i).brand_filerequest
+ 1;
51 !!gstats_array
.(i).brand_filerequest
<- !!gstats_array
.(i).brand_filerequest
+ 1
53 let count_download c v
=
54 let i = brand_to_int c
.client_brand
in
55 stats_array.(i).brand_download
<- stats_array.(i).brand_download
++ v
;
56 !!gstats_array
.(i).brand_download
<- !!gstats_array
.(i).brand_download
++ v
;
58 c
.client_total_downloaded
<- c
.client_total_downloaded
++ v
;
59 c
.client_session_downloaded
<- c
.client_session_downloaded
++ v
;
60 bt_download_counter
:= !bt_download_counter
++ v
;
61 check_client_country_code c
;
62 global_count_download network c
.client_country_code v
64 let count_upload c v
=
65 let i = brand_to_int c
.client_brand
in
66 stats_array.(i).brand_upload
<- stats_array.(i).brand_upload
++ v
;
67 !!gstats_array
.(i).brand_upload
<- !!gstats_array
.(i).brand_upload
++ v
;
69 c
.client_total_uploaded
<- c
.client_total_uploaded
++ v
;
70 c
.client_session_uploaded
<- c
.client_session_uploaded
++ v
;
71 bt_upload_counter
:= !bt_upload_counter
++ v
;
72 check_client_country_code c
;
73 global_count_upload network c
.client_country_code v
75 let print_stats o style
=
76 let buf = o
.conn_buf
in
78 let u1 = BasicSocket.last_time
() - BasicSocket.start_time
in
79 let u2 = (guptime
() + u1) in
81 let t1 = build_title
"BitTorrent" "Session" u1 in
82 let t2 = build_title
"BitTorrent" "Total" u2 in
85 | Old
-> print_stats_old
buf stats_array brand_list
t1 u1
87 if use_html_mods o
then begin
88 print_stats_html_mods
buf stats_array brand_list
t1 u1;
89 print_stats_html_mods
buf !!gstats_array brand_list
t2 u2
91 print_stats_ascii
buf stats_array brand_list
t1 u1;
92 print_stats_ascii
buf !!gstats_array brand_list
t2 u2
96 network
.op_network_display_stats
<- (fun o
-> print_stats o New
);
98 network
.op_network_stat_info_list
<- (fun _ ->
99 let l1 = stats_list brand_list
stats_array in
100 let l2 = stats_list brand_list
!!gstats_array
in
101 let u1 = BasicSocket.last_time
() - BasicSocket.start_time
in
102 let u2 = (guptime
() + u1) in
103 [("Session clients", u1, l1); ("Global clients", u2, l2)]
108 "client_stats_bt", "Network/Bittorrent",Arg_none
(fun o
->
111 ), ":\t\t\tshow breakdown of download/upload by clients brand";
113 "csbt", "Network/Bittorrent",Arg_none
(fun o
->
116 ), ":\t\t\t\t\tshow table of download/upload by BT clients brand";