Skip to content

Snippets Library

The Snippets Library provides reusable code templates and patterns for common LogicMonitor scripting tasks.

MethodAction
SidebarClick Snippets tab in the right sidebar
Keyboard ShortcutPress Ctrl+K, L / Cmd+K, L to open directly
Command PalettePress Cmd+Shift+P and type “Snippets”
Snippets panel showing categories and code preview

Complete script starters that replace your entire script content.

Use templates when:

  • Starting a new script from scratch
  • Learning standard script patterns
  • Need a complete working example

BadgeDescription
TemplateComplete script starters that replace your entire script
PatternCode fragments that insert at cursor position

Snippets are language-specific:

  • Groovy snippets for Groovy scripts
  • PowerShell snippets for PowerShell scripts

Use the filter to show only relevant snippets for your current language.

BadgeDescription
Built-inIncluded with LMDA Composer
UserYour custom snippets

  1. Open the Snippets panel from the sidebar

  2. Use filters to narrow by category, language, or type

  3. Click a snippet to preview its full content

  4. Click Insert to add the snippet to your editor


NameDescription
SNMP WalkWalk an SNMP OID tree and process results
HTTP API CollectorMake HTTP API calls and parse JSON response
WMI Query TemplateExecute WMI queries on Windows devices
SSH Command ExecutorRun commands via SSH and collect output

  1. Click Create Snippet in the panel

  2. Fill in required fields:

    • Name: Unique identifier
    • Category: Organization category
    • Language: Groovy or PowerShell
    • Type: Template or Pattern
    • Content: The actual code
  3. Optionally add description and tags

  4. Click Save

// SNMP Walk Pattern
// TODO: Set target OID
def baseOid = "1.3.6.1.2.1.2.2.1"
def host = hostProps.get("system.hostname")
def community = hostProps.get("snmp.community")
def results = Snmp.walk(host, community, baseOid)
results.each { oid, value ->
println "${oid} = ${value}"
}

ActionDescription
EditClick the edit icon on your snippet, modify details, and save
DeleteClick the delete icon and confirm. Deleted snippets cannot be recovered.

Use clear, descriptive names:

  • SNMP_Walk_Interface_Stats
  • HTTP_GET_With_Auth
  • WMI_CPU_Query

Add relevant tags for searchability:

  • Technology: snmp, wmi, http
  • Purpose: discovery, collection
  • Module type: datasource, configsource

  • Create for Repeated Code — If you write similar code often, generalize it with placeholders and save as a snippet
  • Maintain Your Library — Periodically review, update outdated snippets, and remove unused ones
  • Document Your Snippets — Include what it does, required variables, expected output, and limitations
  • Use TODO Markers — Add // TODO: comments where users need to customize the code

Building a new DataSource:

  1. Start with Basic DataSource template

  2. Add SNMP Walk pattern for discovery

  3. Add Instance Output pattern for AD formatting

  4. Add SNMP Get pattern for collection

  5. Customize for your specific use case