%3 ::nx::Object ::nx::Object ::nsbeat::Beat ::nsbeat::Beat beat data ms_to_utc nspost ::nsbeat::Beat->::nx::Object

Class ::nsbeat::Beat

::nsbeat::Beat[i] create ... \
           [ -outputLocation (default "http://localhost:9200/") ]

Defined in packages/xowiki/tcl/nsbeat-procs.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nx::Object[i]
::nx::Class create ::nsbeat::Beat \
     -superclass ::nx::Object

Methods (to be applied on instances)

  • beat (scripted, public)

     <instance of nsbeat::Beat[i]> beat

    Testcases:
    No testcase defined.
    set data [:data]
    ns_log notice "nsbeat DATA:\n$data"
    :nspost $data
  • data (scripted, public)

     <instance of nsbeat::Beat[i]> data

    Testcases:
    No testcase defined.
    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