Skip to content

Instantly share code, notes, and snippets.

@theute
Created September 16, 2015 14:30
Show Gist options
  • Save theute/d5dba346211a35177104 to your computer and use it in GitHub Desktop.
Save theute/d5dba346211a35177104 to your computer and use it in GitHub Desktop.
Instrument a WF9 server for Hawkular
#/bin/bash
function usage {
echo "Usage: $0 wildfly_zip_location agent_version standalone_patch username password server_ip server_port wildfly_server_name "
echo " wildfly_zip_location: file location of a WildFLy distribution"
echo " wildfly_server_name: Server name to give to the WildFly instance"
echo " agent_version: Version of the Hawkular agent to install or LATEST for the latest release"
echo " standalone_patch: Patch file to apply on standalone.xml"
echo " username"
echo " password"
echo " server_ip"
echo " server_port"
echo "Example: ./instrument.sh ~/Downloads/wildfly-9.0.1.Final.zip LATEST standalone_patch.xml theute myPassw0rd 127.0.0.1 8080 foobar"
}
function error {
echo "ERROR: $1" 1>&2
}
function warning {
echo "WARNING: $1"
}
MIN_ARGUMENTS=8
MAX_ARGUMENTS=$((MIN_ARGUMENTS + 0))
TMP_DIR='/tmp'
WILDFLY_ZIP_PATH=$1
AGENT_VERSION=$2
PATCH_FILE=$3
USERNAME=$4
PASSWORD=$5
SERVER_IP=$6
SERVER_PORT=$7
WILDFLY_NAME=$8
WILDFLY_PATH='wildfly-'${WILDFLY_NAME}/$(basename ${WILDFLY_ZIP_PATH} .zip)
if [ $# -lt ${MIN_ARGUMENTS} -o $# -gt ${MAX_ARGUMENTS} ]; then
error "Wrong number of arguments"
usage
exit 1
fi
# Unzip WildFly
if [ ! -d ${WILDFLY_PATH} ]
then
echo "Unzipping: "${WILDFLY_ZIP_PATH}
mkdir -p ${WILDFLY_PATH}
unzip -q ${WILDFLY_ZIP_PATH} -d 'wildfly-'${WILDFLY_NAME}
echo "Unzipping done"
else
error 'wildfly-'${WILDFLY_NAME}' already exist.'
exit 1
fi
# Get the Wildfly agent
if [ ! -f ${TMP_DIR}/hawkular-monitor-${AGENT_VERSION}-module.zip ] || [ ${AGENT_VERSION} == 'LATEST' ]
then
echo "Downloading: hawkular-monitor-${AGENT_VERSION}-module.zip"
wget -q -P ${TMP_DIR} 'https://repository.jboss.org/nexus/service/local/artifact/maven/content?r=public&g=org.hawkular.agent&a=hawkular-monitor&v='${AGENT_VERSION}'&p=zip&c=module'
mv ${TMP_DIR}'/content?r=public&g=org.hawkular.agent&a=hawkular-monitor&v='${AGENT_VERSION}'&p=zip&c=module' ${TMP_DIR}/hawkular-monitor-${AGENT_VERSION}-module.zip
echo "Downloading done"
else
warning "hawkular-monitor-${AGENT_VERSION}-module.zip has already been downloaded. Not downloading again"
fi
# Extract Wildfly agent
if [ ! -d ${WILDFLY_PATH}/modules/system/layers/base/org/hawkular/agent ]
then
echo Unzipping: hawkular-monitor-${AGENT_VERSION}-module.zip
unzip -q ${TMP_DIR}/hawkular-monitor-${AGENT_VERSION}-module.zip -d ${WILDFLY_PATH}/modules/system/layers/base/
echo "Unzipping done"
else
warning "${WILDFLY_PATH}/modules/system/layers/base/org/hawkular/agent already exist, not extracting again. Note: it may be a different version."
fi
echo "Patching standalone.xml"
patch -s ${WILDFLY_PATH}/standalone/configuration/standalone.xml ${PATCH_FILE}
sed -i 's/server xmlns="urn:jboss:domain:3.0"/server name="'${WILDFLY_NAME}'" xmlns="urn:jboss:domain:3.0"/g' ${WILDFLY_PATH}/standalone/configuration/standalone.xml
sed -i 's/\*\*USERNAME\*\*/'${USERNAME}'/g' ${WILDFLY_PATH}/standalone/configuration/standalone.xml
sed -i 's/\*\*PASSWORD\*\*/'${USERNAME}'/g' ${WILDFLY_PATH}/standalone/configuration/standalone.xml
sed -i 's/\*\*SERVER_IP\*\*/'${USERNAME}'/g' ${WILDFLY_PATH}/standalone/configuration/standalone.xml
sed -i 's/\*\*SERVER_PORT\*\*/'${USERNAME}'/g' ${WILDFLY_PATH}/standalone/configuration/standalone.xml
echo "Done. Your instrumented WildFLy server is here: "${WILDFLY_PATH}
--- /home/theute/Projects/Hawkular/demo/managedservers/wildfly-9.0.1.Final/standalone/configuration/standalone.xml
+++ /home/theute/Projects/Hawkular/demo/managedservers/wildfly-9.0.1.Final1/standalone/configuration/standalone.xml
@@ -1,5 +1,4 @@
<?xml version="1.0" ?>
-
<server xmlns="urn:jboss:domain:3.0">
<extensions>
<extension module="org.jboss.as.clustering.infinispan"/>
@@ -28,6 +27,7 @@
<extension module="org.wildfly.extension.request-controller"/>
<extension module="org.wildfly.extension.security.manager"/>
<extension module="org.wildfly.extension.undertow"/>
+ <extension module="org.hawkular.agent.monitor"/>
</extensions>
<management>
<security-realms>
@@ -375,6 +375,157 @@
<client-config name="Standard-Client-Config"/>
</subsystem>
<subsystem xmlns="urn:jboss:domain:weld:2.0"/>
+ <subsystem apiJndiName="java:global/hawkular/agent/monitor/api" numMetricSchedulerThreads="3" numAvailSchedulerThreads="3" enabled="${hawkular.agent.enabled:true}" xmlns="urn:org.hawkular.agent.monitor:monitor:1.0">
+ <diagnostics enabled="true" reportTo="LOG" interval="1" timeUnits="minutes"/>
+ <storage-adapter type="HAWKULAR" username="**USERNAME**" password="**PASSWORD**" serverOutboundSocketBindingRef="hawkular"/>
+ <metric-set-dmr name="WildFly Memory Metrics" enabled="true">
+ <metric-dmr name="Heap Used" interval="30" timeUnits="seconds" metricUnits="bytes" path="/core-service=platform-mbean/type=memory" attribute="heap-memory-usage#used"/>
+ <metric-dmr name="Heap Committed" interval="1" timeUnits="minutes" path="/core-service=platform-mbean/type=memory" attribute="heap-memory-usage#committed"/>
+ <metric-dmr name="Heap Max" interval="1" timeUnits="minutes" path="/core-service=platform-mbean/type=memory" attribute="heap-memory-usage#max"/>
+ <metric-dmr name="NonHeap Used" interval="30" timeUnits="seconds" path="/core-service=platform-mbean/type=memory" attribute="non-heap-memory-usage#used"/>
+ <metric-dmr name="NonHeap Committed" interval="1" timeUnits="minutes" path="/core-service=platform-mbean/type=memory" attribute="non-heap-memory-usage#committed"/>
+ <metric-dmr name="Accumulated GC Duration" metricType="counter" interval="1" timeUnits="minutes" path="/core-service=platform-mbean/type=garbage-collector/name=*" attribute="collection-time"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="WildFly Threading Metrics" enabled="true">
+ <metric-dmr name="Thread Count" interval="2" timeUnits="minutes" metricUnits="none" path="/core-service=platform-mbean/type=threading" attribute="thread-count"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="WildFly Aggregated Web Metrics" enabled="true">
+ <metric-dmr name="Aggregated Active Web Sessions" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow" attribute="active-sessions"/>
+ <metric-dmr name="Aggregated Max Active Web Sessions" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow" attribute="max-active-sessions"/>
+ <metric-dmr name="Aggregated Expired Web Sessions" metricType="counter" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow" attribute="expired-sessions"/>
+ <metric-dmr name="Aggregated Rejected Web Sessions" metricType="counter" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow" attribute="rejected-sessions"/>
+ <metric-dmr name="Aggregated Servlet Request Time" metricType="counter" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow/servlet=*" attribute="total-request-time"/>
+ <metric-dmr name="Aggregated Servlet Request Count" metricType="counter" interval="1" timeUnits="minutes" path="/deployment=*/subsystem=undertow/servlet=*" attribute="request-count"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Undertow Metrics" enabled="true">
+ <metric-dmr name="Active Sessions" interval="2" timeUnits="minutes" path="/subsystem=undertow" attribute="active-sessions"/>
+ <metric-dmr name="Sessions Created" metricType="counter" interval="2" timeUnits="minutes" path="/subsystem=undertow" attribute="sessions-created"/>
+ <metric-dmr name="Expired Sessions" metricType="counter" interval="2" timeUnits="minutes" path="/subsystem=undertow" attribute="expired-sessions"/>
+ <metric-dmr name="Rejected Sessions" metricType="counter" interval="2" timeUnits="minutes" path="/subsystem=undertow" attribute="rejected-sessions"/>
+ <metric-dmr name="Max Active Sessions" interval="2" timeUnits="minutes" path="/subsystem=undertow" attribute="max-active-sessions"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Servlet Metrics" enabled="true">
+ <metric-dmr name="Max Request Time" interval="5" timeUnits="minutes" metricUnits="milliseconds" path="/" attribute="max-request-time"/>
+ <metric-dmr name="Min Request Time" interval="5" timeUnits="minutes" path="/" attribute="min-request-time"/>
+ <metric-dmr name="Total Request Time" metricType="counter" interval="5" timeUnits="minutes" path="/" attribute="total-request-time"/>
+ <metric-dmr name="Request Count" metricType="counter" interval="5" timeUnits="minutes" path="/" attribute="request-count"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Singleton EJB Metrics" enabled="true">
+ <metric-dmr name="Execution Time" interval="5" timeUnits="minutes" path="/" attribute="execution-time"/>
+ <metric-dmr name="Invocations" metricType="counter" interval="5" timeUnits="minutes" path="/" attribute="invocations"/>
+ <metric-dmr name="Peak Concurrent Invocations" interval="5" timeUnits="minutes" path="/" attribute="peak-concurrent-invocations"/>
+ <metric-dmr name="Wait Time" interval="5" timeUnits="minutes" path="/" attribute="wait-time"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Message Driven EJB Metrics" enabled="true">
+ <metric-dmr name="Execution Time" interval="5" timeUnits="minutes" path="/" attribute="execution-time"/>
+ <metric-dmr name="Invocations" metricType="counter" interval="5" timeUnits="minutes" path="/" attribute="invocations"/>
+ <metric-dmr name="Peak Concurrent Invocations" interval="5" timeUnits="minutes" path="/" attribute="peak-concurrent-invocations"/>
+ <metric-dmr name="Wait Time" interval="5" timeUnits="minutes" path="/" attribute="wait-time"/>
+ <metric-dmr name="Pool Available Count" interval="5" timeUnits="minutes" path="/" attribute="pool-available-count"/>
+ <metric-dmr name="Pool Create Count" interval="5" timeUnits="minutes" path="/" attribute="pool-create-count"/>
+ <metric-dmr name="Pool Current Size" interval="5" timeUnits="minutes" path="/" attribute="pool-current-size"/>
+ <metric-dmr name="Pool Max Size" interval="5" timeUnits="minutes" path="/" attribute="pool-max-size"/>
+ <metric-dmr name="Pool Remove Count" interval="5" timeUnits="minutes" path="/" attribute="pool-remove-count"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Stateless Session EJB Metrics" enabled="true">
+ <metric-dmr name="Execution Time" interval="5" timeUnits="minutes" path="/" attribute="execution-time"/>
+ <metric-dmr name="Invocations" metricType="counter" interval="5" timeUnits="minutes" path="/" attribute="invocations"/>
+ <metric-dmr name="Peak Concurrent Invocations" interval="5" timeUnits="minutes" path="/" attribute="peak-concurrent-invocations"/>
+ <metric-dmr name="Wait Time" interval="5" timeUnits="minutes" path="/" attribute="wait-time"/>
+ <metric-dmr name="Pool Availabile Count" interval="5" timeUnits="minutes" path="/" attribute="pool-available-count"/>
+ <metric-dmr name="Pool Create Count" interval="5" timeUnits="minutes" path="/" attribute="pool-create-count"/>
+ <metric-dmr name="Pool Current Size" interval="5" timeUnits="minutes" path="/" attribute="pool-current-size"/>
+ <metric-dmr name="Pool Max Size" interval="5" timeUnits="minutes" path="/" attribute="pool-max-size"/>
+ <metric-dmr name="Pool Remove Count" interval="5" timeUnits="minutes" path="/" attribute="pool-remove-count"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Datasource JDBC Metrics" enabled="true">
+ <metric-dmr name="Prepared Statement Cache Access Count" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheAccessCount"/>
+ <metric-dmr name="Prepared Statement Cache Add Count" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheAddCount"/>
+ <metric-dmr name="Prepared Statement Cache Current Size" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheCurrentSize"/>
+ <metric-dmr name="Prepared Statement Cache Delete Count" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheDeleteCount"/>
+ <metric-dmr name="Prepared Statement Cache Hit Count" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheHitCount"/>
+ <metric-dmr name="Prepared Statement Cache Miss Count" interval="10" timeUnits="minutes" path="/statistics=jdbc" attribute="PreparedStatementCacheMissCount"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Datasource Pool Metrics" enabled="true">
+ <metric-dmr name="Active Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="ActiveCount"/>
+ <metric-dmr name="Available Count" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="AvailableCount"/>
+ <metric-dmr name="Average Blocking Time" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="AverageBlockingTime"/>
+ <metric-dmr name="Average Creation Time" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="AverageCreationTime"/>
+ <metric-dmr name="Average Get Time" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="AverageGetTime"/>
+ <metric-dmr name="Blocking Failure Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="BlockingFailureCount"/>
+ <metric-dmr name="Created Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="CreatedCount"/>
+ <metric-dmr name="Destroyed Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="DestroyedCount"/>
+ <metric-dmr name="Idle Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="IdleCount"/>
+ <metric-dmr name="In Use Count" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="InUseCount"/>
+ <metric-dmr name="Max Creation Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="MaxCreationTime"/>
+ <metric-dmr name="Max Get Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="MaxGetTime"/>
+ <metric-dmr name="Max Used Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="MaxUsedCount"/>
+ <metric-dmr name="Max Wait Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="MaxWaitCount"/>
+ <metric-dmr name="Max Wait Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="MaxWaitTime"/>
+ <metric-dmr name="Timed Out" interval="1" timeUnits="minutes" path="/statistics=pool" attribute="TimedOut"/>
+ <metric-dmr name="Total Blocking Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="TotalBlockingTime"/>
+ <metric-dmr name="Total Creation Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="TotalCreationTime"/>
+ <metric-dmr name="Total Get Time" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="TotalGetTime"/>
+ <metric-dmr name="Wait Count" interval="10" timeUnits="minutes" path="/statistics=pool" attribute="WaitCount"/>
+ </metric-set-dmr>
+ <metric-set-dmr name="Transactions Metrics" enabled="true">
+ <metric-dmr name="Number of Aborted Transactions" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-aborted-transactions"/>
+ <metric-dmr name="Number of Application Rollbacks" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-application-rollbacks"/>
+ <metric-dmr name="Number of Committed Transactions" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-committed-transactions"/>
+ <metric-dmr name="Number of Heuristics" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-heuristics"/>
+ <metric-dmr name="Number of In-Flight Transactions" interval="10" timeUnits="minutes" path="/" attribute="number-of-inflight-transactions"/>
+ <metric-dmr name="Number of Nested Transactions" interval="10" timeUnits="minutes" path="/" attribute="number-of-nested-transactions"/>
+ <metric-dmr name="Number of Resource Rollbacks" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-resource-rollbacks"/>
+ <metric-dmr name="Number of Timed Out Transactions" metricType="counter" interval="10" timeUnits="minutes" path="/" attribute="number-of-timed-out-transactions"/>
+ <metric-dmr name="Number of Transactions" interval="10" timeUnits="minutes" path="/" attribute="number-of-transactions"/>
+ </metric-set-dmr>
+ <avail-set-dmr name="Server Availability" enabled="true">
+ <avail-dmr name="App Server" interval="30" timeUnits="seconds" path="/" attribute="server-state" upRegex="run.*"/>
+ </avail-set-dmr>
+ <avail-set-dmr name="Deployment Status" enabled="true">
+ <avail-dmr name="Deployment Status" interval="1" timeUnits="minutes" path="/" attribute="status" upRegex="OK"/>
+ </avail-set-dmr>
+ <resource-type-set-dmr name="Main" enabled="true">
+ <resource-type-dmr name="WildFly Server" resourceNameTemplate="WildFly Server [%ManagedServerName] [${jboss.node.name:localhost}]" path="/" metricSets="WildFly Memory Metrics,WildFly Threading Metrics,WildFly Aggregated Web Metrics" availSets="Server Availability">
+ <resource-config-dmr name="Hostname" path="/core-service=server-environment" attribute="qualified-host-name"/>
+ <resource-config-dmr name="Version" attribute="release-version"/>
+ <resource-config-dmr name="Bound Address" path="/socket-binding-group=standard-sockets/socket-binding=http" attribute="bound-address"/>
+ </resource-type-dmr>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="Hawkular" enabled="true">
+ <resource-type-dmr name="Bus Broker" resourceNameTemplate="Bus Broker" path="/subsystem=hawkular-bus-broker" parents="WildFly Server"/>
+ <resource-type-dmr name="Monitor Agent" resourceNameTemplate="Monitor Agent" path="/subsystem=hawkular-monitor" parents="WildFly Server">
+ <operation-dmr name="Status" operationName="status" path="/"/>
+ </resource-type-dmr>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="Deployment" enabled="true">
+ <resource-type-dmr name="Deployment" resourceNameTemplate="Deployment [%2]" path="/deployment=*" parents="WildFly Server" metricSets="Undertow Metrics" availSets="Deployment Status">
+ <operation-dmr name="Deploy" operationName="deploy" path="/"/>
+ <operation-dmr name="Redeploy" operationName="redeploy" path="/"/>
+ <operation-dmr name="Remove" operationName="remove" path="/"/>
+ <operation-dmr name="Undeploy" operationName="undeploy" path="/"/>
+ </resource-type-dmr>
+ <resource-type-dmr name="SubDeployment" resourceNameTemplate="SubDeployment [%-]" path="/subdeployment=*" parents="Deployment" metricSets="Undertow Metrics"/>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="Web Component" enabled="true">
+ <resource-type-dmr name="Servlet" resourceNameTemplate="Servlet [%-]" path="/subsystem=undertow/servlet=*" parents="Deployment,SubDeployment" metricSets="Servlet Metrics"/>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="EJB" enabled="true">
+ <resource-type-dmr name="Singleton EJB" resourceNameTemplate="Singleton EJB [%-]" path="/subsystem=ejb3/singleton-bean=*" parents="Deployment,SubDeployment" metricSets="Singleton EJB Metrics"/>
+ <resource-type-dmr name="Message Driven EJB" resourceNameTemplate="Message Driven EJB [%-]" path="/subsystem=ejb3/message-driven-bean=*" parents="Deployment,SubDeployment" metricSets="Message Driven EJB Metrics"/>
+ <resource-type-dmr name="Stateless Session EJB" resourceNameTemplate="Stateless Session EJB [%-]" path="/subsystem=ejb3/stateless-session-bean=*" parents="Deployment,SubDeployment" metricSets="Stateless Session EJB Metrics"/>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="Datasource" enabled="true">
+ <resource-type-dmr name="Datasource" resourceNameTemplate="Datasource [%-]" path="/subsystem=datasources/data-source=*" parents="WildFly Server" metricSets="Datasource Pool Metrics,Datasource JDBC Metrics"/>
+ </resource-type-set-dmr>
+ <resource-type-set-dmr name="Transaction Manager" enabled="true">
+ <resource-type-dmr name="Transaction Manager" resourceNameTemplate="Transaction Manager" path="/subsystem=transactions" parents="WildFly Server" metricSets="Transactions Metrics"/>
+ </resource-type-set-dmr>
+ <managed-servers>
+ <remote-dmr name="Another Remote Server" enabled="false" host="localhost" port="9990" username="adminUser" password="adminPass" resourceTypeSets="Main,Deployment,Web Component,EJB,Datasource,Transaction Manager"/>
+ <local-dmr name="LocalManaged" enabled="true" resourceTypeSets="Main,Deployment,Web Component,EJB,Datasource,Transaction Manager,Hawkular"/>
+ </managed-servers>
+ </subsystem>
</profile>
<interfaces>
<interface name="management">
@@ -403,5 +554,10 @@
<outbound-socket-binding name="mail-smtp">
<remote-destination host="localhost" port="25"/>
</outbound-socket-binding>
+ <outbound-socket-binding name="hawkular">
+ <remote-destination
+ host="**SERVER_IP**"
+ port="**SERVER_PORT**" />
+ </outbound-socket-binding>
</socket-binding-group>
</server>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment