<?xml version="1.0"?>
<!--

    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.
-->
<!DOCTYPE plugin [
	<!ENTITY jvm-jmx-metrics SYSTEM "/pdk/plugins/jvm-jmx-metrics.xml">
	<!ENTITY process-metrics SYSTEM "/pdk/plugins/process-metrics.xml">
	<!ENTITY fuse-destination-metrics SYSTEM "/pdk/plugins/fuse-destination-metrics.xml">
	<!ENTITY fuse-servicemix-services SYSTEM "/pdk/plugins/fuse-servicemix-services.xml">
	<!ENTITY fuse-messaging-services SYSTEM "/pdk/plugins/fuse-messaging-services.xml">
	<!ENTITY fuse-routing-services SYSTEM "/pdk/plugins/fuse-routing-services.xml">
	<!ENTITY fuse-webservice-metrics SYSTEM "/pdk/plugins/fuse-webservice-metrics.xml">
	<!ENTITY fuse-webservice-services SYSTEM "/pdk/plugins/fuse-webservice-services.xml">
]>
<plugin package="org.hyperic.hq.plugin.servicemix" name="servicemix">

	<classpath>
		<include name="pdk/lib/mx4j"/>
	</classpath>
	
	<filter name="servicemix-domain" value="org.apache.servicemix"/>
	<filter name="karaf-domain" value="org.apache.felix.karaf"/>
	<filter name="osgi-core-domain" value="osgi.core"/>
	<filter name="osgi-compendium-domain" value="osgi.compendium"/>
	<filter name="messaging_domain" value="org.apache.activemq"/>
	<filter name="fuse_routing_domain" value="org.apache.camel"/>
	<filter name="template" value="${OBJECT_NAME}:${alias}"/>
	
	<metrics name="Class Loading Metrics">
		<metric name="Loaded Class Count" indicator="false" category="THROUGHPUT"/>
		<metric name="Total Loaded Class Count" indicator="false" category="THROUGHPUT"/>
		<metric name="Unloaded Class Count" indicator="false" category="THROUGHPUT"/>
	</metrics>
	<metrics name="Compilation">
		<metric name="Total Compilation Time" indicator="false" category="THROUGHPUT" collectionType="trendsup" units="ms"/>
	</metrics>
	<metrics name="Garbage Collector">
		<metric name="Collection Count" indicator="true" category="THROUGHPUT" collectionType="trendsup"/>
		<metric name="Collection Time" indicator="true" category="THROUGHPUT" collectionType="trendsup"/>
	</metrics>
	<metrics name="Memory">
		<metric name="Object Pending Finalization Count" category="THROUGHPUT" indicator="false"/>
	</metrics>
	<metrics name="Threading">
		<metric name="Thread Count" category="UTILIZATION" indicator="true"/>
		<metric name="Daemon Thread Count" category="UTILIZATION" indicator="true"/>
	</metrics>
	

        &fuse-destination-metrics;
        &fuse-webservice-metrics;

	<server name="ServiceMix" version="3.x">
		<config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
			<option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=servicemix.home"/>
		</config>
		
		<property name="PROC_HOME_PROPERTY" value="servicemix.home"/>
		<property name="VERSION_FILE" value="lib/servicemix-core-3.*.jar"/>
		
		<property name="DEFAULT_CONF" value="conf/servicemix.xml"/>
		<property name="DEFAULT_LOG_FILE" value="data/log/servicemix.log"/>
		<plugin type="autoinventory" class="org.hyperic.hq.product.jmx.MxServerDetector"/>
		<plugin type="measurement" class="org.hyperic.hq.product.jmx.MxMeasurementPlugin"/>
		<plugin type="log_track" class="org.hyperic.hq.product.Log4JLogTrackPlugin"/>
		<!--<plugin type="config_track" class="org.hyperic.hq.product.ConfigFileTrackPlugin"/>-->
		<metric name="Availability" template="sigar:Type=ProcState,Arg=%process.query%:State" indicator="true"/>

		&process-metrics;

		<property name="OBJECT_NAME" value="java.lang:type=ClassLoading"/>
		<metrics include="Class Loading Metrics"/>

		<property name="OBJECT_NAME" value="java.lang:type=Compilation"/>
		<metrics include="Compilation"/>

		<property name="OBJECT_NAME" value="java.lang:type=Memory"/>
		<metrics include="Memory"/>

		<property name="OBJECT_NAME" value="java.lang:type=Threading"/>
		<metrics include="Threading"/>

		<service name="Garbage Collector">
			<plugin type="autoinventory"/>
			<property name="OBJECT_NAME" value="java.lang:type=GarbageCollector,name=*"/>
			<metric name="Availability" indicator="true"/>
			<metrics include="Garbage Collector"/>
		</service>

        &fuse-messaging-services;
        &fuse-routing-services; 
		&fuse-webservice-services;
		<service name="Container">
			<property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=JBIContainer"/>
			<config>
				<option name="ContainerName" description="Container Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
		</service>

		<service name="Shared Library">
			<property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=SharedLibrary,Name=*"/>
			<config>
				<option name="ContainerName" description="Container Name" default=""/>
				<option name="Name" description="Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<metric name="Availability" indicator="true"/>
		</service>
	
		<service name="Component">
			<property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=Component,Name=*,SubType=LifeCycle"/>
			<property name="STATS_OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=Statistics,SubType=Component,Name=*"/>
			<config>
				<option name="ContainerName" description="Container Name" default=""/>
				<option name="Name" description="Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
			<metric name="Inbound Exchange Count" alias="inboundExchangeCount" template="${STATS_OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Inbound Exchange Rate" alias="inboundExchangeRate" template="${STATS_OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
			<metric name="Outbound Exchange Count" alias="outboundExchangeCount" template="${STATS_OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Outbound Exchange Rate" alias="outboundExchangeRate" template="${STATS_OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
		</service>
	
		<service name="Service Assembly">
			<property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=ServiceAssembly,Name=*"/>
			<config>
				<option name="ContainerName" description="Container Name" default=""/>
				<option name="Name" description="Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
		</service>
	
		<service name="Endpoint">
			<property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=*,Type=Statistics,SubType=Endpoint,Name=*"/>
			<config>
				<option name="ContainerName" description="Container Name" default=""/>
				<option name="Name" description="Name" default=""/>
				<option name="SubType" description="SubType" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<metric name="Availability" indicator="true"/>
			<metric name="Inbound Exchange Count" alias="inboundExchangeCount" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Inbound Exchange Rate" alias="inboundExchangeRate" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
			<metric name="Outbound Exchange Count" alias="outboundExchangeCount" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Outbound Exchange Rate" alias="outboundExchangeRate" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
		</service>

    <service name="JBI Admin Commands Service">
       <property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=ServiceMix,Type=SystemService,Name=AdminCommandsService"/>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="installComponent,uninstallComponent,listComponents,startComponent,stopComponent,shutdownComponent,installSharedLibrary,uninstallSharedLibrary,listSharedLibraries,deployServiceAssembly,undeployServiceAssembly,startServiceAssembly,stopServiceAssembly,shutdownServiceAssembly,listServiceAssemblies"/>
			<metric name="Availability" indicator="true"/>
    </service>
	</server>

        <!-- Plain Apache ServiceMix 4 series 
          -
          -  Uses:  servicemix.home as the detector property for process table scan
          -         system/org/apache/servicemix/apache-servicemix/4.0.0 as the version sentinel file
          -->
	<server name="ServiceMix" version="4.0">
		<config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/jmxrmi"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
			<option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=servicemix.home"/>
		</config>
		<property name="PROC_HOME_PROPERTY" value="servicemix.home"/>
		<property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.0*"/>
		<plugin type="autoinventory" class="org.hyperic.hq.product.jmx.MxServerDetector"/>
		<property name="DEFAULT_LOG_FILE" value="data/log/servicemix.log"/>
		<plugin type="log_track" class="org.hyperic.hq.product.Log4JLogTrackPlugin"/>
		<plugin type="measurement" class="org.hyperic.hq.product.jmx.MxMeasurementPlugin"/>
		<metric name="Availability" template="sigar:Type=ProcState,Arg=%process.query%:State" indicator="true"/>

		&process-metrics;

		<property name="OBJECT_NAME" value="java.lang:type=ClassLoading"/>
		<metrics include="Class Loading Metrics"/>

		<property name="OBJECT_NAME" value="java.lang:type=Compilation"/>
		<metrics include="Compilation"/>

		<property name="OBJECT_NAME" value="java.lang:type=Memory"/>
		<metrics include="Memory"/>
	
		<property name="OBJECT_NAME" value="java.lang:type=Threading"/>
		<metrics include="Threading"/>

                &fuse-messaging-services;
                &fuse-routing-services; 
                &fuse-webservice-services; 

		<service name="Garbage Collector">
			<plugin type="autoinventory"/>
			<property name="OBJECT_NAME" value="java.lang:type=GarbageCollector,name=*"/>
			<metric name="Availability" indicator="true"/>
			<metrics include="Garbage Collector"/>
		</service>

		<service name="SharedLibrary">
			<property name="OBJECT_NAME" value="${servicemix-domain}:Type=SharedLibrary,Name=*,Version=*"/>
			<config><option name="Name" description="Name" default=""/>
				<option name="Version" description="Version" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<metric name="Availability" indicator="true"/>
		</service>
	
	    <service name="Component">
			<property name="OBJECT_NAME" value="${servicemix-domain}:Type=Component,Name=*,SubType=LifeCycle"/>
			<config>
				<option name="Name" description="Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
		</service>

	    <service name="ServiceAssembly">
			<property name="OBJECT_NAME" value="${servicemix-domain}:Type=ServiceAssembly,Name=*"/>
			<config>
				<option name="Name" description="Name" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
		</service>

	    <service name="Endpoint"><property name="OBJECT_NAME" value="${servicemix-domain}:Type=Endpoint,Id=*"/>
			<config>
				<option name="Id" description="Id" default=""/>
			</config>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="start,stop,shutDown"/>
			<metric name="Availability" indicator="true"/>
			<metric name="Inbound Exchange Count" alias="InboundExchangeCount" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Inbound Exchange Rate" alias="InboundExchangeRate" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
			<metric name="Outbound Exchange Count" alias="OutboundExchangeCount" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true" collectionType="trendsup" rate="none"/>
			<metric name="Outbound Exchange Rate" alias="OutboundExchangeRate" template="${OBJECT_NAME}:${alias}" category="THROUGHPUT" indicator="true"/>
		</service>

    <service name="JBI Admin Commands Service">
       <property name="OBJECT_NAME" value="${servicemix-domain}:ContainerName=ServiceMix,Type=SystemService,Name=AdminCommandsService"/>
			<plugin type="autoinventory"/>
			<plugin type="control" class="org.hyperic.hq.product.jmx.MxControlPlugin"/>
			<actions include="installComponent,uninstallComponent,listComponents,startComponent,stopComponent,shutdownComponent,installSharedLibrary,uninstallSharedLibrary,listSharedLibraries,deployServiceAssembly,undeployServiceAssembly,startServiceAssembly,stopServiceAssembly,shutdownServiceAssembly,listServiceAssemblies"/>
			<metric name="Availability" indicator="true"/>
    </service>

  </server>

   <!-- Fuse Apache ServiceMix 4.1 series
     -
     -  Uses:  Apache ServiceMix 4 properties and
     -         system/org/apache/servicemix/apache-servicemix/4.1*-fuse as the version sentinel file
     -->

  <server name="ServiceMix" version="4.1-psc" include="4.0">
		<config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="karaf"/>
			<option name="jmx.password" description="JMX password" optional="true" default="karaf" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
		</config>
      <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.1.0-psc*"/>
		<property name="PROC_HOME_PROPERTY" value="karaf.home"/>
		<property name="DEFAULT_LOG_FILE" value="data/log/karaf.log"/>
  </server>

  <server name="ServiceMix" version="4.1-fuse" include="4.0">
		<config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="karaf"/>
			<option name="jmx.password" description="JMX password" optional="true" default="karaf" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
		</config>
		<property name="PROC_HOME_PROPERTY" value="karaf.home"/>
		<property name="DEFAULT_LOG_FILE" value="data/log/karaf.log"/>
      <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.1*-fuse"/>
      &fuse-servicemix-services;
  </server>

   <!-- Fuse Apache ServiceMix 4.2 series
     -
     -  Uses:  karaf.home as the detector property for process table scan 
     -         karaf.home as the home directory property
     -         data/log/karaf.log as the default log file
     -         system/org/apache/servicemix/apache-servicemix/4.2*-fuse as the version sentinel file
     -->

  <server name="ServiceMix" version="4.2-fuse" include="4.1-fuse">
    <config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="karaf"/>
			<option name="jmx.password" description="JMX password" optional="true" default="karaf" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
    </config>
    <property name="PROC_HOME_PROPERTY" value="karaf.home"/>
    <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.2.0-fuse*"/>
    <property name="DEFAULT_LOG_FILE" value="data/log/karaf.log"/>
  </server>

  <server name="ServiceMix" version="4.3-fuse" include="4.2-fuse">
    <config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
    </config>
    <property name="PROC_HOME_PROPERTY" value="karaf.home"/>
    <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.3.0-fuse*"/>
    <property name="DEFAULT_LOG_FILE" value="data/log/servicemix.log"/>
  </server>

  <server name="ServiceMix" version="4.3.1-fuse" include="4.3-fuse">
    <config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
    </config>
    <property name="PROC_HOME_PROPERTY" value="karaf.home"/>
    <property name="PROC_MAIN_CLASS" value="org.apache.karaf.main.Main"/>
    <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.3.1-fuse*"/>
    <property name="DEFAULT_LOG_FILE" value="data/log/servicemix.log"/>
  </server>

  <server name="ServiceMix" version="4.4.0-fuse" include="4.3.1-fuse">
    <config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
    </config>
    <property name="PROC_HOME_PROPERTY" value="karaf.home"/>
    <property name="PROC_MAIN_CLASS" value="org.apache.karaf.main.Main"/>
    <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.4.0-fuse*"/>
    <property name="DEFAULT_LOG_FILE" value="data/log/servicemix.log"/>
  </server>

  <!-- For Apache Servicemix 4.2 version discovery. -->
  <server name="ServiceMix" version="4.2" include="4.0">
    <config>
			<option name="jmx.url" description="JMX URL to MBeanServer" default="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/karaf-root"/>
			<option name="jmx.username" description="JMX username" optional="true" default="smx"/>
			<option name="jmx.password" description="JMX password" optional="true" default="smx" type="secret"/>
            <option name="process.query" description="Process Query" default="State.Name.eq=java,Args.*.ct=karaf.home"/>
    </config>
    <property name="PROC_HOME_PROPERTY" value="karaf.home"/>
    <property name="VERSION_FILE" value="system/org/apache/servicemix/apache-servicemix/4.2.0"/>
    <property name="DEFAULT_LOG_FILE" value="data/log/karaf.log"/>
  </server>
</plugin>
