Class ::nsbeat::Beat (public)
::nx::Class ::nsbeat::Beat
Defined in packages/xowiki/tcl/nsbeat-procs.tcl
- Testcases:
- No testcase defined.
Source code: :property {outputLocation http://localhost:9200/} :method ms_to_utc {ms} { set seconds [expr {$ms / 1000}] set fraction [format %03d [expr {$ms - ($seconds * 1000)}]] return [clock format $seconds -format "%Y-%m-%dT%H:%M:%S" -gmt 1].${fraction}Z } :method nspost {data} { set queryHeaders [ns_set create] ns_set update $queryHeaders Host localhost ns_set update $queryHeaders Content-Type "application/json; charset=UTF-8" set d [ns_http run -headers $queryHeaders -method POST -body $data -timeout 10.0 ${:outputLocation}/_bulk] ns_http wait -result R -headers $replyHeaders -status S $h ns_log notice "nsbeat post returned S [dict get $d status] R [dict get $d body]" } :public method data {} { set index nsbeat-[clock format [clock seconds] -format "%Y.%m.%d"] set data "" foreach serverName [ns_info servers] { foreach poolName [lsort [ns_server -server $serverName pools]] { # # provide a nicer name for the pool # set startClicks [clock clicks -microseconds] set poolLabel "default" if {$poolName ne {}} {set poolLabel $poolName} set rtt [expr {[clock clicks -microseconds] - $startClicks}] set stats [ns_server -server $serverName -pool $poolName stats] set header [subst {{"index":{"_index":"$index","_type":"doc"}}}] regsub -all \n [subst $::nsbeat::template(serverStats)] "" payload regsub -all {\s\s+} $payload " " payload append data $header\n$payload\n } } foreach {dbPool stats} [ns_db stats] { set header [subst {{"index":{"_index":"$index","_type":"doc"}}}] regsub -all \n [subst $::nsbeat::template(dbStats)] "" payload regsub -all {\s\s+} $payload " " payload append data $header\n$payload\n } return $data } :public method beat {} { set data [:data] ns_log notice "nsbeat DATA:\n$data" :nspost $data }XQL Not present: Generic, PostgreSQL, Oracle