The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
# Tomcat specific checks
# ========================================================

include common.cfg

# Requests per minute for a servlet
# $0: Web-Module name
# $1: Servlet name
# $2: Critical (default: 1000)
# $3: Warning (default: 900)
<Check tc_servlet_requests>
  MBean = *:j2eeType=Servlet,WebModule=$0,name=$1,*
  Use = count_per_minute("requests")
  Attribute = requestCount
  Name = request
  Critical = ${2:6000}
  Warning = ${3:5000}  
</Check>

# Check whether an webmodule (can contain multiple servlets)
# is running
# $0: Webmodule name (sth like "//localhost/j4p")
<Check tc_webmodule_running>
  MBean = *:j2eeType=WebModule,name=$0,*
  Attribute = state
  String = 1
  Label = $0 running
  Name = running
  Critical = !1
</Check>

# Increase of overall processing time per minute for a web module
# This is calculate the processing time for a certain
# interval and extrapolate to a minute
# $0: Webmodule name
# $1: Critical (default: 50000)
# $2: Warning (default: 40000)
<Check tc_webmodule_processing>
  MBean = *:j2eeType=WebModule,name=$0,*
  Attribute = processingTime
  Delta = 60
  Label = %2.0f ms request processing time / minute
  Name = proc_time
  Critical = ${1:50000}
  Warning = ${2:40000}
</Check>

# ========================================================
# Session related checks

# Number of active sessions at this moment
# $0: Path name without leading slash
# $1: Critical (Default: 1000)
# $2: Warning (Default: 800)
<Check tc_session_active>
  MBean = *:path=/$0,type=Manager,*
  Attribute = activeSessions
  Name = sessions_active
  Label = $0: Active Sessions = %v
  Critical = ${1:1000}
  Warning = ${2:800}
</Check>

# Maximum number of active sessions so far
# $0: Path name without leading slash
# $1: Critical (default: 1000)
# $2: Warning (default: 800)
<Check tc_session_active_max>
  MBean = *:path=/$0,type=Manager,*
  Attribute = maxActive
  Name = sessions_max
  Label = $0: Max-Active Sessions = %v
  Critical = ${1:1000}
  Warning = ${2:800}
</Check>

# Number of sessions we rejected due to maxActive beeing reached
# $0: Path name without leading slash
# $1: Critical (default: 500)
# $2: Warning (default: 200)
<Check tc_session_rejected>
  MBean = *:path=/$0,type=Manager,*
  Attribute = rejectedSessions
  Name = sessions_rejected
  Label = $0: Rejected Sessions = %v
  Critical = ${1:500}
  Warning = ${2:200}
</Check>

# Average time an expired session had been alive
# in seconds
# $0: Path name without leading slash
# $1: Critical (7200)
# $2: Warning (7200)
<Check tc_session_average_lifetime>
  MBean = *:path=/$0,type=Manager,*
  Attribute = sessionAverageAliveTime
  Name = sessions_avg_life
  Label = $0: Average session lifetime = %v
  Critical = ${1:7200}
  Warning = ${2:6400}
</Check>

# Longest time an expired session had been alive
# in seconds
# $0: Path name without leading slash
# $1: Critical (7200)
# $2: Warning (6400)
<Check tc_session_max_lifetime>
  MBean = *:path=/$0,type=Manager,*
  Attribute = sessionMaxAliveTime
  Name = sessions_max_life
  Label = $0: Maximum session lifetime = %v
  Critical = ${1:7200}
  Warning = ${2:6400}
</Check>

# Increase rate of sessions per minute
# $0: Path name without leading slash
# $1: Critical (default: 1000)
# $2: Warning (default: 900)
<Check tc_session_inc>
  Use = count_per_minute("sessions")
  MBean = *:path=/$0,type=Manager,*
  Attribute = sessionCounter
  Name = sessions_inc
  Critical = ${1:1000}
  Warning = ${2:900}
</Check>

# =============================================================
# Connector related checks

# Number of connector threads in relation to maximum 
# allowed connector threads
# $0: Name of connector (e.g. 'http-8080')
# $1: Critical (default: 90%)
# $2: Warning (default: 80%)
<Check tc_connector_threads>
  Use = relative_base($1,$2)
  Label = Connector $0 : $BASE
  Name = connector_threads
  Value = *:type=ThreadPool,name=$0/currentThreadCount
  Base = *:type=ThreadPool,name=$0/maxThreads
</Check>


# Number of bytes received per minute for a connector
# $0: Name of connector (e.g. 'http-8080')
# $1: Critical (default: 100 MB)
# $2: Warning (default: 80 MB)
<Check tc_connector_received_rate>
  Use = count_per_minute("bytes received")
  Label = Connector $0 : $BASE
  Name = bytes_received
  Value = *:type=GlobalRequestProcessor,name=$0/bytesReceived
  Critical = ${1:104857600}
  Warning = ${2:83886080}
</Check>

# Number of bytes sent per minute for a connector
# $0: Name of connector (e.g. 'http-8080')
# $1: Critical (default: 100 MB)
# $2: Warning (default: 80 MB)
<Check tc_connector_sent_rate>
  Use = count_per_minute("bytes sent")
  Label = Connector $0 : $BASE
  Name = bytes_sent
  Value = *:type=GlobalRequestProcessor,name=$0/bytesSent
  Critical = ${1:104857600}
  Warning = ${2:83886080}
</Check>

# Increase of overall processing time per minute for a connector
# This checks calculates the processing time for a certain
# interval and scale it to a minute
# $0: Connector name
# $1: Critical (default: 50000)
# $2: Warning (default: 40000)
<Check tc_connector_processing_time>
  Delta = 60
  Label = Connector $0 : %2.0f ms request processing time / minute
  Name = proc_time
  Value = *:type=GlobalRequestProcessor,name=$0/processingTime
  Critical = ${1:50000}
  Warning = ${2:40000}
</Check>

# Requests per minute for a connector
# $0: Connector name
# $1: Critical (default: 1000)
# $2: Warning (default: 900)
<Check tc_connector_requests>
  Use = count_per_minute("requests")
  Label = Connector $0 : $BASE
  Name = nr_requests
  Value = *:type=GlobalRequestProcessor,name=$0/requestCount
  Critical = ${1:1000}
  Warning = ${2:900}  
</Check>

# Number of errors for a connector per minute. 
# $0: Connector name
# $1: Critical (default: 100)
# $2: Warning (default: 90)
<Check tc_connector_error_count>
  Value = *:type=GlobalRequestProcessor,name=$0/errorCount
  Label = Connector $0:  %d errors
  Name = errors
  Critical = ${1:100}
  Warning = ${2:90}  
  Delta = 60
</Check>

# ==================================================================
# Relative DB Pool check (active connection vs. maximal available connections)
# Note that you need to register the datasource globally in order 
# to access the Pool statistics (i.e. within the <GlobalResources> sections)
# See http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
# for more information
# $0: JNDI-Name of datasource (e.g. jdbc/TestDB)
# $1: Critical value (default: 90%)
# $2: Warning value (default: 80%)
<Check tc_datasource_connections>
  Value = *:name="$0",type=DataSource,*/numActive
  Base = *:name="$0",type=DataSource,*/maxActive
  Name  = dbpool_used
  Label = %.2r% DB connections used (%v %u active / %b %w max)
  Critical = ${1:90}
  Warning = ${2:80}
</Check>