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)));
}
}
}
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;
}
Aggregations