Out of curiosity to see how smart or dumb AI is (and perhaps for a little fun), I asked https://chat.openai.com (ChatGPT) the following:
“Using Groovy 2.4, Write a multi-instance LogicMonitor DataSource for VMware NSX-T that exposes each IPsec tunnel as a discrete DataSource instance with the following datapoints: tunnel status, tunnel speed, tunnel transmit Bps, tunnel receive Bps, Tunnel throughput Bps, Tunnel Utilization Percentage, Tunnel Packet Loss Percentage, Tunnel Jitter, Tunnel Latency, Tunnel Mean Opinion Score”
This was the response:
Here's an example of a Groovy 2.4 script for a multi-instance LogicMonitor DataSource for VMware NSX-T that exposes each IPsec tunnel as a discrete DataSource instance with the specified datapoints:
import com.santaba.agent.groovyapi.datasources.*
import com.santaba.agent.groovyapi.execute.*
// Define the credentials to access the NSX-T API
def nsxHost = "nsx-t-hostname"
def nsxUsername = "username"
def nsxPassword = "password"
// Define the API endpoint to retrieve the IPsec tunnels
def endpoint = "/api/v1/ipsec-tunnel"
// Initialize the LogicMonitor DataSource
def ds = new BasicDataSource("NSX-T IPsec Tunnels")
// Set the custom properties for the DataSource
ds.setMultiInstance(true)
ds.addCustomProperty("nsxHost", nsxHost)
ds.addCustomProperty("nsxUsername", nsxUsername)
ds.addCustomProperty("nsxPassword", nsxPassword)
// Define the datapoints to retrieve for each IPsec tunnel
def datapoints = [
"status",
"speed",
"txBps",
"rxBps",
"throughputBps",
"utilizationPercent",
"packetLossPercent",
"jitter",
"latency",
"meanOpinionScore"
]
// Loop through each IPsec tunnel and create a DataSource instance
executeWithApi("nsxt", { api ->
def tunnels = api.get(endpoint)
tunnels.each { tunnel ->
def instanceName = "Tunnel " + tunnel.id
def instance = ds.addInstance(instanceName)
// Set the instance custom properties
instance.addCustomProperty("tunnelId", tunnel.id)
// Add the datapoints to the instance
datapoints.each { datapoint ->
instance.addDatapoint(new SimpleDatapoint(datapoint))
}
}
})
// Save the DataSource
ds.save()