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.3 -r1.4 --- openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 17 Aug 2006 01:32:27 -0000 1.3 +++ openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 13 Sep 2007 12:06:56 -0000 1.4 @@ -8,21 +8,16 @@ t request-monitor - + Gustaf Neumann Request Monitor with user tracking functionality 2006-08-16 - 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 + 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 @@ -31,22 +26,13 @@ - - - - + + + + + Index: openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl 13 Sep 2007 12:06:56 -0000 1.2 @@ -23,4 +23,27 @@ ### this is probably not sufficient to do something useful... } +# Populate the counters +# Initialize from the old counters +set logdir [parameter::get_from_package_key -package_key xotcl-request-monitor \ + -parameter log-dir \ + -default [file dirname [file root [ns_config ns/parameters ServerLog]]]] + +set nr_trend_elements [parameter::get_from_package_key -package_key "xotcl-request-monitor" -parameter "trend-elements" -default 48] +incr nr_trend_elements + +# Create the file to load. This is per hour = 60*3 + 2 lines +set number_of_lines [expr 182 * $nr_trend_elements] +exec /usr/bin/tail -n $number_of_lines ${logdir}/counter.log >${logdir}/counter-new.log +set f [open $logdir/counter-new.log] + +while {-1 != [gets $f line]} { + regexp {(.*) -- (.*) ::(.*) (.*)} $line match timestamp server label value + set nr_stats_elements [parameter::get_from_package_key -package_key "xotcl-request-monitor" -parameter "max-stats-elements" -default 48] + throttle do $label lappend trend $value + set stats [throttle do $label lappend stats [list $timestamp $value]] + set stats [lrange [lsort -real -decreasing -index 1 $stats] 0 [expr {$nr_stats_elements - 1}]] + throttle do $label set stats $stats +} + 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.7 -r1.8 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 5 Sep 2007 09:39:53 -0000 1.7 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 13 Sep 2007 12:06:56 -0000 1.8 @@ -162,8 +162,25 @@ Class create Counter -parameter { report timeoutMs {stats ""} {last ""} {trend ""} {c 0} {logging 0} - {nr_trend_elements 48} {nr_stats_elements 5} + {nr_trend_elements [parameter::get_from_package_key -package_key "xotcl-request-monitor" -parameter "trend-elements" -default 48]} {nr_stats_elements [parameter::get_from_package_key -package_key "xotcl-request-monitor" -parameter "max-stats-elements" -default 5]} + } -ad_doc { + This class holds the counted statistics so they do not have to be computed + all the time from the list of requests. + + The statistics holding objects are instances of this class and initialized and called after + the timeoutMS + + @param report Report type of the instance. This could e.g. be hours and minutes + @param timeoutMS How often are the statistics for this report computed + @param stats stats keeps nr_stats_elements highest values with time stamp. These hold a list of lists of the actual stats in the form {time value}. Time is given like "Thu Sep 13 09:17:30 CEST 2007". This is used for displaying the Max values + @param last + @param trend trend keeps nr_trend_elements most recent values. This is used for displaying the graphics + @param c + @param logging If set to 1 the instance current value is logged to the counter.log file + @param nr_trend_elements Number of data points that are used for the trend calculation. The default of 48 translates into "48 minutes" for the Views per minute or 48 hours for the views per hour. + @param nr_stats_elements Number of data points for the stats values. The default of 5 will give you the highest datapoints over the whole period. } + Counter instproc ++ {} { my incr c } @@ -197,7 +214,7 @@ # set now [clock format [clock seconds]] lappend stats [list $now $n] - set stats [lrange [lsort -real -decreasing -index 1 $stats] 0 [my nr_stats_elements]] + set stats [lrange [lsort -real -decreasing -index 1 $stats] 0 [expr {[my nr_stats_elements] - 1}]] # # log if necessary # @@ -232,7 +249,6 @@ MaxCounter user_count_hours -timeoutMs [expr {60000*60}] -logging 1 MaxCounter user_count_minutes -timeoutMs 60000 -report user_count_hours -logging 1 - Class create AvgCounter -superclass Counter \ -parameter {{t 0} {atleast 1}} -instproc end {} { if {[my c]>0} { @@ -630,11 +646,7 @@ return $_ } - - if {[catch {set ::package_id [::xo::package_id_from_package_key xotcl-request-monitor]}]} { - # old style - set ::package_id [::Generic::package_id_from_package_key xotcl-request-monitor] - } + set ::package_id [apm_package_id_from_key "xotcl-request-monitor"] ns_log notice "+++ package_id of xotcl-request-monitor is $::package_id" set logdir [parameter::get -package_id $::package_id \ @@ -822,4 +834,4 @@ return $left$ellipsis$right } return $string -} \ No newline at end of file +}