Show TOC

 Installing the Template-Based MonitorsLocate this document in the navigation structure

Procedure

Recall the monitor-configuration excerpt from the Installing the Template section, where there were two template-installable monitors described:

The Amount Integer Monitor
  1. BankMBean:
    public int getExceededClientsMoney(String clientName);
  2. Bank:
    public int getExceededClientsMoney(String clientName) {
         return transaction.getExceededClientsMoney(clientName);
    }

    Given a client name, this method returns the exact amount of money for his/her transaction.

  3. Modify the monitor-configuration.xml:
    1. Define the monitor-semantics:
      <integer-configuration-group name="ExceededClientsMoney" unit="EUR">
          <description ID="Exceeded clients money">Money ammount for the exceeded clients.</description>
          <data-collection>
         <polled-by-monitor period="1" unit="MINUTE"/>
          </data-collection>
          <thresholds green-to-yellow="9999" yellow-to-red="1" red-to-yellow="1" yellow-to-green="9999"/>
      </integer-configuration-group>
    2. Define the monitor-tree:
      <integer-monitor name="Amount" configuration-group="ExceededClientsMoney">
          <monitored-resource name="BankMBean" type="APPLICATION"/>
          <integer-attribute-mapping>
              <integer-attribute>
                  <invoked-resource-method name="getExceededClientsMoney">
             <parameter position="0" type="String" value="%0"/>
         </invoked-resource-method>
              </integer-attribute>
          </integer-attribute-mapping>
      </integer-monitor>

    As you can see, for the information that cannot be supplied statically, the placeholder sign "%" is used.

Result

The Amount monitor appears in the monitoring tree under Applications → Bank Information → List of txs over 10,000 EUR → Transaction No:<xx>.

The Transaction duration Long Monitor Named
  1. BankMBean:
    public long getTransactionDuration(String clientName);
  2. Bank:
    public long getTransactionDuration(String clientName) {
       return transaction.getTransactionDuration(clientName);
    }

    Given a client name, this method returns the duration of his/her transaction.

  3. Modify the monitor-configuration.xml:
    1. Define the monitor-semantics:
      <long-configuration-group name="tsDuration" unit="ms">
          <description ID="Transaction duration">Duration of the transaction of this client.</description>
          <data-collection>
              <polled-by-monitor period="1" unit="MINUTE"/>
          </data-collection>
          <thresholds green-to-yellow="10000" yellow-to-red="14000" red-to-yellow="14000" yellow-to-green="10000"/>
      </long-configuration-group>
    2. Define the monitor-tree:
      <long-monitor name="Transaction duration" configuration-group="tsDuration">
          <monitored-resource name="BankMBean" type="APPLICATION"/>
          <long-attribute-mapping>
              <long-attribute>
                  <invoked-resource-method name="getTransactionDuration">
             <parameter position="0" type="String" value="%0"/>
          </invoked-resource-method>
              </long-attribute>
          </long-attribute-mapping>
      </long-monitor>

    Again, the placeholder sign "%" is used to denote the dynamically supplied data.

Result

The Transaction duration monitor appears in the monitoring tree under Applications → Bank Information → List of txs over 10,000 EUR → Transaction No:<xx>.