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 -r1.13 -r1.14 --- openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 4 Aug 2018 18:55:48 -0000 1.13 +++ openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 3 Nov 2018 10:40:10 -0000 1.14 @@ -8,7 +8,7 @@ t request-monitor - + Gustaf Neumann WU Vienna Request Monitor with user tracking functionality @@ -34,7 +34,7 @@ BSD-Style 2 - + 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 -r1.60 -r1.61 --- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 19 Sep 2018 01:02:10 -0000 1.60 +++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 3 Nov 2018 10:40:10 -0000 1.61 @@ -513,20 +513,26 @@ next } - Class create MaxCounter -superclass Counter -instproc end {} { - set :c [Users nr_active] - if {[info exists :report]} { - if {[${:report} set c] < ${:c}} { - ${:report} set c ${:c} + Class create MaxCounter -superclass Counter \ + -parameter {{metric nr_active}} \ + -instproc end {} { + set :c [Users ${:metric}] + if {[info exists :report]} { + if {[${:report} set c] < ${:c}} { + ${:report} set c ${:c} + } + } + :finalize ${:c} + set :c 0 } - } - :finalize ${:c} - set :c 0 - } MaxCounter create user_count_hours -timeoutMs [expr {60000*60}] -logging 1 MaxCounter create user_count_minutes -timeoutMs 60000 -report user_count_hours -logging 1 + MaxCounter create authenticated_count_hours -metric nr_authenticated -timeoutMs [expr {60000*60}] -logging 1 + MaxCounter create authenticated_count_minutes -metric nr_authenticated -timeoutMs 60000 \ + -report authenticated_count_hours -logging 1 + Class create AvgCounter -superclass Counter \ -parameter {{t 0} {atleast 1}} -instproc end {} { if {${:c} > 0} { @@ -701,6 +707,11 @@ } { return [array size :pa] } + Users ad_proc nr_authenticated {} { + @return number of authenticated users (in time window) + } { + return [lindex [:nr_users_time_window] 1] + } Users ad_proc nr_users_time_window {} { @return number of different ip addresses and authenticated users (in time window) 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 -r1.28 -r1.29 --- openacs-4/packages/xotcl-request-monitor/www/index.tcl 13 Oct 2018 15:52:28 -0000 1.28 +++ openacs-4/packages/xotcl-request-monitor/www/index.tcl 3 Nov 2018 10:40:10 -0000 1.29 @@ -35,7 +35,7 @@ # collect current system statistics proc currentSystemLoad {} { # if {[catch {return [exec "/usr/bin/uptime"]}]} { - # return "" + # return "" # } set procloadavg /proc/loadavg if {[file readable $procloadavg]} { @@ -46,21 +46,21 @@ return $result } if {[set uptime [util::which uptime]] ne ""} { - return [exec $uptime] + return [exec $uptime] } else { set msg "'uptime' command not found on the system" ad_log error $msg return "" - } + } } # collect current response time (per minute and hour) proc currentResponseTime {} { set tm [throttle trend response_time_minutes] set hours [throttle trend response_time_hours] - if { $tm eq "" } { + if { $tm eq "" } { set ::server_running "seconds" - return "NO DATA" + return "NO DATA" } set avg_half_hour [avg_last_n $tm 30 cnt] if {$cnt > 0} { @@ -96,7 +96,9 @@ proc currentViews {} { set vm [throttle trend minutes] set um [throttle trend user_count_minutes] - if { $vm eq "" || $um eq ""} { return "NO DATA" } + if { $vm eq "" || $um eq ""} { + return "NO DATA" + } set views_per_sec [expr {[lindex $vm end]/60.0}] set currentUsers [lindex $um end] if {$currentUsers > 0} { @@ -105,8 +107,8 @@ } else { set views_per_min_per_user "0" } - set view_time [expr {$views_per_min_per_user>0 ? - " avg. view time: [format %4.1f [expr {60.0/$views_per_min_per_user}]]" : ""}] + 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.3f $views_per_min_per_user] views/min/user, $view_time" } @@ -117,19 +119,21 @@ template::add_body_script -src "//code.jquery.com/jquery-1.12.3.min.js" template::add_body_script -src "//code.highcharts.com/highcharts.js" template::add_body_script -src "//code.highcharts.com/modules/exporting.js" - + proc js_time {clock} { set year [clock format $clock -format %Y] set month [expr {[string trimleft [clock format $clock -format %N]] - 1}] return "Date.UTC($year, $month, [clock format $clock -format {%d, %H, %M, %S}], 0)" } set ::graphCount 0 - proc graph {values label type} { + proc graph {valuesList labelList type} { + set values [lindex $valuesList 0] + set label [lindex $labelList 0] #ns_log notice "values=$values label=$label, type=$type" set size [llength $values] - if {$size<12} { + if {$size < 12} { set values [concat [split [string repeat 0 [expr {12-$size}]] ""] $values] set size [llength $values] } @@ -174,6 +178,58 @@ } }}] + # + # Check for a secondary series + # + if {[llength $valuesList] > 1} { + set data {} + set label [lindex $labelList 1] + set i 0 + + # + # Transitional code: perform padding with leading zeros, in case + # we have less values in the secondary series. + # + set values [lindex $valuesList 1] + set secondarySize [llength $values] + if {$secondarySize < $size} { + set values [list {*}[lrepeat [expr {$size-$secondarySize}] 0] {*}$values] + } + + foreach t $values { + set js_time [js_time [expr {$begin + $i * $interval}]] + lappend data [subst {{ x: $js_time, y: $t }}] + incr i + } + append series "," \ + [subst {{ + showInLegend: false, + type: 'areaspline', + threshold : null, + marker: { + enabled: true, + radius: 3 + }, + tooltip : { + valueDecimals : 2 + }, + name: '$label', + colorIndex: 4, + data: \[ [join $data ,] \], + fillColor : { + linearGradient : { + x1: 0, + y1: 0, + x2: 0, + y2: 1 + }, + stops : \[ + \[0, Highcharts.getOptions().colors\[0\]\], + \[1, Highcharts.Color(Highcharts.getOptions().colors\[4\]).setOpacity(0).get('rgba')\] + \] + }}}] + } + template::add_body_script -script [subst { \$('#$graphID').highcharts({ chart: { @@ -184,7 +240,7 @@ }, xAxis: { type: 'datetime', - title: { text: 'Date'}, + title: { text: 'Date'}, }, yAxis: \[{ min: 0, @@ -193,7 +249,7 @@ align: 'high', offset: 60 }, - labels: { overflow: 'justify'} + labels: { overflow: 'justify'} }\], plotOptions: { bar: { @@ -214,30 +270,39 @@
}] } - - proc counterTable {label objlist} { - foreach {t l} $objlist { - set trend [throttle trend $t] + # set users_trend [counterTable Users [list user_count_minutes Minute user_count_hours Hour]] + + proc counterTable {labels objlist} { + foreach {trends l} $objlist { + set values {} + foreach t $trends { + lappend values [throttle trend $t] + } + set labelList {} + foreach label $labels { + lappend labelList "$label per $l" + } append text [subst { - [graph $trend "$label per $l" $l] - - + + \n" } @@ -246,9 +311,11 @@ } } else { - # no JavaScript graphics, use poor men's approach... - - # draw a graph in form of an html table of with 500 pixels + # + # No JavaScript graphics, use poor men's approach... + # + # 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}} @@ -261,28 +328,32 @@ return $graph } - # build an HTML table from statistics of monitor thread - proc counterTable {label objlist} { + # + # Build an HTML table from statistics of monitor thread. + # If there are multiple data rows given, just take the first one. + # + proc counterTable {labels objlist} { + set label [lindex $labels 0] append text "
Max
[graph $values $labelList $l] + }] + set t [lindex $trends 0] 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 cl [expr {$c%2==0?"list-even":"list-odd"}] - append text [subst { - - - }] + 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 cl [expr {$c%2==0?"list-even":"list-odd"}] + append text [subst { + + + }] } append text "
Max
[lindex $v 0][lindex $v 1] $rps
[lindex $v 0][lindex $v 1] $rps
\n
" \ - "" + "" foreach {t l} $objlist { - set trend [throttle trend $t] + set trend [throttle trend [lindex $t 0]] append text [subst { - - -
TrendMax
TrendMax
$label per
$l
[graph $trend]$trend - + + + " @@ -292,10 +363,14 @@ } # 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 views_trend [counterTable Views {seconds Second minutes Minute hours Hour}] +set users_trend [counterTable {Users Authenticated} { + {user_count_minutes authenticated_count_minutes} Minute + {user_count_hours authenticated_count_hours} Hour +}] +set response_trend [counterTable "Avg. Response
Time" { + response_time_minutes Minute response_time_hours Hour +}] set current_response [join [currentResponseTime] " "] set current_load [currentSystemLoad]
$label per
$l
[graph $trend]$trend + }] 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 " + foreach v [throttle max_values [lindex $t 0]] { + 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 0] [lindex $v 1] $rps