mldonkey-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-users] [patch] Updated cs patch


From: Sven Hartge
Subject: [Mldonkey-users] [patch] Updated cs patch
Date: Thu, 16 Jan 2003 03:32:28 +0100
User-agent: tin/1.5.16-20030113 ("Spiders") (UNIX) (Linux/2.4.20-112 (i586))

Hi.

Unfortunately, the patch for an alternative stats-command was not added
to the HEAD, so I grabbed it and polished a little bit for 2.02-5:

Index: donkey/donkeyStats.ml
===================================================================
RCS file: /cvsroot/mldonkey/mldonkey/donkey/donkeyStats.ml,v
retrieving revision 1.7
diff -u -r1.7 donkeyStats.ml
--- donkey/donkeyStats.ml       11 Jan 2003 00:53:35 -0000      1.7
+++ donkey/donkeyStats.ml       16 Jan 2003 02:25:05 -0000
@@ -186,6 +186,46 @@
   end
 
 
+let new_print_stats buf =
+  let one_minute = 60 in
+  let one_hour = 3600 in
+  let one_day = 86400 in
+  let uptime = int_of_float (last_time () -. start_time) in
+  let days = uptime / one_day in
+  let rem = uptime - days * one_day in
+  let hours = rem / one_hour in
+  let rem = rem - hours * one_hour in
+  let mins = rem / one_minute in
+    Printf.bprintf buf "Uptime: %d seconds (%d+%02d:%02d)\n" uptime days hours 
mins;
+
+  Printf.bprintf buf "          Client| Seen     | Dl (Mb, Kb/s, %%) | Ul (Mb, 
Kb/s, %%) |  Banned\n";
+  Printf.bprintf buf 
"----------------+----------+------------------+------------------+----------\n";
+  Printf.bprintf buf "%-16s|%5d     | %6.1f %5.1f     | %6.1f %5.1f     | %3d 
%3.0f%%\n"
+    "Total"
+    stats_all.brand_seen
+    ((Int64.to_float stats_all.brand_download) /. 1024.0 /. 1024.0)
+    ((Int64.to_float stats_all.brand_download) /. (float_of_int uptime) /. 
1024.0)
+    ((Int64.to_float stats_all.brand_upload) /. 1024.0 /. 1024.0)
+    ((Int64.to_float stats_all.brand_upload) /. (float_of_int uptime) /. 
1024.0)
+    stats_all.brand_banned 
+    (100. *. (float_of_int stats_all.brand_banned) /. (float_of_int 
stats_all.brand_seen));
+
+  for i=1 to brand_count-1 do
+    Printf.bprintf buf "%-16s|%5d %3.f%%| %6.1f %5.1f %3.0f%%| %6.1f %5.1f 
%3.0f%%| %3d %3.0f%%\n"
+      (brand_to_string (brand_of_int i))
+      stats_by_brand.(i).brand_seen 
+      (100. *. (float_of_int stats_by_brand.(i).brand_seen) /. (float_of_int 
stats_all.brand_seen))
+      ((Int64.to_float stats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0)
+      ((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int 
uptime) /. 1024.0)
+      (100. *. (Int64.to_float stats_by_brand.(i).brand_download) /. 
(Int64.to_float stats_all.brand_download))
+      ((Int64.to_float stats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0)
+      ((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int 
uptime) /. 1024.0)
+      (100. *. (Int64.to_float stats_by_brand.(i).brand_upload) /. 
(Int64.to_float stats_all.brand_upload))
+      stats_by_brand.(i).brand_banned 
+      (100. *. (float_of_int stats_by_brand.(i).brand_banned) /. (float_of_int 
stats_by_brand.(i).brand_seen))
+  done
+
+
 let _ =
   register_commands 
     [
@@ -194,4 +234,10 @@
          print_stats buf;
          ""
    ), ":\t\t\t\tshow breakdown of download/upload by clients brand";
+
+   "cs", Arg_none (fun o ->
+       let buf = o.conn_buf in
+         new_print_stats buf;
+         ""
+   ), ":\t\t\t\tshow table of download/upload by clients brand";
   ]

S°

-- 
Letzte Worte eines Kellners: Hat's geschmeckt...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]