<?xml version="1.0"?>

<!DOCTYPE plugin [
  <!ENTITY process-metrics SYSTEM "/pdk/plugins/process-metrics.xml">
  <!ENTITY jvm-jmx-metrics SYSTEM "/pdk/plugins/jvm-jmx-metrics.xml">
]>

<!--
  NOTE: This copyright does *not* cover user programs that use HQ
  program services by normal system calls through the application
  program interfaces provided as part of the Hyperic Plug-in Development
  Kit or the Hyperic Client Development Kit - this is merely considered
  normal use of the program, and does *not* fall under the heading of
  "derived work".
  
  Copyright (C) [2004, 2005, 2006], Hyperic, Inc.
  This file is part of HQ.
  
  HQ is free software; you can redistribute it and/or modify
  it under the terms version 2 of the GNU General Public License as
  published by the Free Software Foundation. This program is distributed
  in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  PARTICULAR PURPOSE. See the GNU General Public License for more
  details.
  
  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  USA.
 -->

<plugin package="org.hyperic.hq.plugin.glassfish">

  <classpath>
    <include name="pdk/lib/mx4j"/>
  </classpath>

  <filter name="template"
          value="${OBJECT_NAME}:${alias}"/>

  <server name="GlassFish"
          version="9.x">

    <property name="HAS_BUILTIN_SERVICES"
              value="true"/>

    <property name="VERSION_FILE"
              value="../../lib/jhall.jar"/>

    <property name="DEFAULT_PROGRAM"
              value="../../bin/asadmin"/>

    <property name="domain"
              value="GlassFish"/>

    <config>
      <option name="domain"
              description="GlassFish Domain"
              default="domain1"/>
      <option name="logpath"
              description="GlassFish Log File (Full Path)"
              default="%installpath%/logs/server.log"/>
      <option name="jmx.url"
              description="JMX URL to MBeanServer"
              default="service:jmx:rmi:///jndi/rmi://localhost:8686/jmxrmi"/>
      <option name="jmx.username"
              description="JMX username"
              optional="true"
              default="admin"/>
      <option name="jmx.password"
              description="JMX password"
              optional="true"
              default="adminadmin"
              type="secret"/>
      <option name="process.query"
              description="PTQL for GlassFish Java Process"
              default="State.Name.eq=java,Args.*.ct=com.sun.aas.instanceRoot"/>
    </config>

    <!-- listen for JMX notifications -->
    <plugin type="log_track"
            class="org.hyperic.hq.product.jmx.MxNotificationPlugin"/>

    <property name="DEFAULT_LOG_FILE"
              value="%logpath%"/>
    <plugin type="log_track"
            class="org.hyperic.hq.product.Log4JLogTrackPlugin"/>

    <!-- derive installpath from -Dcom.sun.aas.instanceRoot... -->
    <property name="PROC_HOME_PROPERTY"
              value="com.sun.aas.instanceRoot"/>

    <plugin type="control"
            class="org.hyperic.hq.product.jmx.MxServerControlPlugin"/>
    <plugin type="autoinventory"
            class="org.hyperic.hq.product.jmx.MxServerDetector"/>
    <plugin type="measurement"
            class="org.hyperic.hq.product.jmx.MxMeasurementPlugin"/>

    <actions include="stop,start"/>

    <property name="start.args"
              value="start-domain %domain%"/>

    <property name="stop.args"
              value="stop-domain %domain%"/>

    <metric name="Availability"
            template="sigar:Type=ProcState,Arg=%process.query%:State"
            indicator="true"/>
    &process-metrics;
    &jvm-jmx-metrics;
    <service name="Global Request Processor">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=GlobalRequestProcessor,name=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Bytes Sent"
              alias="bytesSent"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Bytes Received"
              alias="bytesReceived"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Open Connections"
              alias="countOpenConnections"
              indicator="true"
              category="UTILIZATION"
              collectionType="dynamic"/>
      <metric name="Requests"
              alias="requestCount"
              indicator="true"
              category="UTILIZATION"
              collectionType="trendsup"/>
      <metric name="Errors"
              alias="errorCount"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Processing Time"
              alias="processingTime"
              indicator="false"
              category="UTILIZATION"
              collectionType="trendsup"
              units="ms"/>
    </service>

    <service name="Manager">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=Manager,path=*,host=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Active Sessions"
              alias="activeSessions"
              indicator="false"
              category="UTILIZATION"
              collectionType="dynamic"/>
      <metric name="Sessions"
              alias="sessionCount"
              indicator="false"
              category="UTILIZATION"
              collectionType="trendsup"/>
      <metric name="Rejected Sessions"
              alias="rejectedSessions"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Expired Sessions"
              alias="expiredSessions"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Processing Time"
              alias="processingTime"
              indicator="false"
              category="UTILIZATION"
              collectionType="trendsup"
              units="ms"/>
      <metric name="Duplicates"
              alias="duplicates"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="PWC Connection Queue">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=PWCConnectionQueue,name=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Queued 5 Min Average"
              alias="countQueued5MinuteAverage"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Queued 1 Minute Average"
              alias="countQueued1MinuteAverage"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Queued 15 Minute Average"
              alias="countQueued15MinuteAverage"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Overflows"
              alias="countOverflows"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Total Queued"
              alias="countTotalQueued"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Queued"
              alias="countQueued"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Total Connections"
              alias="countTotalConnections"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="PWC File Cache">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=PWCFileCache,name=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Info Hits"
              alias="countInfoHits"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Misses"
              alias="countMisses"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Content Misses"
              alias="countContentMisses"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Info Misses"
              alias="countInfoMisses"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Entries"
              alias="countEntries"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Content Hits"
              alias="countContentHits"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Hits"
              alias="countHits"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="PWC Keep Alive">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=PWCKeepAlive,name=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Connections"
              alias="countConnections"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Refusals"
              alias="countRefusals"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Timeouts"
              alias="countTimeouts"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Flushes"
              alias="countFlushes"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Hits"
              alias="countHits"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="Servlet">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:j2eeType=Servlet,name=*,WebModule=*,J2EEApplication=*,J2EEServer=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Processing Time"
              alias="processingTimeMillis"
              indicator="false"
              category="UTILIZATION"
              collectionType="trendsup"
              units="ms"/>
      <metric name="Max Time Processing Requests"
              alias="maxTimeMillis"
              indicator="false"
              category="UTILIZATION"
              collectionType="static"
              units="ms"/>
      <metric name="Min Time Processing Requests"
              alias="minTimeMillis"
              indicator="false"
              category="UTILIZATION"
              collectionType="static"
              units="ms"/>
      <metric name="Load Time"
              alias="loadTime"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Class Load Time"
              alias="classLoadTime"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Error Count"
              alias="errorCount"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Request Count"
              alias="requestCount"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="WebModule">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:j2eeType=WebModule,name=*,J2EEApplication=*,J2EEServer=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Time To Start Servlet"
              alias="startTimeMillis"
              indicator="true"
              category="THROUGHPUT"
              collectionType="static"/>
      <metric name="Processing Time"
              alias="processingTimeMillis"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"
              units="ms"/>
      <metric name="Time Scanning Jars for TLDs"
              alias="tldScanTime"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"
              units="ms"/>
    </service>

    <service name="Class Loading System">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:name=class-loading-system,type=*,category=*,server=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Unloaded Class Count"
              alias="unloadedclasscount-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Loaded Class Count"
              alias="loadedclasscount-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Total Loaded Class Count"
              alias="totalloadedclasscount-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
    </service>

    <service name="System Compilation">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:name=compilation-system,type=*,category=*,server=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Total Compilation Time"
              alias="totalcompilationtime-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"
              units="ms"/>
    </service>

    <service name="Connection Queue">
      <plugin type="autoinventory"/>
      <property name="OBJECT_NAME"
                value="com.sun.appserv:type=connection-queue,category=*,server=*"/>
      <metric name="Availability"
              indicator="true"/>
      <metric name="Queued 15 Min Average"
              alias="countqueued15minuteaverage-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Queued 5 Min Average"
              alias="countqueued5minuteaverage-count"
              indicator="false"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Queued 1 Min Average"
              alias="countqueued1minuteaverage-count"
              indicator="false"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Total Queued"
              alias="counttotalqueued-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Total Connections"
              alias="counttotalconnections-count"
              indicator="false"
              category="THROUGHPUT"
              collectionType="trendsup"/>
      <metric name="Queued"
              alias="countqueued-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
      <metric name="Overflows"
              alias="countoverflows-count"
              indicator="true"
              category="THROUGHPUT"
              collectionType="dynamic"/>
    </service>

  </server>

  <!-- ==================== Plugin Help =========================== -->
  <help name="GlassFish">
  <![CDATA[
  <p>
  <h3>Configure HQ for monitoring GlassFish</h3>
  </p>
  <p>
    GlassFish has its own JMX agent to listen for connections.  Therefore there is no
    need to configure jmxremote directly for the java process.  Everything will work
    by default.
  </p>
  ]]>
  </help>
  <help name="GlassFish 9.x" include="GlassFish"/>
</plugin>
