<!--
  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.
 -->

<!-- Auto-discover services using SQL and collect SMTP metrics -->
<plugin>
  <classpath>
    <!-- for SQLQueryDetector -->
    <include name="pdk/plugins/sqlquery-plugin.jar"/>
    <!-- for JDBC drivers -->
    <include name="pdk/lib/jdbc"/>
  </classpath>

  <server name="Mail Host">
    <!-- use the postgres process query to auto-discover the server -->
    <!-- postgres on OS X, postmaster elsewhere -->
    <property name="PROC_QUERY" value="State.Name.re=post(gres|master)"/>

    <!-- default properties -->
    <property name="jdbcUrl"
              value="jdbc:postgresql://localhost/hq?protocolVersion=2"/>
    <property name="jdbcDriver" value="org.postgresql.Driver"/>
    <property name="jdbcUser" value="dougm"/>
    <property name="jdbcPassword" value="dougm"/>

    <!-- config defined by the sqlquery plugin -->
    <config include="sql"/>

    <plugin type="measurement"
            class="org.hyperic.hq.product.MeasurementPlugin"/>

    <plugin type="autoinventory"
            class="org.hyperic.hq.plugin.sqlquery.SQLQueryDetector"/>

    <!-- "sql:" domain required to proxy through sqlquery-plugin -->
    <filter name="template" value="sql:${query}:${name}"/>

    <!-- use filters for common sql -->
    <filter name="count"
            value="SELECT COUNT(*) FROM"/>

    <metric name="Availability"
            query="${count} MAILHOSTS WHERE 1=1"
            indicator="true"/>

    <metric name="Number of Servers"
            query="${count} MAILHOSTS"
            indicator="true"/>

    <service name="SMTP">
      <plugin type="autoinventory"/>

      <config>
        <option name="hostname"
                description="Mail Server Hostname"
                default="localhost"/>
      </config>

      <property name="jdbcQuery"
                value="SELECT hostname, description FROM MAILHOSTS"/>

      <!-- format for auto-discovered services -->
      <property name="AUTOINVENTORY_NAME" value="Mail server %hostname% (%description%)"/>

      <!-- collect SMTP metrics via the netservices plugin -->
      <filter name="template"
              value="SMTP:hostname=%hostname%:${alias}"/>

      <metric name="Availability"
              indicator="true"/>

      <metric name="Inbound Connections"
              indicator="true"/>

      <metric name="Outbound Connections"
              indicator="true"/>
    </service>
  </server>
</plugin>
