• Publicity: Public Only All

rrd-plugin-procs.tcl

RRD-plugin-procs - defined plugins

Location:
packages/rrd-tool/tcl/rrd-plugin-procs.tcl
Created:
2015-11-01
Author:
Gustaf Neumann
CVS Identification:
$Id: xowiki-procs.tcl,v 1.485.2.15 2015/10/22 08:28:42 gustafn Exp $

Procedures in this file

Detailed information

[ hide source ]

Content File Source

::xo::library doc {
  RRD-plugin-procs - defined plugins

  @creation-date 2015-11-01
  @author Gustaf Neumann
  @cvs-id $Id: xowiki-procs.tcl,v 1.485.2.15 2015/10/22 08:28:42 gustafn Exp $
}

::xo::library require rrd-procs

####################################################################
#
# Plugin instance for DB statistics with 12 data sources
#
####################################################################
::rrd::Plugin create ::rrd::plugin::dbstats \
    -rrdRoot ${::acs::rootdir}/www/rrd/localhost.localdomain \
    -vars {
      pool1-statements pool1-gethandles pool1-sqltime pool1-waittime
      pool2-statements pool2-gethandles pool2-sqltime pool2-waittime
      pool3-statements pool3-gethandles pool3-sqltime pool3-waittime
    }

::rrd::plugin::dbstats public object method update {} {
  #
  # Get db-statistics from [ns_db stats]
  #
  set pairs [ns_db stats]
  foreach {p values} $pairs {
    foreach {key value} $values {
      set varName $p-$key
      if {$varName ni ${:vars}} continue
      if {![string is integer -strict $value]} {
        # assume floating point number in secs, compute ms
        set value [expr {round ($value*1000)}]
      }
      :updateDataSource $varName $value
    }
  }
}

####################################################################
#
# Plugin instance for memsize with two datasources
#
####################################################################
::rrd::Plugin create ::rrd::plugin::memsize \
    -rrdRoot ${::acs::rootdir}/www/rrd/localhost.localdomain \
    -vars { rss vsize } \
    -type GAUGE \
    -durations {
      "1 min"     "1 day"
      "10 min"    "8 days"
      "2 hours"  "45 days"
      "1 day"    "2 years"
    }
::rrd::plugin::memsize public object method update {} {
  set sizes [exec -ignorestderr /bin/ps -o vsize,rss [pid]]
  :updateDataSource vsize [expr {[lindex $sizes end-1]*1024}]
  :updateDataSource rss   [expr {[lindex $sizes end]*1024}]
}

####################################################################
#
# Plugin instance for response time with one datasource
#
####################################################################
::rrd::Plugin create ::rrd::plugin::responsetime \
    -rrdRoot ${::acs::rootdir}/www/rrd/localhost.localdomain \
    -vars { responsetime } \
    -type GAUGE \
    -durations {
      "1 min"     "1 day"
      "10 min"    "8 days"
      "2 hours"  "45 days"
      "1 day"    "2 years"
    }
::rrd::plugin::responsetime public object method update {} {
  set tm [throttle trend response_time_minutes]
  :updateDataSource responsetime [expr {[lindex $tm end]/1000.0}]
}

####################################################################
#
# Plugin instance for active users with one datasource
#
####################################################################
::rrd::Plugin create ::rrd::plugin::users \
    -rrdRoot ${::acs::rootdir}/www/rrd/localhost.localdomain \
    -vars { anonymous authenticated } \
    -type GAUGE \
    -durations {
      "1 min"     "1 day"
      "10 min"    "8 days"
      "2 hours"  "45 days"
      "1 day"    "2 years"
    }
::rrd::plugin::users public object method update {} {
  set tm [throttle trend user_count_minutes]
  lassign [throttle users nr_users_time_window] ip auth
  :updateDataSource authenticated $auth
  :updateDataSource anonymous $ip
}


::xo::library source_dependent

# Local variables:
#    mode: tcl
#    tcl-indent-level: 2
#    indent-tabs-mode: nil
# End: