Index: openacs-4/packages/xotcl-request-monitor/COPYRIGHT =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/COPYRIGHT,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/xotcl-request-monitor/COPYRIGHT 30 Dec 2005 00:07:23 -0000 1.1 @@ -0,0 +1,26 @@ + * xotcl-request-monitor + * + * Copyright (C) 2005 Gustaf Neumann, neumann@wu-wien.ac.at + * + * Vienna University of Economics and Business Administration + * Institute of Information Systems and New Media + * A-1090, Augasse 2-6 + * Vienna, Austria + * + * This is a BSD-Style license applicable for the files in this + * directory and below, except when stated explicitly different. + * + * For the copyright of the diagramm javascript library see: + * http://www.lutanho.net/diagram/ + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation. We make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + + 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.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 30 Dec 2005 00:07:23 -0000 1.2 @@ -8,10 +8,10 @@ t request-monitor - + Gustaf Neumann Request Monitor with user tracking functionality - 2005-12-11 + 2005-12-29 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, @@ -25,7 +25,7 @@ ns_returnfile_background is included 0 - + Index: openacs-4/packages/xotcl-request-monitor/tcl/background-delivery-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/tcl/Attic/background-delivery-procs.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/tcl/background-delivery-procs.tcl 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/tcl/background-delivery-procs.tcl 30 Dec 2005 00:07:23 -0000 1.2 @@ -39,21 +39,35 @@ @return number of currently running background deliveries } %self do array size running +if {[ns_info name] eq "NaviServer"} { + bgdelivery forward write_headers ns_headers +} else { + bgdelivery forward write_headers ns_headers DUMMY +} -ad_proc -public ad_returnfile_background {statuscode mime_type filename} { +bgdelivery ad_proc returnfile {statuscode mime_type filename} { Deliver the given file to the requestor in the background. This proc uses the background delivery thread to send the file in an event-driven manner without blocking a request thread. This is especially important when large files are requested over slow (e.g. dial-ip) connections. } { #ns_log notice "statuscode = $statuscode, filename=$filename" set size [file size $filename] - if {[ns_headers xxx $statuscode $mime_type $size]} { + if {[my write_headers $statuscode $mime_type $size]} { set ch [ns_conn channel] - thread::transfer [bgdelivery get_tid] $ch + thread::transfer [my get_tid] $ch throttle get_context - bgdelivery do -async deliver $ch $filename \ + my do -async deliver $ch $filename \ [list [throttle set requestor],[throttle set url] [ns_conn start]] - ns_conn contentsentlength $size; #maybe overly optimistic + ns_conn contentsentlength $size ;# maybe overly optimistic } } + +ad_proc -public ad_returnfile_background {statuscode mime_type filename} { + Deliver the given file to the requestor in the background. This proc uses the + background delivery thread to send the file in an event-driven manner without + blocking a request thread. This is especially important when large files are + requested over slow (e.g. dial-ip) connections. +} { + bgdelivery returnfile $statuscode $mime_type $filename +} 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.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 30 Dec 2005 00:07:23 -0000 1.2 @@ -19,7 +19,7 @@ } Throttle instproc add_statistics { type requestor ip_adress url query } { - set furl [expr {$query != "" ? "$url?$query" : $url}] + set furl [expr {$query ne "" ? "$url?$query" : $url}] my incr ${type}s #my log "++++ add_statistics -type $type -user_id $requestor " set entry [ThrottleStat new -childof [self]::stats \ @@ -73,7 +73,7 @@ # issued; if yes, block this request. Caveat: some html-pages # use the same image in many places, so we can't block it. This # will make the sttistics for images look better than they are. - set is_image_request [string match image/* $content_type] + set is_image_request [string match "image/*" $content_type] if {[my exists $var] && !$is_image_request && !$off} { my log "### already $var" return [list 0 0 1] @@ -822,6 +822,7 @@ my users community_access [my set requestor] $community_id } } +throttle proc {} args {my eval $args} ad_proc string_truncate_middle {{-ellipsis ...} {-len 100} string} { cut middle part of a string in case it is to long 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.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/www/index.tcl 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/www/index.tcl 30 Dec 2005 00:07:23 -0000 1.2 @@ -41,7 +41,7 @@ proc currentResponseTime {} { set tm [throttle trend response_time_minutes] set hours [throttle trend response_time_hours] - if { $tm == "" } { + if { $tm eq "" } { set ::server_running "seconds" return "NO DATA" } @@ -79,7 +79,7 @@ proc currentViews {} { set vm [throttle trend minutes] set um [throttle trend user_count_minutes] - if { $vm == "" } { return "NO DATA" } + if { $vm eq "" } { return "NO DATA" } set views_per_sec [expr {[lindex $vm end]/60.0}] ns_log notice "um='$um' vm='$vm' expr {60.0*$views_per_sec/[lindex $um end]}" set views_per_min_per_user [expr {60.0*$views_per_sec/[lindex $um end]}] @@ -239,7 +239,7 @@ append running /[bgdelivery nr_running] } -if {[string compare "" [info command ::tlf::system_activity]]} { +if {[info command ::tlf::system_activity] ne ""} { array set server_stats [::tlf::system_activity] set current_exercise_activity $server_stats(activity) set current_system_activity "$server_stats(activity) exercises last 15 mins, " Index: openacs-4/packages/xotcl-request-monitor/www/index.tcl-gn =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/Attic/index.tcl-gn,v diff -u -N --- openacs-4/packages/xotcl-request-monitor/www/index.tcl-gn 14 Dec 2005 16:09:02 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,187 +0,0 @@ -ad_page_contract { - present usage statistics, active users, etc - - @author Gustaf Neumann - @cvs-id $Id: index.tcl-gn,v 1.1 2005/12/14 16:09:02 maltes Exp $ -} -properties { - title:onevalue - context:onevalue - active_user_label - active_users_10 - current_system_activity - current_load - current_response - views_trend - users_trend - response_trend - throttle_stats -} - -set title "Performance statistics" - -# draw a graph in form of an html table of with 500 pixels -proc graph values { - set max 1 - foreach v $values {if {$v>$max} {set max $v}} - set graph "\n" - foreach v $values { - ns_log notice "540*$v/$max" - set bar "
" - append graph "
\n" - } - append graph "
$bar
\n" - return $graph -} - -# compute the average of the last n values (or less, if -# not enough values are given) -proc avg_last_n {list n var} { - upvar $var cnt - set total 0.0 - set list [lrange $list end-[incr n -1] end] - foreach d $list { set total [expr {$total+$d}] } - set cnt [llength $list] - return [expr {$cnt > 0 ? $total*0.001/$cnt : 0}] -} - - -# collect current system statistics -proc currentSystemLoad {} { - return [lindex [split [exec "/usr/bin/w"] \n] 0] -} - -# collect current response time (per minute and hour) -proc currentResponseTime {} { - set tm [throttle trend response_time_minutes] - set hours [throttle trend response_time_hours] - ns_log notice "trend = <$tm>" - if { $tm == "" } { - set ::server_running "seconds" - return "NO DATA" - } - set avg_half_hour [avg_last_n $tm 30 cnt] - if {$cnt > 0} { - set minstat "[format %4.2f $avg_half_hour] (last $cnt minutes), " - } else { - set minstat "" - } - if {[llength $tm]>0} { - set lminstat "[format %4.2f [expr {[lindex $tm end]/1000.0}]] (last minute), " - } else { - set lminstat "" - } - if {[llength $hours]>0} { - set avg_last_day [avg_last_n $hours 24 cnt] - set hourstat "[format %4.2f [expr {[lindex $hours end]/1000.0}]] (last hour), " - append hourstat "[format %4.2f $avg_last_day] (last $cnt hours)" - set server_running "$cnt hours" - } else { - if {[llength $tm]>0} { - set dummy [avg_last_n $tm 60 cnt] - set server_running "$cnt minutes" - } else { - set server_running "1 minute" - } - set hourstat "" - } - set ::server_running $server_running - return [list $lminstat $minstat $hourstat] -} - -# collect figures for views per second (when statistics are applied -# only on views) -proc currentViews {} { - set vm [throttle trend minutes] - set um [throttle trend user_count_minutes] - if { $vm == "" } { return "NO DATA" } - set views_per_sec [expr {[lindex $vm end]/60.0}] - set views_per_min_per_user [expr {60.0*$views_per_sec/[lindex $um end]}] - set view_time [expr {$views_per_min_per_user>0 ? - " avg. view time: [format %4.1f [expr {60.0/$views_per_min_per_user}]]" : ""}] - return "[format %4.1f $views_per_sec] views/sec, [format %4.2f $views_per_min_per_user] views/min/user, $view_time" -} - - -# build an HTML table from statistics of monitor thread - -proc counterTable {label objlist} { - append text "" \ - "" - foreach {t l} $objlist { - set trend [throttle trend $t] - append text \ - "" \ - "" \ - "" - } - append text "
TrendMax
$label per
$l
[graph $trend]$trend" \ - "\n" - set c 1 - foreach v [throttle max_values $t] { - incr c - switch $t { - minutes {set rps "([format %5.2f [expr {[lindex $v 1]/60.0}]] rps)"} - hours {set rps "([format %5.2f [expr {[lindex $v 1]/(60*60.0)}]] rps)"} - default {set rps ""} - } - set bg [expr {$c%2==0?"white":"#EAF2FF"}] - append text " - " - } - append text "
[lindex $v 0][lindex $v 1] $rps

