Script Active Discovery
IN THIS ARTICLE:
- Introduction to Script Active Discovery
- Script Active Discovery Approach
- Active Discovery Script Output
- Script Return Value
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:
- 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 = 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.
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.