Welcome to the HyperFORGE

The HyperFORGE was created to facilitate collaboration on plugins and documentation for they Hyperic Community.

Become a HyperFORGE member →

Recent Activity

Skip to end of metadata
Go to start of metadata

Description

This script gets a list of metric data points for resources of a certain type. It returns the result in XML. Useful for asking the question, _'What is the recent Bits Received for all my Cisco IOS resources?'

Works With

HQ 3.2.2 or higher

Running

Simply paste this script into the Groovy Console, and press execute.

Configuration

The best way to see what the valid resource types are, is to navigate find it in the 'Metric Defaults' section.

  • Navigate to the Administration section
  • Select Monitoring Defaults

Names of resource types are listed on the left-side.

Snippet

import org.hyperic.hq.hqu.rendit.util.HQUtil
import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper
import groovy.xml.MarkupBuilder

def resourceType = 'JBoss 4.0 JMS Destination'
def overlord     = HQUtil.overlord
def rhelp        = new ResourceHelper(overlord)
def prototype    = rhelp.findResourcePrototype(resourceType)
def resources    = rhelp.findResourcesOfType(prototype)

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

xml.resources() {
    for (r in resources) {
        xml.resource(name: r.name, id: r.id) {
            for (metric in r.enabledMetrics) {
                def metricData = metric.lastDataPoint
                xml.metric(name: metric.template.name,
                                 value: metricData.value,
                                 time: metricData.timestamp)
            }
        }
    }
}
writer.toString()

Related Files

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.