• 0
Vitor Santos

Tegile IntelliFlash - API - Datasources?

Question

Posted (edited)

Hello,

We're monitoring a lot of Tegile device(s) via SNMP (making use of the OOB datasources, however, those fail quite often). 
This is happening for the majority of our clients & after our NOC opened a case with Tegile directly (they stated there's a bug when using SNMP on the MGMT IP).

Having that in mind, I started leveraging the possibility of using Tegile API instead of SNMP.

Searched through the Exchange but found none developed yet. My idea would be replace the SNMP with API ones.
I've found their documentation about API calls but, actually requires some help to put that into Groovy.

I'm able to do it in Python, but, Groovy is the way to go on LM.


Added their documentation related with the REST API to my github for everyone to see it -> https://github.com/vitor7santos/RestAPI_docs

Can someone perhaps help me out on how to do a simple API call into those on Groovy?

 

 

Edited by Vitor Santos

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

@Vitor Santos, looks like their API uses Basic Auth, so it should be fairly trivial to make simple calls with our built-in HTTP library, and parse the JSON with JSON Slurper:

 

import com.santaba.agent.groovyapi.http.HTTP
import groovy.json.JsonSlurper

hostname = hostProps.get("system.hostname")
port = hostProps.get("api.port")
user = hostProps.get("api.user")
pass = hostProps.get("api.pass")

httpClient = HTTP.open(hostname, 443, true)
httpClient.setAuthentication(user, pass)

/*
 * This helper function handles any HTTP GETs.
 */

def httpGET(endpoint) {

    httpClient.get(endpoint)

    if (httpClient.getStatusCode() == 200) {

        return new JsonSlurper().parseText(httpClient.getResponseBody())
    } else {
        println "STATUS CODE:\n${httpClient.getStatusCode()}\n\nRESPONSE:\n${httpClient.getResponseBody()}"
    }
}

/////// Your Code:

def alarms = httpGET("/alarms")

println(alarms.json_property_you_want_to_access)


return 0;

Basically, you use HTTP.open to connect, setup the auth. We define a helper function to make GET requests and pass the body to JsonSlurper so you end up with a parsed object you can iterate over and print from.

Share this post


Link to post
Share on other sites
  • 0

Hello Michael, 

Thanks for you reply!

I was able to do it in the meanwhile (started reading the documentation and trying out on Groovy) & ended up getting it.

I'm working on trying to do the same monitoring (via API) that we're currently doing using SNMP (there's some limitations but, I believe we can do it).
I'll post here my data sources once I've finished them (in order for you guys to view/correct/make use of).

Share this post


Link to post
Share on other sites
  • 0

Ok, I finished the datasources we need & I believe it looks nice.
Deployed those within all the Tegile devices & it seems to work nice.

I was trying to create a package out of those (to further deploy it within Exchange) but, Exchange seems to be weird today. I can't even commit those to our rep.

Anyone else facing issues?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.