Forum Discussion

ronaldmcdonald's avatar
3 years ago

How to get current logicmonitor platform version?

Hello all,

 

Does anyone know how to grab the latest logic monitor platform version with groovy? E.g. the current one is v176 release (https://www.logicmonitor.com/release-notes)

I need it for a post request that I am running on a datasource with groovy.

Any help would be greatly appreciated.

 

Yours Sincerely,

Ronald McDonald

  • Anonymous's avatar
    Anonymous
    3 years ago

    I do this as part of my script that notifies me of LogicModule updates. Some of these include statements are likely not needed if this is all you're doing.

    import org.apache.http.HttpEntity
    import org.apache.http.client.methods.CloseableHttpResponse
    import org.apache.http.client.methods.HttpPost
    import org.apache.http.impl.client.CloseableHttpClient
    import org.apache.http.impl.client.HttpClients
    import org.apache.http.util.EntityUtils
    import javax.crypto.Mac
    import javax.crypto.spec.SecretKeySpec
    import org.apache.commons.codec.binary.Hex
    import org.apache.http.entity.ContentType
    import org.apache.http.entity.StringEntity
    import groovy.json.*
    
    def account = hostProps.get("LogicModule_Updates.company")
    
    def jsondata = new URL("https://${account}.logicmonitor.com/santaba/rest/version").getText()
    def versiondata = new JsonSlurper().parseText(jsondata)
    def version = versiondata.data.version.major ?: "173"

     

  • Anonymous's avatar
    Anonymous

    I do this as part of my script that notifies me of LogicModule updates. Some of these include statements are likely not needed if this is all you're doing.

    import org.apache.http.HttpEntity
    import org.apache.http.client.methods.CloseableHttpResponse
    import org.apache.http.client.methods.HttpPost
    import org.apache.http.impl.client.CloseableHttpClient
    import org.apache.http.impl.client.HttpClients
    import org.apache.http.util.EntityUtils
    import javax.crypto.Mac
    import javax.crypto.spec.SecretKeySpec
    import org.apache.commons.codec.binary.Hex
    import org.apache.http.entity.ContentType
    import org.apache.http.entity.StringEntity
    import groovy.json.*
    
    def account = hostProps.get("LogicModule_Updates.company")
    
    def jsondata = new URL("https://${account}.logicmonitor.com/santaba/rest/version").getText()
    def versiondata = new JsonSlurper().parseText(jsondata)
    def version = versiondata.data.version.major ?: "173"

     

  • Anonymous's avatar
    Anonymous

    Better version:

    import com.santaba.agent.util.Settings
    import groovy.json.*
    
    def account = hostProps.get("lmaccount")?:Settings.getSetting(Settings.AGENT_COMPANY)
    def jsondata = new URL("https://${account}.logicmonitor.com/santaba/rest/version").getText()
    def versiondata = new JsonSlurper().parseText(jsondata)
    println(versiondata.data.version.major)

     

    Just realized i could probably have built this into a webpage type datasource, but i put it in a scripted datasource.

  • 16 minutes ago, Stuart Weenig said:

    I do this as part of my script that notifies me of LogicModule updates. Some of these include statements are likely not needed if this is all you're doing.

    import org.apache.http.HttpEntity
    import org.apache.http.client.methods.CloseableHttpResponse
    import org.apache.http.client.methods.HttpPost
    import org.apache.http.impl.client.CloseableHttpClient
    import org.apache.http.impl.client.HttpClients
    import org.apache.http.util.EntityUtils
    import javax.crypto.Mac
    import javax.crypto.spec.SecretKeySpec
    import org.apache.commons.codec.binary.Hex
    import org.apache.http.entity.ContentType
    import org.apache.http.entity.StringEntity
    import groovy.json.*
    
    def account = hostProps.get("LogicModule_Updates.company")
    
    def jsondata = new URL("https://${account}.logicmonitor.com/santaba/rest/version").getText()
    def versiondata = new JsonSlurper().parseText(jsondata)
    def version = versiondata.data.version.major ?: "173"

    Thank you Stuart, that is exactly what I was looking for.