Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
NMS-6466: Expose poller thread pool stats via JMX
Squashed commit of the following:

commit 9c129df
Author: Jeff Gehlbach <jeffg@opennms.org>
Date:   Sun Mar 16 14:50:19 2014 -0500

    Start collecting and graphing the new Pollerd JMX stats

commit 48df9b8
Author: Jeff Gehlbach <jeffg@opennms.org>
Date:   Sun Mar 16 12:43:30 2014 -0500

    Add the following attributes to the OpenNMS.Pollerd MBean:

     - ActiveThreads
     - TasksTotal
     - TasksCompleted
     - TaskCompletionRatio
  • Loading branch information
Jeff Gehlbach committed Mar 17, 2014
1 parent 3adb771 commit 7a8b065
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 5 deletions.
Expand Up @@ -89,6 +89,11 @@
<attrib name="TotalOperationsPending" alias="ONMSQueOpsPend" type="gauge"/>
<attrib name="UpdatesCompleted" alias="ONMSQueUpdates" type="counter"/>
</mbean>
<mbean name="OpenNMS Pollerd" objectname="OpenNMS:Name=Pollerd">
<attrib name="ActiveThreads" alias="ONMSPollerThreadAct" type="gauge"/>
<attrib name="TasksTotal" alias="ONMSPollerTasksTot" type="counter"/>
<attrib name="TasksCompleted" alias="ONMSPollerTasksCpt" type="counter"/>
</mbean>
<mbean name="JVM Memory" objectname="java.lang:type=OperatingSystem">
<attrib name="FreePhysicalMemorySize" alias="FreeMemory" type="gauge"/>
<attrib name="TotalPhysicalMemorySize" alias="TotalMemory" type="gauge"/>
Expand Down
Expand Up @@ -64,7 +64,8 @@ include.directory=snmp-graph.properties.d
# NOTE: Only OpenNMS internal graph definitions. Please create for
# customized graphs in snmp-graph.properties.d dedicated property
# files
reports=onms.queued.updates, onms.queued.pending
reports=onms.queued.updates, onms.queued.pending, \
onms.pollerd.activeThreads, onms.pollerd.completedRatio

# values available to prefab reports:
# {rrd1}, {rrd2}, {rrd3}, ... must match the datasources exactly
Expand Down Expand Up @@ -101,4 +102,29 @@ report.onms.queued.pending.command=--title="OpenNMS Queued Operations Pending" \
GPRINT:pending:MIN:"Min \\: %8.2lf %s" \
GPRINT:pending:MAX:"Max \\: %8.2lf %s\\n"

report.onms.pollerd.activeThreads.name=OpenNMS Poller Threads Active
report.onms.pollerd.activeThreads.columns=ONMSPollerThreadAct
report.onms.pollerd.activeThreads.type=interfaceSnmp
report.onms.pollerd.activeThreads.command=--title="OpenNMS Pollerd Threads Active" \
--vertical-label="Threads" \
DEF:active={rrd1}:ONMSPollerThreadAct:AVERAGE \
LINE1:active#0000ff:"Total Active" \
GPRINT:active:AVERAGE:" Avg \\: %8.2lf %s" \
GPRINT:active:MIN:"Min \\: %8.2lf %s" \
GPRINT:active:MAX:"Max \\: %8.2lf %s\\n"

report.onms.pollerd.completedRatio.name=OpenNMS Poller Task Completion Ratio
report.onms.pollerd.completedRatio.columns=ONMSPollerTasksTot,ONMSPollerTasksCpt
report.onms.pollerd.completedRatio.type=interfaceSnmp
report.onms.pollerd.completedRatio.command=--title="OpenNMS Pollerd Task Completion" \
--vertical-label="Percent" \
--lower-limit=0 --upper-limit=100 --units-exponent=0 \
DEF:total={rrd1}:ONMSPollerTasksTot:AVERAGE \
DEF:completed={rrd2}:ONMSPollerTasksCpt:AVERAGE \
CDEF:percent=completed,total,/,100,* \
LINE1:percent#0000ff:"Completion Ratio" \
GPRINT:percent:AVERAGE:" Avg \\: %8.2lf %s" \
GPRINT:percent:MIN:"Min \\: %8.2lf %s" \
GPRINT:percent:MAX:"Max \\: %8.2lf %s\\n"

## EOF
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2006-2012 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
* Copyright (C) 2006-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand All @@ -28,7 +28,10 @@

package org.opennms.netmgt.poller.jmx;

import java.util.concurrent.ThreadPoolExecutor;

import org.opennms.netmgt.daemon.AbstractSpringContextJmxServiceDaemon;
import org.opennms.netmgt.scheduler.LegacyScheduler;

/**
* <p>Pollerd class.</p>
Expand All @@ -49,6 +52,57 @@ protected String getLoggingPrefix() {
protected String getSpringContext() {
return "pollerdContext";
}

/** {@inheritDoc} */
@Override
public long getActiveThreads() {
if (getThreadPoolStatsStatus()) {
return getExecutor().getActiveCount();
} else {
return 0L;
}
}

/** {@inheritDoc} */
@Override
public long getTasksTotal() {
if (getThreadPoolStatsStatus()) {
return getExecutor().getTaskCount();
} else {
return 0L;
}
}

/** {@inheritDoc} */
@Override
public long getTasksCompleted() {
if (getThreadPoolStatsStatus()) {
return getExecutor().getTaskCount();
} else {
return 0L;
}
}

/** {@inheritDoc} */
@Override
public double getTaskCompletionRatio() {
if (getThreadPoolStatsStatus()) {
if (getExecutor().getTaskCount() > 0) {
return new Double(getExecutor().getCompletedTaskCount() / new Double(getExecutor().getTaskCount()));
} else {
return new Double(0);
}
} else {
return new Double(0);
}
}

private ThreadPoolExecutor getExecutor() {
return (ThreadPoolExecutor) ((LegacyScheduler) getDaemon().getScheduler()).getRunner();
}

private boolean getThreadPoolStatsStatus() {
return (getDaemon().getScheduler() instanceof LegacyScheduler);
}
}

@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2006-2012 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
* Copyright (C) 2006-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand Down Expand Up @@ -37,4 +37,23 @@
* @version $Id: $
*/
public interface PollerdMBean extends BaseOnmsMBean {
/**
* @return The number of currently active poller threads
*/
public long getActiveThreads();

/**
* @return The cumulative number of polling tasks scheduled since poller startup
*/
public long getTasksTotal();

/**
* @return The cumulative number of polling tasks completed since poller startup
*/
public long getTasksCompleted();

/**
* @return The ratio of completed to scheduled polling tasks since poller startup
*/
public double getTaskCompletionRatio();
}

0 comments on commit 7a8b065

Please sign in to comment.