#*
The server renders this page in response to a heartbeat request to a PingFederate instance
running as an engine node.

Velocity variables (identified by the $ character) are generated
at runtime by the server. If pf.heartbeat.system.monitoring is set
to true in run.properties then the following variables are available
for use in this template:

$monitor.getTotalJvmMemory() - bytes by default
$monitor.getTotalJvmMemory('KB' | 'MB' | 'GB')
$monitor.getUsedJvmMemory() - bytes by default
$monitor.getUsedJvmMemory('KB' | 'MB' | 'GB')
$monitor.getFreeJvmMemory() - bytes by default
$monitor.getFreeJvmMemory('KB' | 'MB' | 'GB')
$monitor.getTotalPhysicalSystemMemory()	- bytes by default
$monitor.getTotalPhysicalSystemMemory('bytes' | 'KB' | 'MB' | 'GB')
$monitor.getTotalFreePhysicalSystemMemory()	- bytes by default
$monitor.getTotalFreePhysicalSystemMemory('bytes' | 'KB' | 'MB' | 'GB')
$monitor.getTotalUsedPhysicalSystemMemory()	- bytes by default
$monitor.getTotalUsedPhysicalSystemMemory('bytes' | 'KB' | 'MB' | 'GB')
$monitor.getHostname()
$monitor.getNumberOfCpus()
$monitor.getCpuLoad('###.##') - insert custom format

$resultKeys defines additional metrics to include in the response. Please see online documentation for a description
of these metrics.

Percentile values are configurable in com.pingidentity.monitoring.MonitoringService.xml
*#

#if($heartbeatSystemMonitoring)
#set($resultKeys = [
    "response.statistics.count",
    "response.statistics.window.seconds",
    "response.time.statistics.*",
    "response.concurrency.statistics.*",
    "response.http.status.*",
    "transaction.count",
    "transaction.errors",
    "total.transactions",
    "total.failed.transactions",
    "ds.*",
    "adapter.*",
    "connection.*",
    "engine.jetty.queued.thread.pool.*",
    "idp.session.registry.session.map.*",
    "sp.session.registry.session.map.*",
    "session.state.attribute.map.*",
    "transaction.state.map.*",
    "atm.*.token.map.size",
    "cluster.*"
])

{"items":[{
      "cpu.load": "$monitor.getCpuLoad('###.##')",
      "total.jvm.memory": "$monitor.getTotalJvmMemory('MB') MB",
      "free.jvm.memory": "$monitor.getFreeJvmMemory('MB') MB",
      "used.jvm.memory": "$monitor.getUsedJvmMemory('MB') MB",
      "total.physical.system.memory": "$monitor.getTotalPhysicalSystemMemory('GB') GB",
      "total.free.physical.system.memory": "$monitor.getTotalFreePhysicalSystemMemory('MB') MB",
      "total.used.physical.system.memory": "$monitor.getTotalUsedPhysicalSystemMemory('GB') GB",
      "number.of.cpus": "$monitor.getNumberOfCpus()",
#set ( $map = $monitor.getResults($resultKeys) )
#set ( $size = $map.size() )
#set ( $count = 0)
#foreach( $key in $map.keySet() )
      #set ( $count =  $count + 1)
      "${key}": "$map.get($key)"#if( $count < $size ),
#end
#end

}]}
#else
OK
#end
