LogicMonitor seeks to disrupt AI landscape with $800M strategic investment at $2.4B valuation to revolutionize data centers.

Learn More

Script Active Discovery

Last updated on 26 November, 2024

LogicMonitor’s pre-defined Active Discovery methods, such as SNMP, WMI, and HTTP, are suitable for most applications. But in some cases you may need to use a script to discover DataSource instances.

Script Active Discovery Approach

Discovering DataSource instances using a script is straightforward. Here’s a high-level overview of what you need to do:

  1. Navigate to the DataSource’s Active Discovery settings, which can be found in the DataSource definition (Settings | LogicModules | DataSources).
  2. From the Discovery method field’s dropdown menu, select “Script”.
  3. Select the scripting language most appropriate for your environment and the device or system in question. Review the Script Collection Types supported by LogicMonitor to determine which is best for your application.
  4. Write a script which retrieves instance identifiers, names, and any other identifying details.
  5. Print the instances data to standard output, one per line.

Please note the following string/character limitations for your script:

  • Wildvalue character limit = 1024
  • Wildvalue cannot contain the following characters: =, :, \, #, space
  • Instance Level Property character limit = 49000
  • Wildalias (Instance name) character limit = 255

Active Discovery Script Output

To ensure instance generation is properly interpreted by the Collector, Active Discovery scripts require output in a specific format. In the simplest case your Active Discovery script needs to return only the instance id and name, with each instance on its own line.

instance1_id##instance1_name
instance2_id##instance2_name

You can optionally add a description to each instance as follows:

instance3_id##instance3_name##instance3_description
instance4_id##instance4_name##instance4_description

Further you may collect instance properties with your Active Discovery script using this syntax:

instance5_id##instance5_name##instance5_description####auto.fooProperty=somevalue&auto.barProperty=anothervalue
instance6_id##instance6_name##instance6_description####auto.fooProperty=thisvalue&auto.barProperty=thatvalue

Script Return Value

Active Discovery will update its list of discovered instances when the script returns an exit code of “0”, indicating that the script execution completed successfully.

It is best practice to ensure values are assigned to the instance level properties and not left blank. In the example below, creating the property auto.fooProperty with a null value will create an error in the discovery task log.

instance6_id##instance6_name##instance6_description####auto.fooProperty=&auto.barProperty=thatvalue

If the script output is empty or malformed, but the script exits with a code of “0”, all previously discovered instances will be removed. To prevent Active Discovery from removing instances in the case of a script error (such as an SNMP timeout), make sure your code is designed to catch such conditions and return a non-zero exit code.

NOTE: Use the Test Active Discovery button to return a table of all instances that would be discovered using the script. This is a good way to ensure that all instances you expect to discover are, in fact, being discovered.

In This Article