<?xml version="1.0"?>

<!--
  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 name="resin">
    <classpath>
        <include name="pdk/lib/mx4j"/>
    </classpath>

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

    <!-- Generic 3.x type is known to work with 3.0.20, 3.0.21, and 3.0.22. -->
    <server name="Resin"
            version="3.x"
            description="Resin 3.x">

        <property name="OBJECT_NAME"
                  value="resin:type=Server"/>

        <property name="PROC_MAIN_CLASS"
                  value="com.caucho.server.resin.Resin"/>

        <property name="PROC_HOME_PROPERTY"
                  value="resin.home"/>

        <!-- Availability mappings -->
        <property name="State.active" value="1.0"/>
        <property name="State.stopped" value="0.0"/>
        <property name="State.stopped-lazy" value="-0.01"/>

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

        <plugin type="control"
                class="org.hyperic.hq.product.jmx.MxControlPlugin"/>

        <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"/>

        <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="system"/>

            <option name="jmx.password"
                    description="JMX password"
                    optional="true"
                    default="manager"
                    type="secret"/>
        </config>

        <properties>
            <property name="RedeployMode" description="Redeploy Mode"/>
            <property name="Id" description="Server Id"/>
            <property name="SelectManagerEnabled" description="Select Manager Enabled"/>
            <property name="StartupMode" description="Startup Mode"/>
        </properties>

        <actions include="stop,start,update,restart"/>

        <metric name="Availability"
                template="${OBJECT_NAME}:State"
                indicator="true"/>

        <metric name="Invocation Cache Hit Count"
                alias="InvocationCacheHitCountTotal"
                collectionType="trendsup"/>

        <metric name="Invocation Cache Miss Count"
                alias="InvocationCacheMissCountTotal"
                collectionType="trendsup"/>

        <metric name="Keepalive Count"
                alias="KeepaliveCountTotal"
                collectionType="trendsup"/>

        <metric name="Request Count"
                alias="RequestCountTotal"
                collectionType="trendsup"
                indicator="true"/>

        <metric name="Request Read Bytes"
                alias="RequestReadBytesTotal"
                collectionType="trendsup"
                units="b"
                indicator="true"/>

        <metric name="Request Time"
                alias="RequestTimeTotal"
                collectionType="trendsup"
                units="ms"/>

        <metric name="Request Write Bytes"
                alias="RequestWriteBytesTotal"
                collectionType="trendsup"
                units="b"
                indicator="true"/>

        <metric name="Runtime Memory"
                units="b"/>

        <metric name="Runtime Memory Free"
                units="b"/>

        <metric name="Thread Active"
                alias="ThreadActiveCount"
                indicator="true"/>

        <metric name="Thread Keepalive"
                alias="ThreadKeepaliveCount"/>

        <service name="Port">
            <property name="OBJECT_NAME"
                      value="resin:type=Port,name=*"/>
            <config>
                <option name="name"
                        description="Port name"/>
            </config>

            <properties>
                <property name="Address" description="Address"/>
                <property name="ProtocolName" description="Protocol"/>
                <property name="ConnectionMax" description="Max Connections"/>
                <property name="KeepAliveMax" description="Max Keepalives"/>
                <property name="Port" description="Port"/>
                <property name="SSL" description="SSL Enabled"/>
                <property name="SelectKeepaliveCount"
                          description="Select Keepalive"/>
            </properties>

            <plugin type="autoinventory"/>

            <!-- Availability mappings -->
            <property name="State.active" value="1.0"/>
            <property name="State.stopped" value="0.0"/>
            <property name="State.stopped-lazy" value="-0.01"/>

            <metric name="Availability"
                    template="${OBJECT_NAME}:State"
                    indicator="true"/>

            <metric name="Client Disconnect Count"
                    alias="ClientDisconnectCountTotal"
                    collectionType="trendsup"/>

            <metric name="Keepalive Count"
                    alias="KeepaliveCountTotal"
                    collectionType="trendsup"/>

            <metric name="Read Bytes"
                    alias="ReadBytesTotal"
                    collectionType="trendsup"
                    units="b"
                    indicator="true"/>

            <metric name="Write Bytes"
                    alias="WriteBytesTotal"
                    collectionType="trendsup"
                    units="b"
                    indicator="true"/>

            <metric name="Request Count"
                    alias="RequestCountTotal"
                    collectionType="trendsup"
                    indicator="true"/>

            <metric name="Request Time"
                    alias="RequestTimeTotal"
                    collectionType="trendsup"
                    units="ms"/>

            <metric name="Thread Active Count"/>

            <metric name="Thread Count"/>

            <metric name="Thread Idle Count"/>

            <metric name="Thread Keepalive Count"/>

        </service>

        <service name="Connection Pool">
            <property name="OBJECT_NAME"
                      value="resin:type=ConnectionPool,Host=*,WebApp=*,name=*"/>
            <config>
                <option name="Host"
                        description="Connection Pool Host"/>
                <option name="WebApp"
                        description="Connection Pool WebApp"/>
                <option name="name"
                        description="Connection Pool name"/>
            </config>

            <properties>
                <property name="MaxConnections" description="Max Connections"/>
                <property name="MaxActiveTime" description="Max Active Time"/>
                <property name="MaxCreateConnections" description="Max Create Connections"/>
                <property name="MaxIdleTime" description="Max Idle Time"/>
                <property name="MaxOverflowConnections" description="Max Overflow Connections"/>
                <property name="MaxPoolTime" description="Max Pool Time"/>
            </properties>

            <plugin type="autoinventory"/>

            <!-- No state attribute, use existance of MBean -->
            <metric name="Availability"
                    indicator="true"/>

            <metric name="Connection Active Count"
                    indicator="true"/>

            <metric name="Connection Count"
                    indicator="true"/>

            <metric name="Connection Idle Count"
                    indicator="true"/>

        </service>

        <service name="Webapp">
            <property name="OBJECT_NAME"
                      value="resin:type=WebApp,Host=*,name=*"/>

            <!-- Availability mappings -->
            <property name="State.active" value="1.0"/>
            <property name="State.stopped" value="0.0"/>
            <property name="State.stopped-lazy" value="-0.01"/>

            <config>
                <option name="Host"
                        description="Host"/>
                <option name="WebApp"
                        description="WebApp"/>
                <option name="name"
                        description="name"/>
            </config>

            <properties>
                <property name="RedeployMode" description="Redeploy Mode"/>
                <property name="StartupMode" description="Startup Mode"/>
            </properties>

            <plugin type="autoinventory"/>

            <metric name="Availability"
                    template="${OBJECT_NAME}:State"
                    indicator="true"/>

            <metric name="Client Disconnect Count"
                    alias="ClientDisconnectCountTotal"/>

            <metric name="Request Count"
                    alias="RequestCountTotal"
                    collectionType="trendsup"
                    indicator="true"/>

            <metric name="Request Read Bytes"
                    alias="RequestReadBytesTotal"
                    collectionType="trendsup"
                    units="b"
                    indicator="true"/>

            <metric name="Request Time"
                    alias="RequestTimeTotal"
                    collectionType="trendsup"
                    units="ms"/>

            <metric name="Request Write Bytes"
                    alias="RequestWriteBytesTotal"
                    collectionType="trendsup"
                    units="b"
                    indicator="true"/>

            <plugin type="control"/>

            <actions include="start,stop,update,restart"/>

        </service>

    </server>

    <help name="Resin 3.x">
    <![CDATA[
    <p>
      <h3>Configure Resin ${product.version} for Monitoring</h3>
    </p>

    <p>
    To enable monitoring of Resin servers and services the Resin server
    must be run with Java 1.5, and have the remote JMX connector enabled.
    To enable the connector 2 steps must be taken.
    </p>

    <p>
    <b>Configure JMX connector within the JDK</b>
    </p>
    <p>
    Sun has <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#PasswordAccessFiles">
    extensive documentation</a> on how to setup users and permissions for remote
    monitoring and management.
    </p>

    <p>
    If you plan on controlling Resin resources through HQ, the user must have
    <b>readwrite</b> access defined in the access file.
    </p>

    <p>
    <b>Enable JMX connector within Resin</b>
    <p>
    To enable monitoring and management of Resin, set this property when starting
    the server:
    </p>

    <p>
    <code>
    com.sun.management.jmxremote.port=portNum
    </code>
    </p>

    <p>
    Where portNum is the port number through which you want to enable the JMX/RMI
    connections.  Within Resin's httpd.sh script there is an args parameter that
    can be used to pass additional arguments to the JVM when starting up.  For
    example:
   </p>

    <p>
    <code>
    args=-Dcom.sun.management.jmxremote.port=1099
    </code>
    </p>
    ]]>
  </help>

</plugin>
