Forum Discussion
FYI, you don't need any of those imports. You're not using any of them, so importing them is a waste of CPU cycles.
Thanks for the tip, I didn't actually know that.
- Anonymous8 months ago
Yeah, whenever you start a new DS, the UI inserts all the most common imports at the beginning of the script, whether you need them or not. In almost every case, you only need one not the others. It would be actually helpful if LM could prompt you for how you need to collect data and start the script. For example, if you know you need to SSH into a device and execute a command, it would be nice for it to start with a script like this:
import com.logicmonitor.common.sse.utils.GroovyScriptHelper as GSH import com.logicmonitor.mod.Snippets def azureHost = hostProps.get("auto.network.resolves") == "false" ? hostProps.get("system.azure.privateIpAddress") : null def loader = GSH.getInstance()._getScript("Snippets", Snippets.getLoader()) def remote = loader.load("lm.remote", "0").create(hostProps) .withHost(azureHost ?: hostProps.get("system.hostname")) .withTimeout(15000) def debug = false // To run in debug mode, set to true try { def command_output = remote.exec('echo YOUR COMMAND HERE') println(command_output) return 0 } catch (Exception e) {println(e);return 1}
This is the skeleton of most of LM's own Linux SSH scripts since they made a snippet that can be imported to do most of the tricky stuff. I'm sure the ME team has a bunch of monitoring recipes that can be used as starters for many scripted datasources. It would be nice if we could walk through a wizard that helps us find a template to get started with (or at least let us browse a repo through the UI and select a template to start with).
Related Content
- 9 months ago
- 2 years ago