Search in sources :

Example 6 with HealthCheckResultEntry

use of fish.payara.notification.healthcheck.HealthCheckResultEntry in project Payara by payara.

the class ConnectionPoolHealthCheck method evaluatePoolUsage.

private void evaluatePoolUsage(HealthCheckResult result, PoolInfo poolInfo) {
    PoolStatus poolStatus = poolManager.getPoolStatus(poolInfo);
    if (poolStatus != null) {
        long usedConnection = poolStatus.getNumConnUsed();
        long freeConnection = poolStatus.getNumConnFree();
        long totalConnection = usedConnection + freeConnection;
        if (totalConnection > 0) {
            double usedPercentage = ((double) usedConnection / totalConnection) * 100;
            result.add(new HealthCheckResultEntry(decideOnStatusWithRatio(usedPercentage), poolInfo.getName() + " Usage (%): " + new DecimalFormat("#.00").format(usedPercentage)));
        }
    }
}
Also used : DecimalFormat(java.text.DecimalFormat) PoolStatus(com.sun.enterprise.resource.pool.PoolStatus) HealthCheckResultEntry(fish.payara.notification.healthcheck.HealthCheckResultEntry)

Example 7 with HealthCheckResultEntry

use of fish.payara.notification.healthcheck.HealthCheckResultEntry in project Payara by payara.

the class StuckThreadsHealthCheck method doCheck.

@Override
public HealthCheckResult doCheck() {
    HealthCheckResult result = new HealthCheckResult();
    ThreadMXBean bean = ManagementFactory.getThreadMXBean();
    Long thresholdNanos = TimeUnit.NANOSECONDS.convert(options.getTimeStuck(), options.getUnitStuck());
    ConcurrentHashMap<Long, Long> threads = stuckThreadsStore.getThreads();
    for (Long thread : threads.keySet()) {
        Long timeHeld = threads.get(thread);
        if (timeHeld > thresholdNanos) {
            ThreadInfo info = bean.getThreadInfo(thread, Integer.MAX_VALUE);
            if (info != null) {
                // check thread hasn't died already
                result.add(new HealthCheckResultEntry(HealthCheckResultStatus.WARNING, "Stuck Thread: " + info.toString()));
            }
        }
    }
    return result;
}
Also used : ThreadMXBean(java.lang.management.ThreadMXBean) ThreadInfo(java.lang.management.ThreadInfo) HealthCheckResult(fish.payara.nucleus.healthcheck.HealthCheckResult) HealthCheckResultEntry(fish.payara.notification.healthcheck.HealthCheckResultEntry)

Aggregations

HealthCheckResultEntry (fish.payara.notification.healthcheck.HealthCheckResultEntry)7 HealthCheckResult (fish.payara.nucleus.healthcheck.HealthCheckResult)5 ThreadMXBean (java.lang.management.ThreadMXBean)3 DecimalFormat (java.text.DecimalFormat)3 ThreadTimes (fish.payara.nucleus.healthcheck.entity.ThreadTimes)2 ThreadInfo (java.lang.management.ThreadInfo)2 PoolStatus (com.sun.enterprise.resource.pool.PoolStatus)1 IOException (java.io.IOException)1 GarbageCollectorMXBean (java.lang.management.GarbageCollectorMXBean)1 MemoryMXBean (java.lang.management.MemoryMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1 OperatingSystemMXBean (java.lang.management.OperatingSystemMXBean)1