23 |
open Options |
open Options |
24 |
open BasicSocket (* last_time *) |
open BasicSocket (* last_time *) |
25 |
open GuiTypes |
open GuiTypes |
26 |
open CommonOptions |
open CommonOptions |
27 |
open CommonTypes |
open CommonTypes |
28 |
open CommonGlobals |
open CommonGlobals |
29 |
open CommonNetwork |
open CommonNetwork |
30 |
open CommonMessages |
open CommonMessages |
31 |
open CommonInteractive |
open CommonInteractive |
32 |
|
|
33 |
open DonkeyOptions |
open DonkeyOptions |
34 |
open DonkeyTypes |
open DonkeyTypes |
35 |
open DonkeyGlobals |
open DonkeyGlobals |
53 |
| Brand_lphant -> 12 |
| Brand_lphant -> 12 |
54 |
| Brand_emuleplus -> 13 |
| Brand_emuleplus -> 13 |
55 |
| Brand_hydranode -> 14 |
| Brand_hydranode -> 14 |
56 |
|
|
57 |
let brand_of_int b = |
let brand_of_int b = |
58 |
match b with |
match b with |
59 |
0 -> Brand_unknown |
0 -> Brand_unknown |
72 |
| 13 -> Brand_emuleplus |
| 13 -> Brand_emuleplus |
73 |
| 14 -> Brand_hydranode |
| 14 -> Brand_hydranode |
74 |
| _ -> raise Not_found |
| _ -> raise Not_found |
75 |
|
|
76 |
let gbrand_to_string b = |
let gbrand_to_string b = |
77 |
match b with |
match b with |
78 |
Brand_unknown -> "unk" |
Brand_unknown -> "unk" |
323 |
| 111 -> Brand_mod_enos |
| 111 -> Brand_mod_enos |
324 |
| 112 -> Brand_mod_webys |
| 112 -> Brand_mod_webys |
325 |
| _ -> raise Not_found |
| _ -> raise Not_found |
326 |
|
|
327 |
let gbrand_mod_to_string b = |
let gbrand_mod_to_string b = |
328 |
match b with |
match b with |
329 |
Brand_mod_unknown -> "" |
Brand_mod_unknown -> "" |
440 |
| Brand_mod_enos -> "eno" |
| Brand_mod_enos -> "eno" |
441 |
| Brand_mod_webys -> "wys" |
| Brand_mod_webys -> "wys" |
442 |
|
|
443 |
let stats_all = dummy_stats |
let stats_all = dummy_stats |
444 |
let mod_stats_all = dummy_mod_stats |
let mod_stats_all = dummy_mod_stats |
445 |
let stats_by_brand = Array.init brand_count (fun _ -> |
let stats_by_brand = Array.init brand_count (fun _ -> |
446 |
{ dummy_stats with brand_seen = 0 } |
{ dummy_stats with brand_seen = 0 } |
447 |
) |
) |
448 |
|
|
449 |
let stats_by_brand_mod = Array.init brand_mod_count (fun _ -> |
let stats_by_brand_mod = Array.init brand_mod_count (fun _ -> |
450 |
{ dummy_mod_stats with brand_mod_seen = 0 } |
{ dummy_mod_stats with brand_mod_seen = 0 } |
451 |
) |
) |
476 |
stats_all.brand_banned <- stats_all.brand_banned + 1; |
stats_all.brand_banned <- stats_all.brand_banned + 1; |
477 |
if !!emule_mods_count && c.client_mod_brand != Brand_mod_unknown then mod_stats_all.brand_mod_banned <- mod_stats_all.brand_mod_banned + 1; |
if !!emule_mods_count && c.client_mod_brand != Brand_mod_unknown then mod_stats_all.brand_mod_banned <- mod_stats_all.brand_mod_banned + 1; |
478 |
(match c.client_brand with |
(match c.client_brand with |
479 |
Brand_unknown -> () |
Brand_unknown -> () |
480 |
| b -> |
| b -> |
481 |
stats_by_brand.(brand_to_int b).brand_banned <- |
stats_by_brand.(brand_to_int b).brand_banned <- |
482 |
stats_by_brand.(brand_to_int b).brand_banned + 1; |
stats_by_brand.(brand_to_int b).brand_banned + 1; |
484 |
!!gstats_by_brand.(brand_to_int b).brand_banned + 1); |
!!gstats_by_brand.(brand_to_int b).brand_banned + 1); |
485 |
if !!emule_mods_count then begin |
if !!emule_mods_count then begin |
486 |
(match c.client_mod_brand with |
(match c.client_mod_brand with |
487 |
Brand_mod_unknown -> () |
Brand_mod_unknown -> () |
488 |
| b -> |
| b -> |
489 |
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned <- |
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned <- |
490 |
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned + 1; |
stats_by_brand_mod.(brand_mod_to_int b).brand_mod_banned + 1; |
556 |
Int64.add !!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload v) |
Int64.add !!gstats_by_brand_mod.(brand_mod_to_int b).brand_mod_upload v) |
557 |
end |
end |
558 |
|
|
559 |
let percent_of_ints x y = |
let percent_of_ints x y = |
560 |
if y <> 0 then 100. *. (float_of_int x /. float_of_int y) |
if y <> 0 then 100. *. (float_of_int x /. float_of_int y) |
561 |
else 0. |
else 0. |
562 |
|
|
563 |
let percent_of_int64s x y = |
let percent_of_int64s x y = |
564 |
if y <> Int64.zero then 100. *. (Int64.to_float x /. Int64.to_float y) |
if y <> Int64.zero then 100. *. (Int64.to_float x /. Int64.to_float y) |
565 |
else 0. |
else 0. |
566 |
|
|
567 |
let print_stats buf = |
let print_stats buf = |
568 |
let one_minute = 60 in |
let one_minute = 60 in |
569 |
let one_hour = 3600 in |
let one_hour = 3600 in |
583 |
else begin |
else begin |
584 |
Printf.bprintf buf "\n Successful Connections: %18d\n" stats_all.brand_seen; |
Printf.bprintf buf "\n Successful Connections: %18d\n" stats_all.brand_seen; |
585 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
586 |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
587 |
(brand_to_string (brand_of_int i)) |
(brand_to_string (brand_of_int i)) |
588 |
stats_by_brand.(i).brand_seen |
stats_by_brand.(i).brand_seen |
589 |
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
590 |
done |
done |
591 |
end; |
end; |
595 |
else begin |
else begin |
596 |
Printf.bprintf buf "\nTotal filerequests received: %18d\n" stats_all.brand_filerequest; |
Printf.bprintf buf "\nTotal filerequests received: %18d\n" stats_all.brand_filerequest; |
597 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
598 |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
599 |
(brand_to_string (brand_of_int i)) |
(brand_to_string (brand_of_int i)) |
600 |
stats_by_brand.(i).brand_filerequest |
stats_by_brand.(i).brand_filerequest |
601 |
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
602 |
done |
done |
603 |
end; |
end; |
606 |
Printf.bprintf buf "You didn't download anything yet\n" |
Printf.bprintf buf "You didn't download anything yet\n" |
607 |
else begin |
else begin |
608 |
Printf.bprintf buf "\n Total downloads: %18s (%5.1f KB/s)\n" |
Printf.bprintf buf "\n Total downloads: %18s (%5.1f KB/s)\n" |
609 |
(Int64.to_string stats_all.brand_download) |
(Int64.to_string stats_all.brand_download) |
610 |
((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); |
611 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
612 |
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
613 |
(brand_to_string (brand_of_int i)) |
(brand_to_string (brand_of_int i)) |
614 |
(Int64.to_string stats_by_brand.(i).brand_download) |
(Int64.to_string stats_by_brand.(i).brand_download) |
615 |
(percent_of_int64s stats_by_brand.(i).brand_download stats_all.brand_download) |
(percent_of_int64s stats_by_brand.(i).brand_download stats_all.brand_download) |
616 |
done |
done |
617 |
end; |
end; |
623 |
(Int64.to_string stats_all.brand_upload) |
(Int64.to_string stats_all.brand_upload) |
624 |
((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); |
625 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
626 |
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
Printf.bprintf buf "%27s: %18s (%5.1f %%)\n" |
627 |
(brand_to_string (brand_of_int i)) |
(brand_to_string (brand_of_int i)) |
628 |
(Int64.to_string stats_by_brand.(i).brand_upload) |
(Int64.to_string stats_by_brand.(i).brand_upload) |
629 |
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
630 |
done |
done |
631 |
end; |
end; |
632 |
|
|
633 |
if stats_all.brand_banned = 0 then |
if stats_all.brand_banned = 0 then |
634 |
Printf.bprintf buf "You didn't ban any client yet\n" |
Printf.bprintf buf "You didn't ban any client yet\n" |
635 |
else begin |
else begin |
636 |
Printf.bprintf buf "\n Total bans: %18d\n" stats_all.brand_banned; |
Printf.bprintf buf "\n Total bans: %18d\n" stats_all.brand_banned; |
637 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
638 |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
Printf.bprintf buf "%27s: %18d (%5.1f %%)\n" |
639 |
(brand_to_string (brand_of_int i)) |
(brand_to_string (brand_of_int i)) |
640 |
stats_by_brand.(i).brand_banned |
stats_by_brand.(i).brand_banned |
641 |
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
642 |
done |
done |
643 |
end |
end |
|
|
|
644 |
|
|
645 |
let stats_html_header buf = |
|
646 |
html_mods_table_header buf "csTable" "cs" [ |
let stats_html_header buf = |
647 |
( "0", "srh", "Client brand", "Brand" ) ; |
html_mods_table_header buf "csTable" "cs" [ |
648 |
( "0", "srh", "Separator", ":" ) ; |
( "0", "srh", "Client brand", "Brand" ) ; |
649 |
( "1", "srh ar", "Successful connections", "Seen" ) ; |
( "0", "srh", "Separator", ":" ) ; |
650 |
( "1", "srh", "Successful connections percent", "%" ) ; |
( "1", "srh ar", "Successful connections", "Seen" ) ; |
651 |
( "0", "srh", "Separator", "|" ) ; |
( "1", "srh", "Successful connections percent", "%" ) ; |
652 |
( "1", "srh ar", "File requests received", "Reqs" ) ; |
( "0", "srh", "Separator", "|" ) ; |
653 |
( "1", "srh", "File requests received percent", "%" ) ; |
( "1", "srh ar", "File requests received", "Reqs" ) ; |
654 |
( "0", "srh", "Separator", "|" ) ; |
( "1", "srh", "File requests received percent", "%" ) ; |
655 |
( "1", "srh ar", "Total bans", "B" ) ; |
( "0", "srh", "Separator", "|" ) ; |
656 |
( "1", "srh", "Total bans percent", "%" ) ; |
( "1", "srh ar", "Total bans", "B" ) ; |
657 |
( "0", "srh", "Separator", "|" ) ; |
( "1", "srh", "Total bans percent", "%" ) ; |
658 |
( "1", "srh ar", "Total uploads", "UL" ) ; |
( "0", "srh", "Separator", "|" ) ; |
659 |
( "1", "srh", "Total uploads percent", "%" ) ; |
( "1", "srh ar", "Total uploads", "UL" ) ; |
660 |
( "1", "srh ar", "Total uploads average KB/s", "KB/s" ) ; |
( "1", "srh", "Total uploads percent", "%" ) ; |
661 |
( "0", "srh", "Separator", "|" ) ; |
( "1", "srh ar", "Total uploads average KB/s", "KB/s" ) ; |
662 |
( "1", "srh ar", "Total downloads", "DL" ) ; |
( "0", "srh", "Separator", "|" ) ; |
663 |
( "1", "srh", "Total downloads percent", "%" ) ; |
( "1", "srh ar", "Total downloads", "DL" ) ; |
664 |
( "1", "srh ar", "Total downloads average KB/s", "KB/s" ) ; |
( "1", "srh", "Total downloads percent", "%" ) ; |
665 |
( "0", "srh", "Separator", "|" ) ; |
( "1", "srh ar", "Total downloads average KB/s", "KB/s" ) ; |
666 |
|
( "0", "srh", "Separator", "|" ) ; |
667 |
( "1", "srh", "Total uploads:downloads ratio", "U:DL" ) ] |
( "1", "srh", "Total uploads:downloads ratio", "U:DL" ) ] |
668 |
|
|
669 |
let new_print_stats buf o = |
let new_print_stats buf o = |
673 |
let uptime = last_time () - start_time in |
let uptime = last_time () - start_time in |
674 |
let days = uptime / one_day in |
let days = uptime / one_day in |
675 |
let rem = maxi 1 (uptime - days * one_day) in |
let rem = maxi 1 (uptime - days * one_day) in |
676 |
|
|
677 |
let hours = rem / one_hour in |
let hours = rem / one_hour in |
678 |
let rem = rem - hours * one_hour in |
let rem = rem - hours * one_hour in |
679 |
let mins = rem / one_minute in |
let mins = rem / one_minute in |
680 |
|
|
681 |
let sstats_all = |
let sstats_all = |
682 |
let stat = { |
let stat = { |
683 |
brand_seen = 0; |
brand_seen = 0; |
684 |
brand_banned = 0; |
brand_banned = 0; |
696 |
sstats_all.brand_upload <- Int64.add sstats_all.brand_upload stats_by_brand.(i).brand_upload; |
sstats_all.brand_upload <- Int64.add sstats_all.brand_upload stats_by_brand.(i).brand_upload; |
697 |
sstats_all.brand_banned <- sstats_all.brand_banned + stats_by_brand.(i).brand_banned; |
sstats_all.brand_banned <- sstats_all.brand_banned + stats_by_brand.(i).brand_banned; |
698 |
end; |
end; |
699 |
done; |
done; |
700 |
|
|
701 |
let gstats_all = |
let gstats_all = |
702 |
let stat = { |
let stat = { |
703 |
brand_seen = 0; |
brand_seen = 0; |
704 |
brand_banned = 0; |
brand_banned = 0; |
707 |
brand_upload = Int64.zero |
brand_upload = Int64.zero |
708 |
} |
} |
709 |
in stat in |
in stat in |
710 |
|
|
711 |
for i=0 to brand_count-1 do |
for i=0 to brand_count-1 do |
712 |
gstats_all.brand_seen <- gstats_all.brand_seen + !!gstats_by_brand.(i).brand_seen; |
gstats_all.brand_seen <- gstats_all.brand_seen + !!gstats_by_brand.(i).brand_seen; |
713 |
gstats_all.brand_filerequest <- gstats_all.brand_filerequest + !!gstats_by_brand.(i).brand_filerequest; |
gstats_all.brand_filerequest <- gstats_all.brand_filerequest + !!gstats_by_brand.(i).brand_filerequest; |
714 |
gstats_all.brand_download <- Int64.add gstats_all.brand_download !!gstats_by_brand.(i).brand_download ; |
gstats_all.brand_download <- Int64.add gstats_all.brand_download !!gstats_by_brand.(i).brand_download ; |
715 |
gstats_all.brand_upload <- Int64.add gstats_all.brand_upload !!gstats_by_brand.(i).brand_upload; |
gstats_all.brand_upload <- Int64.add gstats_all.brand_upload !!gstats_by_brand.(i).brand_upload; |
716 |
gstats_all.brand_banned <- gstats_all.brand_banned + !!gstats_by_brand.(i).brand_banned; |
gstats_all.brand_banned <- gstats_all.brand_banned + !!gstats_by_brand.(i).brand_banned; |
717 |
done; |
done; |
718 |
|
|
719 |
if use_html_mods o then |
if use_html_mods o then |
720 |
begin |
begin |
721 |
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>Session Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>Session Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
722 |
days hours mins uptime; |
days hours mins uptime; |
723 |
stats_html_header buf; |
stats_html_header buf; |
724 |
|
|
725 |
let counter = ref 0 in |
let counter = ref 0 in |
726 |
let showTotal = ref false in |
let showTotal = ref false in |
727 |
|
|
757 |
|
|
758 |
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
759 |
\\</tr\\>\n" |
\\</tr\\>\n" |
760 |
|
|
761 |
(if !showTotal then "Total" else (brand_to_string (brand_of_int i))) |
(if !showTotal then "Total" else (brand_to_string (brand_of_int i))) |
762 |
|
|
763 |
(if !showTotal then sstats_all.brand_seen else |
(if !showTotal then sstats_all.brand_seen else |
764 |
stats_by_brand.(i).brand_seen) |
stats_by_brand.(i).brand_seen) |
765 |
|
|
766 |
(if !showTotal then 100.0 else (percent_of_ints |
(if !showTotal then 100.0 else (percent_of_ints |
767 |
stats_by_brand.(i).brand_seen stats_all.brand_seen)) |
stats_by_brand.(i).brand_seen stats_all.brand_seen)) |
768 |
|
|
769 |
(if !showTotal then sstats_all.brand_filerequest else stats_by_brand.(i).brand_filerequest) |
(if !showTotal then sstats_all.brand_filerequest else stats_by_brand.(i).brand_filerequest) |
770 |
|
|
771 |
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest)) |
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest)) |
772 |
|
|
773 |
(if !showTotal then sstats_all.brand_banned else |
(if !showTotal then sstats_all.brand_banned else |
774 |
stats_by_brand.(i).brand_banned) |
stats_by_brand.(i).brand_banned) |
775 |
|
|
776 |
(max 0.0 (if !showTotal then (percent_of_ints sstats_all.brand_banned sstats_all.brand_seen) |
(max 0.0 (if !showTotal then (percent_of_ints sstats_all.brand_banned sstats_all.brand_seen) |
777 |
else (percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned))) |
else (percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned))) |
778 |
|
|
779 |
(size_of_int64 (if !showTotal then sstats_all.brand_upload else |
(size_of_int64 (if !showTotal then sstats_all.brand_upload else |
780 |
stats_by_brand.(i).brand_upload)) |
stats_by_brand.(i).brand_upload)) |
781 |
|
|
782 |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
783 |
stats_by_brand.(i).brand_upload stats_all.brand_upload))) |
stats_by_brand.(i).brand_upload stats_all.brand_upload))) |
784 |
|
|
785 |
(if !showTotal then ((Int64.to_float sstats_all.brand_upload) /. (float_of_int uptime) /. 1024.0) |
(if !showTotal then ((Int64.to_float sstats_all.brand_upload) /. (float_of_int uptime) /. 1024.0) |
786 |
else ((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int uptime) /. 1024.0)) |
else ((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int uptime) /. 1024.0)) |
787 |
|
|
788 |
(size_of_int64 (if !showTotal then sstats_all.brand_download else |
(size_of_int64 (if !showTotal then sstats_all.brand_download else |
789 |
stats_by_brand.(i).brand_download)) |
stats_by_brand.(i).brand_download)) |
790 |
|
|
791 |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
792 |
stats_by_brand.(i).brand_download stats_all.brand_download))) |
stats_by_brand.(i).brand_download stats_all.brand_download))) |
794 |
(if !showTotal then ((Int64.to_float sstats_all.brand_download) /. (float_of_int uptime) /. 1024.0) |
(if !showTotal then ((Int64.to_float sstats_all.brand_download) /. (float_of_int uptime) /. 1024.0) |
795 |
else ((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int uptime) /. 1024.0)) |
else ((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int uptime) /. 1024.0)) |
796 |
|
|
797 |
(if !showTotal then |
(if !showTotal then |
798 |
(if sstats_all.brand_upload = Int64.zero then 0.0 else |
(if sstats_all.brand_upload = Int64.zero then 0.0 else |
799 |
( (Int64.to_float sstats_all.brand_download) /. (Int64.to_float sstats_all.brand_upload) )) |
( (Int64.to_float sstats_all.brand_download) /. (Int64.to_float sstats_all.brand_upload) )) |
800 |
else |
else |
801 |
(if stats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
(if stats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
802 |
( (Int64.to_float stats_by_brand.(i).brand_download) /. |
( (Int64.to_float stats_by_brand.(i).brand_download) /. |
803 |
(Int64.to_float stats_by_brand.(i).brand_upload) ))); |
(Int64.to_float stats_by_brand.(i).brand_upload) ))); |
804 |
end |
end |
805 |
done; |
done; |
806 |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
807 |
|
|
808 |
let gdays = (guptime () + uptime) / one_day in |
let gdays = (guptime () + uptime) / one_day in |
809 |
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
810 |
|
|
811 |
let ghours = grem / one_hour in |
let ghours = grem / one_hour in |
812 |
let grem = grem - ghours * one_hour in |
let grem = grem - ghours * one_hour in |
813 |
let gmins = grem / one_minute in |
let gmins = grem / one_minute in |
814 |
|
|
815 |
Printf.bprintf buf "\n\\<div class=\\\"cs\\\"\\>Total Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
Printf.bprintf buf "\n\\<div class=\\\"cs\\\"\\>Total Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
816 |
gdays ghours gmins (guptime() + uptime); |
gdays ghours gmins (guptime() + uptime); |
817 |
stats_html_header buf; |
stats_html_header buf; |
818 |
|
|
819 |
showTotal := false; |
showTotal := false; |
820 |
for i=1 to brand_count do |
for i=1 to brand_count do |
821 |
if i=brand_count then showTotal := true; |
if i=brand_count then showTotal := true; |
853 |
|
|
854 |
(if !showTotal then "Total" else (brand_to_string (brand_of_int i)) ) |
(if !showTotal then "Total" else (brand_to_string (brand_of_int i)) ) |
855 |
|
|
856 |
(if !showTotal then gstats_all.brand_seen else !!gstats_by_brand.(i).brand_seen) |
(if !showTotal then gstats_all.brand_seen else !!gstats_by_brand.(i).brand_seen) |
857 |
|
|
858 |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_seen) gstats_all.brand_seen)) |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_seen) gstats_all.brand_seen)) |
859 |
|
|
860 |
(if !showTotal then gstats_all.brand_filerequest else !!gstats_by_brand.(i).brand_filerequest) |
(if !showTotal then gstats_all.brand_filerequest else !!gstats_by_brand.(i).brand_filerequest) |
861 |
|
|
862 |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_filerequest) gstats_all.brand_filerequest)) |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand.(i).brand_filerequest) gstats_all.brand_filerequest)) |
863 |
|
|
864 |
(if !showTotal then gstats_all.brand_banned else !!gstats_by_brand.(i).brand_banned) |
(if !showTotal then gstats_all.brand_banned else !!gstats_by_brand.(i).brand_banned) |
865 |
|
|
866 |
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_banned |
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_banned |
867 |
gstats_all.brand_seen) else (percent_of_ints (!!gstats_by_brand.(i).brand_banned) gstats_all.brand_banned))) |
gstats_all.brand_seen) else (percent_of_ints (!!gstats_by_brand.(i).brand_banned) gstats_all.brand_banned))) |
868 |
|
|
869 |
(size_of_int64 (if !showTotal then gstats_all.brand_upload else !!gstats_by_brand.(i).brand_upload)) |
(size_of_int64 (if !showTotal then gstats_all.brand_upload else !!gstats_by_brand.(i).brand_upload)) |
870 |
|
|
871 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
872 |
(!!gstats_by_brand.(i).brand_upload) gstats_all.brand_upload))) |
(!!gstats_by_brand.(i).brand_upload) gstats_all.brand_upload))) |
873 |
|
|
875 |
else ((Int64.to_float (!!gstats_by_brand.(i).brand_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
else ((Int64.to_float (!!gstats_by_brand.(i).brand_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
876 |
|
|
877 |
(size_of_int64 (if !showTotal then gstats_all.brand_download else !!gstats_by_brand.(i).brand_download)) |
(size_of_int64 (if !showTotal then gstats_all.brand_download else !!gstats_by_brand.(i).brand_download)) |
878 |
|
|
879 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
880 |
(!!gstats_by_brand.(i).brand_download) gstats_all.brand_download))) |
(!!gstats_by_brand.(i).brand_download) gstats_all.brand_download))) |
881 |
|
|
882 |
(if !showTotal then ((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
(if !showTotal then ((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
883 |
else ((Int64.to_float (!!gstats_by_brand.(i).brand_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
else ((Int64.to_float (!!gstats_by_brand.(i).brand_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
884 |
|
|
885 |
(if !showTotal then (if gstats_all.brand_upload = Int64.zero then 0.0 else |
(if !showTotal then (if gstats_all.brand_upload = Int64.zero then 0.0 else |
886 |
((Int64.to_float gstats_all.brand_download) /. (Int64.to_float gstats_all.brand_upload) )) else |
((Int64.to_float gstats_all.brand_download) /. (Int64.to_float gstats_all.brand_upload) )) else |
887 |
(if !!gstats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
(if !!gstats_by_brand.(i).brand_upload = Int64.zero then 0.0 else |
888 |
( (Int64.to_float !!gstats_by_brand.(i).brand_download) /. |
( (Int64.to_float !!gstats_by_brand.(i).brand_download) /. |
889 |
(Int64.to_float !!gstats_by_brand.(i).brand_upload) ))) |
(Int64.to_float !!gstats_by_brand.(i).brand_upload) ))) |
890 |
end |
end |
897 |
days hours mins uptime; |
days hours mins uptime; |
898 |
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
899 |
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
900 |
|
|
901 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
902 |
if brand_of_int i != Brand_server && stats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
if brand_of_int i != Brand_server && stats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
903 |
let brandstr = |
let brandstr = |
904 |
if brand_of_int i = Brand_mldonkey3 then |
if brand_of_int i = Brand_mldonkey3 then |
905 |
"trusted mld" |
"trusted mld" |
906 |
else |
else |
907 |
brand_to_string (brand_of_int i) in |
brand_to_string (brand_of_int i) in |
908 |
|
|
909 |
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
910 |
(brandstr) |
(brandstr) |
911 |
stats_by_brand.(i).brand_seen |
stats_by_brand.(i).brand_seen |
912 |
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
(percent_of_ints stats_by_brand.(i).brand_seen stats_all.brand_seen) |
913 |
((Int64.to_float stats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
((Int64.to_float stats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
914 |
((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float stats_by_brand.(i).brand_download) /. (float_of_int uptime) /. 1024.0) |
916 |
((Int64.to_float stats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float stats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
917 |
((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float stats_by_brand.(i).brand_upload) /. (float_of_int uptime) /. 1024.0) |
918 |
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
(percent_of_int64s stats_by_brand.(i).brand_upload stats_all.brand_upload) |
919 |
stats_by_brand.(i).brand_banned |
stats_by_brand.(i).brand_banned |
920 |
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
(percent_of_ints stats_by_brand.(i).brand_banned stats_all.brand_banned) |
921 |
stats_by_brand.(i).brand_filerequest |
stats_by_brand.(i).brand_filerequest |
922 |
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
(percent_of_ints stats_by_brand.(i).brand_filerequest stats_all.brand_filerequest) |
930 |
((Int64.to_float sstats_all.brand_download) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float sstats_all.brand_download) /. (float_of_int uptime) /. 1024.0) |
931 |
((Int64.to_float sstats_all.brand_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float sstats_all.brand_upload) /. 1024.0 /. 1024.0) |
932 |
((Int64.to_float sstats_all.brand_upload) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float sstats_all.brand_upload) /. (float_of_int uptime) /. 1024.0) |
933 |
sstats_all.brand_banned |
sstats_all.brand_banned |
934 |
sstats_all.brand_filerequest; |
sstats_all.brand_filerequest; |
935 |
|
|
936 |
let gdays = (guptime () + uptime) / one_day in |
let gdays = (guptime () + uptime) / one_day in |
942 |
gdays ghours gmins (guptime() + uptime); |
gdays ghours gmins (guptime() + uptime); |
943 |
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
Printf.bprintf buf "Client Brand| seen | Downloads | Uploads | Banned | Requests\n"; |
944 |
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
Printf.bprintf buf "------------+--------------+--------------------+--------------------+------------+--------------\n"; |
945 |
|
|
946 |
for i=1 to brand_count-1 do |
for i=1 to brand_count-1 do |
947 |
if brand_of_int i != Brand_server && !!gstats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
if brand_of_int i != Brand_server && !!gstats_by_brand.(i).brand_seen > 0 then (* dont print server stats *) |
948 |
let brandstr = |
let brandstr = |
949 |
if brand_of_int i = Brand_mldonkey3 then |
if brand_of_int i = Brand_mldonkey3 then |
950 |
"trusted mld" |
"trusted mld" |
951 |
else |
else |
952 |
brand_to_string (brand_of_int i) in |
brand_to_string (brand_of_int i) in |
953 |
|
|
954 |
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
Printf.bprintf buf "%-12s|%9d %3.f%%|%9.1f %5.1f %3.0f%%|%9.1f %5.1f %3.0f%%|%7d %3.0f%%|%9d %3.0f%%\n" |
955 |
(brandstr) |
(brandstr) |
956 |
!!gstats_by_brand.(i).brand_seen |
!!gstats_by_brand.(i).brand_seen |
957 |
(percent_of_ints !!gstats_by_brand.(i).brand_seen gstats_all.brand_seen) |
(percent_of_ints !!gstats_by_brand.(i).brand_seen gstats_all.brand_seen) |
958 |
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. 1024.0 /. 1024.0) |
959 |
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
((Int64.to_float !!gstats_by_brand.(i).brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
961 |
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. 1024.0 /. 1024.0) |
962 |
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
((Int64.to_float !!gstats_by_brand.(i).brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
963 |
(percent_of_int64s !!gstats_by_brand.(i).brand_upload gstats_all.brand_upload) |
(percent_of_int64s !!gstats_by_brand.(i).brand_upload gstats_all.brand_upload) |
964 |
!!gstats_by_brand.(i).brand_banned |
!!gstats_by_brand.(i).brand_banned |
965 |
(percent_of_ints !!gstats_by_brand.(i).brand_banned gstats_all.brand_banned) |
(percent_of_ints !!gstats_by_brand.(i).brand_banned gstats_all.brand_banned) |
966 |
!!gstats_by_brand.(i).brand_filerequest |
!!gstats_by_brand.(i).brand_filerequest |
967 |
(percent_of_ints !!gstats_by_brand.(i).brand_filerequest gstats_all.brand_filerequest) |
(percent_of_ints !!gstats_by_brand.(i).brand_filerequest gstats_all.brand_filerequest) |
975 |
((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
((Int64.to_float gstats_all.brand_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
976 |
((Int64.to_float gstats_all.brand_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float gstats_all.brand_upload) /. 1024.0 /. 1024.0) |
977 |
((Int64.to_float gstats_all.brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
((Int64.to_float gstats_all.brand_upload) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
978 |
gstats_all.brand_banned |
gstats_all.brand_banned |
979 |
gstats_all.brand_filerequest; |
gstats_all.brand_filerequest; |
980 |
|
|
981 |
end |
end |
982 |
|
|
983 |
let new_print_mod_stats buf o = |
let new_print_mod_stats buf o = |
987 |
let uptime = last_time () - start_time in |
let uptime = last_time () - start_time in |
988 |
let days = uptime / one_day in |
let days = uptime / one_day in |
989 |
let rem = maxi 1 (uptime - days * one_day) in |
let rem = maxi 1 (uptime - days * one_day) in |
990 |
|
|
991 |
let hours = rem / one_hour in |
let hours = rem / one_hour in |
992 |
let rem = rem - hours * one_hour in |
let rem = rem - hours * one_hour in |
993 |
let mins = rem / one_minute in |
let mins = rem / one_minute in |
994 |
|
|
995 |
if !!emule_mods_count then |
if !!emule_mods_count then |
996 |
|
|
997 |
if use_html_mods o then |
if use_html_mods o then |
998 |
begin |
begin |
999 |
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>Session Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>Session Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
1000 |
days hours mins uptime; |
days hours mins uptime; |
1001 |
stats_html_header buf; |
stats_html_header buf; |
1002 |
|
|
1003 |
let counter = ref 0 in |
let counter = ref 0 in |
1004 |
let showTotal = ref false in |
let showTotal = ref false in |
1005 |
|
|
1035 |
|
|
1036 |
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
\\<td class=\\\"sr \\\"\\>1:%.2f\\</td\\> |
1037 |
\\</tr\\>\n" |
\\</tr\\>\n" |
1038 |
|
|
1039 |
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i))) |
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i))) |
1040 |
|
|
1041 |
(if !showTotal then mod_stats_all.brand_mod_seen else |
(if !showTotal then mod_stats_all.brand_mod_seen else |
1042 |
stats_by_brand_mod.(i).brand_mod_seen) |
stats_by_brand_mod.(i).brand_mod_seen) |
1043 |
|
|
1044 |
(if !showTotal then 100.0 else (percent_of_ints |
(if !showTotal then 100.0 else (percent_of_ints |
1045 |
stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen)) |
stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen)) |
1046 |
|
|
1047 |
(if !showTotal then mod_stats_all.brand_mod_filerequest else stats_by_brand_mod.(i).brand_mod_filerequest) |
(if !showTotal then mod_stats_all.brand_mod_filerequest else stats_by_brand_mod.(i).brand_mod_filerequest) |
1048 |
|
|
1049 |
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand_mod.(i).brand_mod_filerequest mod_stats_all.brand_mod_filerequest)) |
(if !showTotal then 100.0 else (percent_of_ints stats_by_brand_mod.(i).brand_mod_filerequest mod_stats_all.brand_mod_filerequest)) |
1050 |
|
|
1051 |
(if !showTotal then mod_stats_all.brand_mod_banned else |
(if !showTotal then mod_stats_all.brand_mod_banned else |
1052 |
stats_by_brand_mod.(i).brand_mod_banned) |
stats_by_brand_mod.(i).brand_mod_banned) |
1053 |
|
|
1054 |
(max 0.0 (if !showTotal then (percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen) |
(max 0.0 (if !showTotal then (percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen) |
1055 |
else (percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned))) |
else (percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned))) |
1056 |
|
|
1057 |
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_upload else |
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_upload else |
1058 |
stats_by_brand_mod.(i).brand_mod_upload)) |
stats_by_brand_mod.(i).brand_mod_upload)) |
1059 |
|
|
1060 |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
1061 |
stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload))) |
stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload))) |
1062 |
|
|
1063 |
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
1064 |
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int uptime) /. 1024.0)) |
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int uptime) /. 1024.0)) |
1065 |
|
|
1066 |
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_download else |
(size_of_int64 (if !showTotal then mod_stats_all.brand_mod_download else |
1067 |
stats_by_brand_mod.(i).brand_mod_download)) |
stats_by_brand_mod.(i).brand_mod_download)) |
1068 |
|
|
1069 |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
(max 0.0 (if !showTotal then 100.0 else (percent_of_int64s |
1070 |
stats_by_brand_mod.(i).brand_mod_download mod_stats_all.brand_mod_download))) |
stats_by_brand_mod.(i).brand_mod_download mod_stats_all.brand_mod_download))) |
1072 |
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
(if !showTotal then ((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
1073 |
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int uptime) /. 1024.0)) |
else ((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int uptime) /. 1024.0)) |
1074 |
|
|
1075 |
(if !showTotal then |
(if !showTotal then |
1076 |
(if mod_stats_all.brand_mod_upload = Int64.zero then 0.0 else |
(if mod_stats_all.brand_mod_upload = Int64.zero then 0.0 else |
1077 |
( (Int64.to_float mod_stats_all.brand_mod_download) /. (Int64.to_float mod_stats_all.brand_mod_upload) )) |
( (Int64.to_float mod_stats_all.brand_mod_download) /. (Int64.to_float mod_stats_all.brand_mod_upload) )) |
1078 |
else |
else |
1079 |
(if stats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
(if stats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
1080 |
( (Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. |
( (Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. |
1081 |
(Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) ))); |
(Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) ))); |
1082 |
end |
end |
1083 |
done; |
done; |
1084 |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
Printf.bprintf buf "\\</table\\>\\</div\\>\n"; |
1085 |
|
|
1086 |
let gstats_all = |
let gstats_all = |
1087 |
let stat = { |
let stat = { |
1088 |
brand_mod_seen = 0; |
brand_mod_seen = 0; |
1089 |
brand_mod_banned = 0; |
brand_mod_banned = 0; |
1092 |
brand_mod_upload = Int64.zero |
brand_mod_upload = Int64.zero |
1093 |
} |
} |
1094 |
in stat in |
in stat in |
1095 |
|
|
1096 |
for i=0 to brand_mod_count-1 do |
for i=0 to brand_mod_count-1 do |
1097 |
|
|
1098 |
gstats_all.brand_mod_seen <- gstats_all.brand_mod_seen + !!gstats_by_brand_mod.(i).brand_mod_seen; |
gstats_all.brand_mod_seen <- gstats_all.brand_mod_seen + !!gstats_by_brand_mod.(i).brand_mod_seen; |
1099 |
gstats_all.brand_mod_filerequest <- gstats_all.brand_mod_filerequest + !!gstats_by_brand_mod.(i).brand_mod_filerequest; |
gstats_all.brand_mod_filerequest <- gstats_all.brand_mod_filerequest + !!gstats_by_brand_mod.(i).brand_mod_filerequest; |
1100 |
gstats_all.brand_mod_download <- Int64.add gstats_all.brand_mod_download !!gstats_by_brand_mod.(i).brand_mod_download ; |
gstats_all.brand_mod_download <- Int64.add gstats_all.brand_mod_download !!gstats_by_brand_mod.(i).brand_mod_download ; |
1101 |
gstats_all.brand_mod_upload <- Int64.add gstats_all.brand_mod_upload !!gstats_by_brand_mod.(i).brand_mod_upload; |
gstats_all.brand_mod_upload <- Int64.add gstats_all.brand_mod_upload !!gstats_by_brand_mod.(i).brand_mod_upload; |
1102 |
gstats_all.brand_mod_banned <- gstats_all.brand_mod_banned + !!gstats_by_brand_mod.(i).brand_mod_banned; |
gstats_all.brand_mod_banned <- gstats_all.brand_mod_banned + !!gstats_by_brand_mod.(i).brand_mod_banned; |
1103 |
|
|
1104 |
done; |
done; |
1105 |
let gdays = (guptime () + uptime) / one_day in |
let gdays = (guptime () + uptime) / one_day in |
1106 |
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
let grem = maxi 1 ((guptime () + uptime) - gdays * one_day) in |
1107 |
|
|
1108 |
let ghours = grem / one_hour in |
let ghours = grem / one_hour in |
1109 |
let grem = grem - ghours * one_hour in |
let grem = grem - ghours * one_hour in |
1110 |
let gmins = grem / one_minute in |
let gmins = grem / one_minute in |
1111 |
|
|
1112 |
Printf.bprintf buf "\n\\<div class=\\\"cs\\\"\\>Total Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
Printf.bprintf buf "\n\\<div class=\\\"cs\\\"\\>Total Uptime: %d days, %02dh:%02dm (= %d seconds)\\</div\\>" |
1113 |
gdays ghours gmins (guptime() + uptime); |
gdays ghours gmins (guptime() + uptime); |
1114 |
stats_html_header buf; |
stats_html_header buf; |
1115 |
|
|
1116 |
showTotal := false; |
showTotal := false; |
1117 |
for i=1 to brand_mod_count do |
for i=1 to brand_mod_count do |
1118 |
if i=brand_mod_count then showTotal := true; |
if i=brand_mod_count then showTotal := true; |
1150 |
|
|
1151 |
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i)) ) |
(if !showTotal then "Total" else (brand_mod_to_string (brand_mod_of_int i)) ) |
1152 |
|
|
1153 |
(if !showTotal then gstats_all.brand_mod_seen else !!gstats_by_brand_mod.(i).brand_mod_seen) |
(if !showTotal then gstats_all.brand_mod_seen else !!gstats_by_brand_mod.(i).brand_mod_seen) |
1154 |
|
|
1155 |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_seen) gstats_all.brand_mod_seen)) |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_seen) gstats_all.brand_mod_seen)) |
1156 |
|
|
1157 |
(if !showTotal then gstats_all.brand_mod_filerequest else !!gstats_by_brand_mod.(i).brand_mod_filerequest) |
(if !showTotal then gstats_all.brand_mod_filerequest else !!gstats_by_brand_mod.(i).brand_mod_filerequest) |
1158 |
|
|
1159 |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_filerequest) gstats_all.brand_mod_filerequest)) |
(if !showTotal then 100. else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_filerequest) gstats_all.brand_mod_filerequest)) |
1160 |
|
|
1161 |
(if !showTotal then gstats_all.brand_mod_banned else !!gstats_by_brand_mod.(i).brand_mod_banned) |
(if !showTotal then gstats_all.brand_mod_banned else !!gstats_by_brand_mod.(i).brand_mod_banned) |
1162 |
|
|
1163 |
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_mod_banned |
(max 0.0 (if !showTotal then (percent_of_ints gstats_all.brand_mod_banned |
1164 |
gstats_all.brand_mod_seen) else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_banned) gstats_all.brand_mod_banned))) |
gstats_all.brand_mod_seen) else (percent_of_ints (!!gstats_by_brand_mod.(i).brand_mod_banned) gstats_all.brand_mod_banned))) |
1165 |
|
|
1166 |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_upload else !!gstats_by_brand_mod.(i).brand_mod_upload)) |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_upload else !!gstats_by_brand_mod.(i).brand_mod_upload)) |
1167 |
|
|
1168 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
1169 |
(!!gstats_by_brand_mod.(i).brand_mod_upload) gstats_all.brand_mod_upload))) |
(!!gstats_by_brand_mod.(i).brand_mod_upload) gstats_all.brand_mod_upload))) |
1170 |
|
|
1172 |
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_upload)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
1173 |
|
|
1174 |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_download else !!gstats_by_brand_mod.(i).brand_mod_download)) |
(size_of_int64 (if !showTotal then gstats_all.brand_mod_download else !!gstats_by_brand_mod.(i).brand_mod_download)) |
1175 |
|
|
1176 |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
(if !showTotal then 100. else (max 0.0 (percent_of_int64s |
1177 |
(!!gstats_by_brand_mod.(i).brand_mod_download) gstats_all.brand_mod_download))) |
(!!gstats_by_brand_mod.(i).brand_mod_download) gstats_all.brand_mod_download))) |
1178 |
|
|
1179 |
(if !showTotal then ((Int64.to_float gstats_all.brand_mod_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
(if !showTotal then ((Int64.to_float gstats_all.brand_mod_download) /. (float_of_int (guptime() + uptime)) /. 1024.0) |
1180 |
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
else ((Int64.to_float (!!gstats_by_brand_mod.(i).brand_mod_download)) /. (float_of_int (guptime() + uptime)) /. 1024.0)) |
1181 |
|
|
1182 |
(if !showTotal then (if gstats_all.brand_mod_upload = Int64.zero then 0.0 else |
(if !showTotal then (if gstats_all.brand_mod_upload = Int64.zero then 0.0 else |
1183 |
((Int64.to_float gstats_all.brand_mod_download) /. (Int64.to_float gstats_all.brand_mod_upload) )) else |
((Int64.to_float gstats_all.brand_mod_download) /. (Int64.to_float gstats_all.brand_mod_upload) )) else |
1184 |
(if !!gstats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
(if !!gstats_by_brand_mod.(i).brand_mod_upload = Int64.zero then 0.0 else |
1185 |
( (Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_download) /. |
( (Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_download) /. |
1186 |
(Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_upload) ))) |
(Int64.to_float !!gstats_by_brand_mod.(i).brand_mod_upload) ))) |
1187 |
end |
end |
1195 |
Printf.bprintf buf " MOD| seen | Downloads | Uploads | Banned\n"; |
Printf.bprintf buf " MOD| seen | Downloads | Uploads | Banned\n"; |
1196 |
Printf.bprintf buf "------------+-----------+------------------+------------------+----------\n"; |
Printf.bprintf buf "------------+-----------+------------------+------------------+----------\n"; |
1197 |
Printf.bprintf buf "%-12s|%6d |%7.1f %5.1f |%7.1f %5.1f |%5d %3.0f%%\n" |
Printf.bprintf buf "%-12s|%6d |%7.1f %5.1f |%7.1f %5.1f |%5d %3.0f%%\n" |
1198 |
|
|
1199 |
"Total" |
"Total" |
1200 |
mod_stats_all.brand_mod_seen |
mod_stats_all.brand_mod_seen |
1201 |
((Int64.to_float mod_stats_all.brand_mod_download) /. 1024.0 /. 1024.0) |
((Int64.to_float mod_stats_all.brand_mod_download) /. 1024.0 /. 1024.0) |
1202 |
((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float mod_stats_all.brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
1203 |
((Int64.to_float mod_stats_all.brand_mod_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float mod_stats_all.brand_mod_upload) /. 1024.0 /. 1024.0) |
1204 |
((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float mod_stats_all.brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
1205 |
mod_stats_all.brand_mod_banned |
mod_stats_all.brand_mod_banned |
1206 |
(percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen); |
(percent_of_ints mod_stats_all.brand_mod_banned mod_stats_all.brand_mod_seen); |
1207 |
|
|
1208 |
for i=1 to brand_mod_count-1 do |
for i=1 to brand_mod_count-1 do |
1209 |
let brandstr = |
let brandstr = |
1210 |
brand_mod_to_string (brand_mod_of_int i) in |
brand_mod_to_string (brand_mod_of_int i) in |
1211 |
|
|
1212 |
Printf.bprintf buf "%-12s|%6d %3.f%%|%7.1f %5.1f %3.0f%%|%7.1f %5.1f %3.0f%%|%5d %3.0f%%\n" |
Printf.bprintf buf "%-12s|%6d %3.f%%|%7.1f %5.1f %3.0f%%|%7.1f %5.1f %3.0f%%|%5d %3.0f%%\n" |
1213 |
(brandstr) |
(brandstr) |
1214 |
stats_by_brand_mod.(i).brand_mod_seen |
stats_by_brand_mod.(i).brand_mod_seen |
1215 |
(percent_of_ints stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen) |
(percent_of_ints stats_by_brand_mod.(i).brand_mod_seen mod_stats_all.brand_mod_seen) |
1216 |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. 1024.0 /. 1024.0) |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. 1024.0 /. 1024.0) |
1217 |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_download) /. (float_of_int uptime) /. 1024.0) |
1219 |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. 1024.0 /. 1024.0) |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. 1024.0 /. 1024.0) |
1220 |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
((Int64.to_float stats_by_brand_mod.(i).brand_mod_upload) /. (float_of_int uptime) /. 1024.0) |
1221 |
(percent_of_int64s stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload) |
(percent_of_int64s stats_by_brand_mod.(i).brand_mod_upload mod_stats_all.brand_mod_upload) |
1222 |
stats_by_brand_mod.(i).brand_mod_banned |
stats_by_brand_mod.(i).brand_mod_banned |
1223 |
(percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned) |
(percent_of_ints stats_by_brand_mod.(i).brand_mod_banned mod_stats_all.brand_mod_banned) |
1224 |
done |
done |
1225 |
end |
end |
1230 |
html_mods_table_header buf "emodsTable" "cs" []; |
html_mods_table_header buf "emodsTable" "cs" []; |
1231 |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>"; |
1232 |
html_mods_td buf [ |
html_mods_td buf [ |
1233 |
("", "sr", |
("", "sr", |
1234 |
"eMule mods statistics are disabled, to activate set emule_mods_count true in the \\<a href=\\\"/submit?q=voo+8\\\"\\>misc options\\</a\\> tab." ); ]; |
"eMule mods statistics are disabled, to activate set emule_mods_count true in the \\<a href=\\\"/submit?q=voo+8\\\"\\>misc options\\</a\\> tab." ); ]; |
1235 |
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>\n" |
Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>\n" |
1236 |
end |
end |
1242 |
|
|
1243 |
|
|
1244 |
(* |
(* |
1245 |
let save_download_history file = |
let save_download_history file = |
1246 |
|
|
1247 |
let buf = Buffer.create 100 in |
let buf = Buffer.create 100 in |
1248 |
|
|
1249 |
(* Some opcode for edonkey downloads *) |
(* Some opcode for edonkey downloads *) |
1258 |
buf_int8 buf time.Unix.tm_mon; |
buf_int8 buf time.Unix.tm_mon; |
1259 |
buf_int16 buf time.Unix.tm_year; |
buf_int16 buf time.Unix.tm_year; |
1260 |
(* ANONYMISED Informations on the downloads: *) |
(* ANONYMISED Informations on the downloads: *) |
1261 |
(* Send the SHA1 hash of the MD4+size, so that they cannot be recovered, |
(* Send the SHA1 hash of the MD4+size, so that they cannot be recovered, |
1262 |
but they can be used to compare downloads. *) |
but they can be used to compare downloads. *) |
1263 |
let m = Printf.sprintf "%s%Ld" |
let m = Printf.sprintf "%s%Ld" |
1264 |
(Md4.Md4.direct_to_string file.file_md4) (file_size file) in |
(Md4.Md4.direct_to_string file.file_md4) (file_size file) in |
1265 |
let m = Md4.Sha1.string m in (* compute SHA1 of the string *) |
let m = Md4.Sha1.string m in (* compute SHA1 of the string *) |
1266 |
(* SENT: 20 bytes *) |
(* SENT: 20 bytes *) |
1275 |
done; |
done; |
1276 |
(* SENT: 1 byte *) |
(* SENT: 1 byte *) |
1277 |
buf_int8 buf !m; |
buf_int8 buf !m; |
1278 |
|
|
1279 |
let current = ref [] in |
let current = ref [] in |
1280 |
|
|
1281 |
Intmap.iter (fun _ c -> |
Intmap.iter (fun _ c -> |
1282 |
let location = |
let location = |
1283 |
match c.client_kind with |
match c.client_kind with |
1284 |
Indirect_location (name, md4) -> |
Indirect_location (name, md4) -> |
1285 |
Printf.sprintf "%s%s" name |
Printf.sprintf "%s%s" name |
1286 |
(Md4.Md4.direct_to_string md4) |
(Md4.Md4.direct_to_string md4) |
1287 |
| Known_location (ip,port) -> |
| Known_location (ip,port) -> |
1288 |
Printf.sprintf "%s%d" |
Printf.sprintf "%s%d" |
1294 |
let location = Md4.Sha1.string location in (* compute SHA1 of the string *) |
let location = Md4.Sha1.string location in (* compute SHA1 of the string *) |
1295 |
current := location :: !current; |
current := location :: !current; |
1296 |
) file.file_locations; |
) file.file_locations; |
1297 |
|
|
1298 |
buf_list (fun buf s -> |
buf_list (fun buf s -> |
1299 |
Buffer.add_string buf (Md4.Sha1.direct_to_string s) |
Buffer.add_string buf (Md4.Sha1.direct_to_string s) |
1300 |
) buf !current; |
) buf !current; |
1301 |
|
|
1302 |
|
|
1303 |
let file_history = "downloads.stats" in |
let file_history = "downloads.stats" in |
1304 |
let oc = append_out file_history in |
let oc = append_out file_history in |
1305 |
output_string oc (Buffer.contents buf); |
output_string oc (Buffer.contents buf); |
1306 |
close_out oc |
close_out oc |
1307 |
*) |
*) |
1308 |
|
|
1309 |
let _ = |
let _ = |
1310 |
network.op_network_display_stats <- (fun buf o -> new_print_stats buf o); |
network.op_network_display_stats <- (fun buf o -> new_print_stats buf o); |
1311 |
|
|
1312 |
register_commands |
register_commands |
1313 |
[ |
[ |
1314 |
"client_stats", "Network/Donkey",Arg_none (fun o -> |
"client_stats", "Network/Donkey",Arg_none (fun o -> |
1315 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
1316 |
print_stats buf; |
print_stats buf; |
1317 |
"" |
"" |
1318 |
), ":\t\t\t\tshow breakdown of download/upload by clients brand"; |
), ":\t\t\t\tshow breakdown of download/upload by clients brand"; |
1319 |
|
|
1320 |
"cs", "Network/Donkey",Arg_none (fun o -> |
"cs", "Network/Donkey",Arg_none (fun o -> |
1321 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
1322 |
new_print_stats buf o; |
new_print_stats buf o; |
1323 |
"" |
"" |
1324 |
), ":\t\t\t\t\tshow table of download/upload by ED2K clients brand"; |
), ":\t\t\t\t\tshow table of download/upload by ED2K clients brand"; |
1325 |
|
|
1326 |
"csm", "Network/Donkey",Arg_none (fun o -> |
"csm", "Network/Donkey",Arg_none (fun o -> |
1327 |
let buf = o.conn_buf in |
let buf = o.conn_buf in |
1328 |
new_print_mod_stats buf o; |
new_print_mod_stats buf o; |