HQU Create HTTP Snippet

Description

This script allows you to create a new HTTP service check for every platform within a group called "All Platforms". Each new check will be an HTTP service, setup to ping the HTTP socket on that platform.

Works With

HQ 3.2.2 or higher

Running

Simply paste this script into the Groovy Console, change the port, path, and any other configuration you like (such as the group's name), and press execute.

Configuration

The best way to see what the valid configuration options are, is to create an HTTP service yourself and look at its properties.

Snippet

import org.hyperic.hq.hqu.rendit.util.HQUtil
import org.hyperic.hq.hqu.rendit.helpers.ResourceHelper

def resourceTypeName = 'HTTP'
def groupName = 'All Platforms'

def overlord     = HQUtil.getOverlord()
def rhelp        = new ResourceHelper(overlord)
def resourceType = rhelp.findResourcePrototype(resourceTypeName)
def group        = rhelp.findViewableGroups().find { it.name == groupName }

if (resourceType == null) {
    return "Resource type ${resourceTypeName} not found"
} else if(group == null) {
    return "Group ${groupName} not found"
}


def created = []
group.getResources().each { platform ->
    def newName = "${platform.name} HTTP 7080"
    // Don't create resources if they already exist
    if (platform.getChildrenByPrototype(resourceType).find { it.name == newName})
        return

    def newService = resourceType.createInstance(platform,  newName, overlord, 
                                                 [hostname  : platform.config.fqdn.value,
                                                  port      : '7080',
                                                  sotimeout : '5',    /* socket timeout (sec) */
                                                  path      : '/'])
    created << newService
}

"Created ${created.name}"

Related Files


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced
- Activity

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

or Sign Up  

Other Features

Add Content


System Monitoring Software
SourceForge.net Logo