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.12 -r1.13
--- openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 23 Mar 2018 22:56:43 -0000 1.12
+++ openacs-4/packages/xotcl-request-monitor/xotcl-request-monitor.info 4 Aug 2018 18:55:48 -0000 1.13
@@ -8,7 +8,7 @@
t
request-monitor
-
+
Gustaf Neumann
WU Vienna
Request Monitor with user tracking functionality
@@ -34,7 +34,7 @@
BSD-Style
2
-
+
@@ -45,7 +45,7 @@
-
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.8 -r1.9
--- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl 7 Aug 2017 23:48:30 -0000 1.8
+++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-init.tcl 4 Aug 2018 18:55:48 -0000 1.9
@@ -15,15 +15,34 @@
ad_register_filter -priority 1000 postauth POST * throttle
}
-# check if we are running under oacs; if not, provide
-# minimal compatibility code
+#
+# Check if we are running under OpenACS; if not, provide
+# minimal compatibility code.
+#
if {[info commands ad_conn] eq ""} {
- # otherwise provide alias for ad_conn and dummy for ad_get_user_id
+ #
+ # Otherwise provide alias for "ad_conn"
+ #
interp alias {} ad_conn {} ns_conn
- ### this is probably not sufficient to do something useful...
}
+#
+# When activity tracking is on, and we have a recent version of
+# NaviServer, then "::xo::job_dequeue" is defined. We define a
+# scheduled proc that runs every 61 seconds the executes the collected
+# cmd in the background. This version produces substantially less locks
+# on busy servers and reduces latency for the client.
+#
+set do_track_activity [parameter::get_from_package_key \
+ -package_key "xotcl-request-monitor" \
+ -parameter do_track_activity \
+ -default false]
+if {$do_track_activity && [info commands ::xo::job_dequeue] ne ""} {
+ nsv_set request_monitor jobs {}
+ ad_schedule_proc -thread t 61 ::xo::job_dequeue
+}
+
# Local variables:
# mode: tcl
# tcl-indent-level: 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 -N -r1.58 -r1.59
--- openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 26 Jul 2018 17:11:15 -0000 1.58
+++ openacs-4/packages/xotcl-request-monitor/tcl/throttle_mod-procs.tcl 4 Aug 2018 18:55:48 -0000 1.59
@@ -845,13 +845,7 @@
set :user_in_community($key) $data
#ns_log notice "=== user $key left community $community_id at $now reason $reason after $seconds seconds clicks $clicks"
if {[do_track_activity] && $seconds > 0} {
- #set t0 [clock milliseconds]
- ns_job queue -detached async-cmd \
- [list ::xo::request_monitor_record_community_activity $key $pa $community_id $seconds $clicks $reason]
- #set t1 [clock milliseconds]
- #if {$t1 - $t0 > 500} {
- # ns_log warning "request_monitor_record_community_activity left_community slow, can lead to filter time >1sec: total time [expr {$t1 - $t0}]"
- #}
+ xo::job_enqueue [list ::xo::request_monitor_record_community_activity $key $pa $community_id $seconds $clicks $reason]
}
}
@@ -871,13 +865,7 @@
}
ns_log notice "=== user $key left system at $now reason $reason after $seconds seconds clicks $clicks"
if {[do_track_activity] && $seconds > 0} {
- #set t0 [clock milliseconds]
- ns_job queue -detached async-cmd \
- [list ::xo::request_monitor_record_activity $key $pa $seconds $clicks $reason]
- #set t1 [clock milliseconds]
- #if {$t1 - $t0 > 500} {
- # ns_log warning "::xo::request_monitor_record_activity left_system slow, can lead to filter time >1sec: total time [expr {$t1 - $t0}]"
- #}
+ xo::job_enqueue [list ::xo::request_monitor_record_activity $key $pa $seconds $clicks $reason]
}
unset -nocomplain :user_in_community($key) :refcount($key) :pa($key) :expSmooth($key) :switches($key)
}
@@ -1051,7 +1039,7 @@
}
#
- # The array "urls" keeps triples of time stamps, urls and peer
+ # The array "urls" keeps triples of time stamps, URLs and peer
# addresses per user.
#
lappend :urls($key) [list ${:point_in_time} $url $pa]
@@ -1635,10 +1623,46 @@
}
namespace eval ::xo {
+
proc is_ip {key} {
expr { [string match "*.*" $key] || [string match "*:*" $key] }
}
+ #
+ # Check, if we have a NaviServer with the atomic ns_set operation
+ # with the "-reset" option
+ #
+ # "nsv_set ?-default? ?-reset? ?--? array key ?value?"
+ #
+ # available. If so, implement an async job-queue with ltttle
+ # overhead based on it.
+ #
+ catch {nsv_set} errMsg
+ if {[string match *-reset* $errMsg]} {
+ #
+ # Yes, we have the "-reset" option.
+ #
+ proc job_enqueue {cmd} {
+ nsv_lappend request_monitor jobs $cmd
+ }
+
+ proc job_dequeue {} {
+ foreach cmd [nsv_set -reset request_monitor jobs {}] {
+ {*}$cmd
+ }
+ }
+
+ } else {
+ #
+ # Older version of NaviServer, so the classic approach via "ns_job
+ # queue -detached async-cmd ...."
+ #
+ proc job_enqueue {cmd} {
+ ns_job queue -detached async-cmd $cmd
+ }
+ }
+
+
proc request_monitor_record_activity {key pa seconds clicks reason} {
if {[::xo::is_ip $key]} {
set user_id -1
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.11 -r1.12
--- openacs-4/packages/xotcl-request-monitor/www/last100.tcl 27 Jun 2018 16:24:27 -0000 1.11
+++ openacs-4/packages/xotcl-request-monitor/www/last100.tcl 4 Aug 2018 18:55:48 -0000 1.12
@@ -46,7 +46,7 @@
}
#
- # Provide the urls only to admins as links.
+ # Provide the URLs only to admins as links.
#
# First of all, it is questionable, whether this page should be
# public. However, when this page is public, and a spider
Index: openacs-4/packages/xotcl-request-monitor/www/stat-details.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-request-monitor/www/stat-details.tcl,v
diff -u -N -r1.12 -r1.13
--- openacs-4/packages/xotcl-request-monitor/www/stat-details.tcl 29 Jun 2018 17:27:19 -0000 1.12
+++ openacs-4/packages/xotcl-request-monitor/www/stat-details.tcl 4 Aug 2018 18:55:48 -0000 1.13
@@ -49,7 +49,7 @@
set full_stat [list]
if {$with_param == 0} {
# without parameter
- # add up same urls
+ # add up same URLs
array unset aggr_stat
foreach l $stat {
lassign $l url time cnt