Datasources

Script Active Discovery

Introduction to Script Active Discovery

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. For actual data collection, see our Scripted Data Collection Overview for details on when to use script or batchscript methods. 

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. 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.
  2. Write a script which retrieves instance identifiers, names, and any other identifying details.
  3. 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 = 30,000

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.