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 "
$bar |
\n"
- }
- append graph "
\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 "" \
- " | Trend | Max |
"
- foreach {t l} $objlist {
- set trend [throttle trend $t]
- append text \
- "$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 "[lindex $v 0] |
- [lindex $v 1] $rps | "
- }
- append text " |
"
- }
- append text "
"
-}
-
-# 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
-
- }]
-}