<cluster xmlns="http://caucho.com/ns/resin"
         xmlns:resin="urn:java:com.caucho.resin"
         xmlns:health="urn:java:com.caucho.health"
         xmlns:ee="urn:java:ee">

  <!--
     - Health monitoring system default configuration
    -->
         
  <health:HealthSystem>
    <enabled>true</enabled>
    <startup-delay>15m</startup-delay>
    <period>5m</period>
    <recheck-period>15s</recheck-period>
    <recheck-max>5</recheck-max>
  </health:HealthSystem>
  
  <health:Restart>
    <health:IfHealthFatal/>
  </health:Restart>

  <!--
     - Restart on critical if the problem persists for 5 min.
    -->
  <health:Restart>
    <health:IfCriticalRechecked time="5m"/>
  </health:Restart>

  <!--
     - Checks for JVM-detected deadlocks.
    -->
  
  <health:JvmDeadlockHealthCheck/>

  <!--
     - heap memory checks
    -->
  
  <health:MemoryTenuredHealthCheck>
    <memory-free-min>1m</memory-free-min>
  </health:MemoryTenuredHealthCheck>
  
  <health:MemoryPermGenHealthCheck>
    <memory-free-min>1m</memory-free-min>
  </health:MemoryPermGenHealthCheck>

  <!--
     - Dump heap if memory pools are critically low 
    -->
  
  <health:DumpHeap>
    <health:Or>
      <health:IfHealthCritical healthCheck="${memoryTenuredHealthCheck}"/>
      <health:IfHealthCritical healthCheck="${memoryPermGenHealthCheck}"/>
    </health:Or>
    <health:IfRechecked/>
  </health:DumpHeap>
  
  <!--
     - Dump active threads if cpu usage is critically high
    -->

  <health:CpuHealthCheck>
    <warning-threshold>95</warning-threshold>
    <!--
       - <critical-threshold>99</critical-threshold>
      -->
  </health:CpuHealthCheck>
  
  <health:DumpThreads>
    <health:IfHealthCritical healthCheck="${cpuHealthCheck}"/>
    <health:IfRechecked/>
  </health:DumpThreads>
  
  <!--
     - Check cluster heartbeats
    -->

  <health:HeartbeatHealthCheck/>

  <!--
     - Log connection pool limits reached
    -->

  <health:ConnectionPoolHealthCheck/>
  
  <!--
     - Log transaction manager commit failures 
    -->

  <health:TransactionHealthCheck/>
  
  <!--
     - Restart if any health checks are frozen or threads are hung 
    -->
    
  <health:HealthSystemHealthCheck/>
  
  
  <!-- JMX Meters - for graphing in resin-admin -->
  
  <health:JmxMeter>
    <name>Resin|Uptime|Uptime</name>
    <objectName>resin:type=Server</objectName>
    <attribute>Uptime</attribute>
  </health:JmxMeter>
   
  <health:JmxMeter>
    <name>OS|CPU|Unix Load Avg</name>
    <objectName>resin:type=Server</objectName>
    <attribute>CpuLoadAvg</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>OS|Memory|Physical Memory Free</name>
    <objectName>java.lang:type=OperatingSystem</objectName>
    <attribute>FreePhysicalMemorySize</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>OS|Memory|Swap Free</name>
    <objectName>java.lang:type=OperatingSystem</objectName>
    <attribute>FreeSwapSpaceSize</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>OS|Process|File Descriptor Count</name>
    <objectName>java.lang:type=OperatingSystem</objectName>
    <attribute>OpenFileDescriptorCount</attribute>
  </health:JmxMeter>
   
  <health:JmxMeter>
    <name>JVM|Memory|Heap Memory Used</name>
    <objectName>resin:type=Server</objectName>
    <attribute>RuntimeMemory</attribute>
  </health:JmxMeter>
   
  <health:JmxMeter>
    <name>JVM|Memory|Heap Memory Free</name>
    <objectName>resin:type=Server</objectName>
    <attribute>RuntimeMemoryFree</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>JVM|Memory|PermGen Memory Used</name>
    <objectName>resin:type=Memory</objectName>
    <attribute>PermGenUsed</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>JVM|Memory|PermGen Memory Free</name>
    <objectName>resin:type=Memory</objectName>
    <attribute>PermGenFree</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>JVM|Memory|Tenured Memory Used</name>
    <objectName>resin:type=Memory</objectName>
    <attribute>TenuredUsed</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>JVM|Memory|Tenured Memory Free</name>
    <objectName>resin:type=Memory</objectName>
    <attribute>TenuredFree</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>JVM|Memory|Loaded Classes</name>
    <objectName>java.lang:type=ClassLoading</objectName>
    <attribute>LoadedClassCount</attribute>
  </health:JmxMeter>
  
  <health:JmxDeltaMeter>
    <name>JVM|Compilation|Compilation Time</name>
    <objectName>java.lang:type=Compilation</objectName>
    <attribute>TotalCompilationTime</attribute>
  </health:JmxDeltaMeter>
  
  <health:JmxMeter>
    <name>JVM|Thread|JVM Thread Count</name>
    <objectName>java.lang:type=Threading</objectName>
    <attribute>ThreadCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Active Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadActiveCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Idle Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadIdleCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Starting Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadStartingCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Wait Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadWaitCount</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Task Queue</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadTaskQueueSize</attribute>
  </health:JmxMeter>

  <health:JmxMeter>
    <name>Resin|Thread|Thread Priority Queue</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadPriorityQueueSize</attribute>
  </health:JmxMeter>
  
  <health:JmxDeltaMeter>
    <name>Resin|Thread|Thread Create Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadCreateCountTotal</attribute>
  </health:JmxDeltaMeter>
  
  <health:JmxDeltaMeter>
    <name>Resin|Thread|Thread Overflow Count</name>
    <objectName>resin:type=ThreadPool</objectName>
    <attribute>ThreadOverflowCountTotal</attribute>
  </health:JmxDeltaMeter>
  
  <health:JmxDeltaMeter>
    <name>Resin|Cache|Block Read Count</name>
    <objectName>resin:type=BlockManager</objectName>
    <attribute>BlockReadCountTotal</attribute>
  </health:JmxDeltaMeter>

  <health:JmxDeltaMeter>
    <name>Resin|Cache|Block Write Count</name>
    <objectName>resin:type=BlockManager</objectName>
    <attribute>BlockWriteCountTotal</attribute>
  </health:JmxDeltaMeter>

  <health:JmxDeltaMeter>
    <name>Resin|Cache|Block Miss Count</name>
    <objectName>resin:type=BlockManager</objectName>
    <attribute>MissCountTotal</attribute>
  </health:JmxDeltaMeter>

</cluster>
