#
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing,
#  software distributed under the License is distributed on an
#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#  KIND, either express or implied.  See the License for the
#  specific language governing permissions and limitations
#  under the License.
##
[feature name=healthcheck]

# startlevel 5 together with jetty (to allow use during startup)
[artifacts startLevel=5]
    org.apache.felix/org.apache.felix.healthcheck.api/2.0.2
    org.apache.felix/org.apache.felix.healthcheck.core/2.0.6
    org.apache.felix/org.apache.felix.healthcheck.generalchecks/2.0.4
    org.apache.felix/org.apache.felix.healthcheck.webconsoleplugin/2.0.0

# sling health check bundles at startlevel 20
[artifacts startLevel=20]
    org.apache.sling/org.apache.sling.hc.api/1.0.4
    org.apache.sling/org.apache.sling.hc.support/1.0.6

[configurations]
    
  ## servlet
    
  org.apache.felix.hc.core.impl.servlet.HealthCheckExecutorServlet-default
    servletPath="/system/health"

  ## systemalive checks

  org.apache.felix.hc.generalchecks.FrameworkStartCheck
    hc.tags=["systemalive"]
    targetStartLevel=I"30"
    
  org.apache.felix.hc.generalchecks.ServicesCheck
    hc.tags=["systemalive"]
    services.list=[
      "org.apache.sling.jcr.api.SlingRepository",
      "org.apache.sling.engine.auth.Authenticator",
      "org.apache.sling.api.resource.ResourceResolverFactory",
      "org.apache.sling.api.servlets.ServletResolver",
      "javax.script.ScriptEngineManager",
    ]


  ## bundles
  
  org.apache.felix.hc.generalchecks.BundlesStartedCheck
    hc.tags=["bundles"]
    
  ## system resources
  
  org.apache.felix.hc.generalchecks.ThreadUsageCheck
    hc.tags=["threads", "cpu", "system-resources"]

  org.apache.felix.hc.generalchecks.CpuCheck
    hc.tags=["cpu", "system-resources"]
    cpuPercentageThresholdWarn=L"95"
    
   org.apache.felix.hc.generalchecks.DiskSpaceCheck
    hc.tags=["diskspace", "system-resources"]
    diskPaths=["."]
  
   org.apache.felix.hc.generalchecks.MemoryCheck
    hc.tags=["memory", "system-resources"]
    heapUsedPercentageThresholdWarn=L"95"
    heapUsedPercentageThresholdCritical=L"100"

   ## service user for scripted health check (to make it easy to use jcr:/path/to/script urls)
  org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-hc-support
    user.mapping=[
      "org.apache.sling.hc.support\=sling-readall"
    ]

  ## Service Unavailable Filter for startup-shutdown
  org.apache.felix.hc.core.impl.filter.ServiceUnavailableFilter-startupandshutdown
    tags=["systemalive"]
    service.ranking=I"2147483647"
    osgi.http.whiteboard.context.select="(osgi.http.whiteboard.context.name\=*)"
    osgi.http.whiteboard.filter.regex="(?!/system/).*"
    responseTextFor503="classpath:org.apache.sling.starter.content:content/content/startup/index.html"
    includeExecutionResult=B"false"
    autoDisableFilter=B"true"
    avoid404DuringStartup=B"true"