" -} - -# set variables for template -set views_trend [counterTable Views [list seconds Second minutes Minute hours Hour]] -set users_trend [counterTable Users [list user_count_minutes Minute user_count_hours Hour]] -set response_trend [counterTable "Avg. Response
Time" \ - [list response_time_minutes Minute response_time_hours Hour]] -set current_response [join [currentResponseTime] " "] -set current_load [currentSystemLoad] -set running [throttle nr_running] - -if {[string compare "" [info command ::tlf::system_activity]]} { - array set server_stats [::tlf::system_activity] - set current_exercise_activity $server_stats(activity) - set current_system_activity "$server_stats(activity) exercises last 15 mins, " -} else { - set current_system_activity "" -} -append current_system_activity \n[currentViews] - -set active_users_10 [throttle users total] -set throttle_stats [throttle statistics] -set active24 [throttle users perDay] -set activeUsers24 [lindex $active24 1] -set activeIP24 [lindex $active24 0] -set activeTotal24 [expr {$activeUsers24 + $activeIP24}] -set active_user_string "$active_users_10 active users in last 10 minutes, $activeUsers24 in last $::server_running ($activeTotal24 total)" -set current_url [ns_conn url] -regexp {^(.*/)[^/]*$} $current_url match current_path -set active_user_label "Active Users:" - -# use template in OACS or HTML table with plain AS -if {[string compare "" [info command ad_return_template]]} { - ad_return_template -} else { - ns_return 200 text/html [subst -nobackslash { - System Statistics - - - - - - -
$active_user_label$active_users_10
Current System Activity:$current_system_activity
Current System Load:$current_load
Current Avg Response Time/sec:$current_response
Details
-
-

Page View Statistics

-
$views_trend

-

Active Users

-
$users_trend

-

Avg. Response Time in milliseconds

-
$response_trend
- $throttle_stats - - }] -} Index: openacs-4/packages/xotcl-request-monitor/www/last100.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/last100.tcl,v diff -u -N -r1.1 -r1.2 --- openacs-4/packages/xotcl-request-monitor/www/last100.tcl 14 Dec 2005 16:09:02 -0000 1.1 +++ openacs-4/packages/xotcl-request-monitor/www/last100.tcl 30 Dec 2005 00:07:23 -0000 1.2 @@ -49,4 +49,5 @@ -ms $ms \ -url $url } -set t1 [t1 asHTML] \ No newline at end of file +set t1 [t1 asHTML] +