Script Active DiscoveryLast updated on 07 November, 2022
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:
- Navigate to the DataSource’s Active Discovery settings, which can be found in the DataSource definition (Settings | LogicModules | DataSources).
- From the Discovery method field’s dropdown menu, select “Script”.
- 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.
- Write a script which retrieves instance identifiers, names, and any other identifying details.
- 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
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.
You can optionally add a description to each instance as follows:
Further you may collect instance properties with your Active Discovery script using this syntax:
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.
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.