Support Center Home

Embedded Groovy Scripting

LogicMonitor supports embedded scripting throughout our product using the Groovy programming language. Groovy can be used in Datasources for Scripted Active Discovery, Scripted Data Collection, and Complex Datapoint Post-Processing; in Scripted EventSources; ConfigSources; and Netscan Policies.

We favor Groovy primarily because – as an extension of Java – it is run entirely within the LogicMonitor Collector, so we can guarantee that it will run the same way across all collectors regardless of underlying OS platform and version. Also, we’ve bundled into our Collector a wide variety of helper classes specifically selected to help get instrumentation data out of systems & devices.

Using Device & Instance Properties in Groovy Scripts

Another advantage of Groovy is that we support the use of any device or instance property within your script. In other languages we can pass in device properties but not instance properties.

The following methods support ingest of properties.

  • hostProps.get() – return the specified device property. e.g. name = hostProps.get(“system.hostname”);
  • instanceProps.get() – return the specified instance property e.g. instance = instanceProps.get(“wildvalue”)
  • taskProps.get() – return the specified property from either the device property or instance property table; in case of a property name collision, return the value set at the instance level e.g.  speed=taskProps.get(“speed”) will get the value of the speed property if set on the instance; else if it is not set it will get the value set on the device.

Example – Using Groovy for Datasource Active Discovery

The following is sample Groovy code used to perform Scripted Active Discovery. In scripted Active Discovery, the goal is to return instance data of the form:


This particular script is used by the PaloAlto_FW_Power DataSource to discover power source instances:

import com.santaba.agent.groovyapi.http.*;

apikey = hostProps.get("paloalto.apikey.pass")
host = hostProps.get("system.hostname")

command ="")
url = "https://${host}/api/?type=op&key=${apikey}&cmd=${command}"

def response = new XmlSlurper().parseText(HTTP.body(url))

// loop through slots
response.result.power.children().each { slot ->
  slot_name =

  // loop through each slot's components
  slot.entry.each { entry ->
    entry_desc    = entry.description.text()
    instance_name = slot_name + '/' + entry_desc
    println "${instance_name}##${instance_name}"


See our pages on Groovy Tips & Tricks and Groovy/Expect Text-Based Interaction for more examples and sample code.

In This Article