Index: openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info,v diff -u -N -r1.6 -r1.7 --- openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 23 May 2008 19:23:23 -0000 1.6 +++ openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 4 Oct 2008 19:26:51 -0000 1.7 @@ -8,18 +8,18 @@ t request-monitor - + Gustaf Neumann Request Monitor with user tracking functionality - 2008-05-23 + 2008-10-04 This package provides a Request Monitor for OACS applications. It computes performance summary information such as requests/views per seconds, average response time, number of users connected, lists currently active threads, etc. Furthermore it can block overactive users (e.g. automated web-bots mirroring the site, users repeating running queries, etc.). It provides as well some user tracking (such as whos-online) with activity measures, it blocks repeated requests (impatient reloads), tracks switching of IP-adresses from users and provides request tracking per user for the monitored time window. It contains as well overall url statistics with performance measures. Updated for cirumventing handler calls openacs 5.2 for /resources/*. 0.28 provides calles for listing active communities and users active in these communities. 0.30 provides a nice graphical chats (many thanks to Nima) and a new interface to the background thread. In addition, ns_returnfile_background is included; 0.38 using context form xotcl-core 0.39 brings parameterized counter values 0 - + Index: openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl,v diff -u -N -r1.15 -r1.16 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 26 May 2008 19:42:42 -0000 1.15 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 4 Oct 2008 19:26:51 -0000 1.16 @@ -221,7 +221,7 @@ ThrottleTrace instproc log {msg} { if {![my exists traceFile]} { set file $::logdir/calls - my set traceFile [open $file w] + my set traceFile [open $file a] my set traceCounter 0 } puts [my set traceFile] $msg @@ -241,6 +241,25 @@ #throttle do throttler mixin ThrottleTrace + + Class create TraceLongCalls + TraceLongCalls set count 0 + TraceLongCalls instproc log {msg} { + set traceFile [open $::logdir/long-calls.log a] + puts $traceFile "[clock format [clock seconds]] -- $msg" + close $traceFile + [self class] append log "[clock format [clock seconds]] -- $msg\n" + [self class] incr count + } + TraceLongCalls instproc add_url_stat {url time_used key pa content_type} { + if {$time_used > 5000} { + catch {my log [self args]} + } + next + } + + throttle do throttler mixin TraceLongCalls + ############################ # A simple counter class, which is able to aggregate values in some # higher level counters (report_to) and to keep statistics in form @@ -290,12 +309,13 @@ } Counter instproc log_to_file {timestamp label value} { - if {![my logging]} return set server [ns_info server] + ::xotcl::Object log "[self] log-to-file [my logging] - $::logdir/counter.log" set f [open $::logdir/counter.log a] puts $f "$timestamp -- $server $label $value" close $f } + Counter instproc add_value {timestamp n} { my instvar trend stats # @@ -322,7 +342,7 @@ # # log if necessary # - catch {my log_to_file $now [self] $n} + catch {if {[my logging]} {my log_to_file $now [self] $n}} # my set to [after [my timeoutMs] [list [self] end]] } @@ -339,7 +359,25 @@ Counter hours -timeoutMs [expr {60000*60}] -logging 1 Counter minutes -timeoutMs 60000 -report hours -logging 1 Counter seconds -timeoutMs 1000 -report minutes - + + # The counter user_count_day just records the number of active user + # per day. It differs from other counters by keeping track of a pair + # of values (authenticated and non-authenticated). + + Counter user_count_day -timeoutMs [expr {60000*60}] -logging 1 + user_count_day proc end {} { + ::xotcl::Object log XXX + foreach {auth ip} [throttle users perDay] break + set now [clock format [clock seconds]] + # The counter logs its intrinsic value (c) anyhow, which are the + # authenticated users. We also want to record the number of + # unauthenticated users, and do this here manually. + my log_to_file $now [self]-non-auth $ip + my set c $auth + Users perDayCleanup + next + } + Class create MaxCounter -superclass Counter -instproc end {} { my c [Users nr_active] if {[my exists report]} { @@ -756,11 +794,10 @@ my unset timestamp($i) } } - after [expr {60000*60}] [list [self] [self proc]] } # initialization of Users class object - Users perDayCleanup + #Users perDayCleanup Object create Users::users Users set last_mkey "" @@ -807,7 +844,11 @@ while {-1 != [gets $f line]} { regexp {(.*) -- (.*) ::(.*) (.*)} $line match timestamp server counter value #ns_log notice "$counter add_value $timestamp $value" - $counter add_value $timestamp $value + if {[::xotcl::Object isobject $counter]} { + $counter add_value $timestamp $value + } else { + ns_log notice "ignore reload of value $value for counter $counter" + } } close $f Index: openacs-4/packages/xotcl-request-monitor/www/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/index.tcl,v diff -u -N -r1.12 -r1.13 --- openacs-4/packages/xotcl-request-monitor/www/index.tcl 23 May 2008 19:23:24 -0000 1.12 +++ openacs-4/packages/xotcl-request-monitor/www/index.tcl 4 Oct 2008 19:26:51 -0000 1.13 @@ -263,15 +263,15 @@ } append current_system_activity \n[currentViews] -set active_users_10 [throttle users nr_active] set throttle_stats [throttle statistics] set active10 [throttle users nr_users_time_window] -set activeUsers10 [lindex $active10 1] +set authUsers10 [lindex $active10 1] set activeIP10 [lindex $active10 0] +set activeTotal10 [expr {$authUsers10 + $activeIP10}] set active24 [throttle users perDay] -set activeUsers24 [lindex $active24 1] +set authUsers24 [lindex $active24 1] set activeIP24 [lindex $active24 0] -set activeTotal24 [expr {$activeUsers24 + $activeIP24}] +set activeTotal24 [expr {$authUsers24 + $activeIP24}] if {[info command ::dotlrn_community::get_community_id] ne ""} { set nr [throttle users nr_active_communities] @@ -280,7 +280,7 @@ set active_community_string "" } -set active_user_string "$active_users_10 users ($activeUsers10 authenticated) $active_community_string active in last 10 minutes, $activeTotal24 ($activeUsers24 authenticated) in last $::server_running" +set active_user_string "$activeTotal10 users ($authUsers10 authenticated) $active_community_string active in last 10 minutes, $activeTotal24 ($authUsers24 authenticated) in last $::server_running" set jsGraph [expr {!$jsGraph}] set toggle_graphics_url [export_vars -base [ad_conn url] {jsGraph}] set jsGraph [expr {!$jsGraph}] Index: openacs-4/packages/xotcl-request-monitor/www/whos-online.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/whos-online.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/xotcl-request-monitor/www/whos-online.tcl 12 Sep 2008 19:44:57 -0000 1.9 +++ openacs-4/packages/xotcl-request-monitor/www/whos-online.tcl 4 Oct 2008 19:26:51 -0000 1.10 @@ -39,11 +39,11 @@ AnchorField name -label "User" -orderby name Field online_time -label "Last Activity" -html { align right } \ -orderby online_time + Field vpm -label "Views per min" -html { align center } -orderby vpm if {$admin} { Field activity -label "Activity" -html { align right } -orderby activity AnchorField hits -label "Hits" -orderby hits Field switches -label "Switches" -html { align center } -orderby switches - Field vpm -label "Views per min" -html { align center } -orderby vpm Field peer_address -label "Peer" -orderby peer_address } }] \ @@ -114,7 +114,7 @@ } switch -glob $orderby { name,* {set index 0; set type -dictionary} - online_time,* {set index 4; set type -real} + online_time,* {set index 3; set type -dictionary} activity,* {set index 5; set type -integer} hits,* {set index 5; set type -dictionary} switches,* {set index 8; set type -integer} @@ -144,12 +144,13 @@ -hits [lindex $e 6] \ -hits.href [lindex $e 7] \ -switches [lindex $e 8] \ - -vpm [lindex $e 11] \ + -vpm [format %.2f [lindex $e 11]] \ -peer_address [lindex $e 9] } else { t1 add -name [lindex $e 0] \ -name.href [lindex $e 1] \ - -online_time [lindex $e 3] + -online_time [lindex $e 3] \ + -vpm [format %.2f [lindex $e 11]] } }