Forum Discussion

SmokinIndo's avatar
5 years ago

Monitoring an IPSec tunnel in LM?

Good morning everyone. I've been searching for ways to monitor an IPSec tunnel in LM, but so far I've been unable to find any articles on how to do this. We have a Meraki security device. The Meraki out-of-the-box LM modules do not come with a way to monitor S2S. It would greatly help out our IT team if we could receive a notification on whether or not one of our tunnels is misbehaving in LM. 

  • @Stuart Weenig, I rephrased my question as:

    ​​​​​​Using Groovy 2.4, write the discovery and collection scripts for 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.

    Below is the response:
    ​​​

    Here's an example of a Groovy 2.4 script for the discovery and collection of a multi-instance LogicMonitor DataSource for VMware NSX-T that exposes each IPsec tunnel as a discrete DataSource instance with the specified datapoints:

    Discovery script:
    ​​​​​​import com.santaba.agent.groovyapi.datasources.*
    import com.santaba.agent.groovyapi.execute.*

    // Define the credentials to access the NSX-T API
    def nsxHost = "${nsxHost}"
    def nsxUsername = "${nsxUsername}"
    def nsxPassword = "${nsxPassword}"

    // Define the API endpoint to retrieve the IPsec tunnels
    def endpoint = "/api/v1/ipsec-tunnel"

    // Define the datapoints to retrieve for each IPsec tunnel
    def datapoints = [
        "status",
        "speed",
        "txBps",
        "rxBps",
        "throughputBps",
        "utilizationPercent",
        "packetLossPercent",
        "jitter",
        "latency",
        "meanOpinionScore"
    ]

    // 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)

    // Retrieve the list of IPsec tunnels and create a DataSource instance for each tunnel
    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()
     

    Collection Script:
    ​​​​​​

    import com.santaba.agent.groovyapi.datasources.*
    import com.santaba.agent.groovyapi.execute.*
    import com.santaba.agent.groovyapi.http.*

    // Retrieve the custom properties for the DataSource
    def nsxHost = "${nsxHost}"
    def nsxUsername = "${nsxUsername}"
    def nsxPassword = "${nsxPassword}"

    // Retrieve the API endpoint for the specified IPsec tunnel
    def getEndpoint = { tunnelId ->
        "/api/v1/ipsec-tunnel/${tunnelId}"
    }

    // Retrieve the datapoint values for the specified IPsec tunnel
    def getData = { tunnelId ->
        def datapoints = [
            "status",
            "speed",
            "txBps",
            "rxBps",
            "throughputBps",
            "utilizationPercent",
            "packetLossPercent",
            "jitter",
            "latency",
            "meanOpinionScore"
        ]

        def values = [:]

        executeWithApi("nsxt", { api ->
            def endpoint = getEndpoint(tunnelId)
            def tunnel = api.get(endpoint)

            datapoints.each { datapoint ->
                values[datapoint] = tunnel[datapoint]
            }
        })

        values
    }

    // Loop through each IPsec tunnel and collect its datapoints
    executeWithApi("nsxt", { api ->
        def tunnels = api.get("/api/v1/ipsec-tunnel")
        tunnels.each { tunnel ->
            def instanceName = "Tunnel " + tunnel.id
            def instance = findDataSourceInstance(dsName, instanceName)

            if (instance != null
     

  • Anonymous's avatar
    Anonymous

    Meh, the discovery script looks like it’s trying to create the datasource, not create the instance output required for the discovery. 

    The collection script seems incomplete. @Patrick Rouse , try embedding the code using the code widget. Will make it easier to read. 

    Since the santaba libraries are not documented (except for self documentation), it would be difficult to know exactly what it’s trying to save with the ds.Save() statement.