Blog Post

Tech Talk

Sample Webcheck via Groovy Scripts to test-out!!!

Persie's avatar
Icon for LM Champion rankLM Champion
10 months ago

In LM tool, you can choose to manually add your request and response Groovy scripts directly into the text boxes found under both of these Script tabs or, as shown next, you can choose to first complete the fields under the Settings tab (e.g. HTTP VersionMethodFollow redirectAuthentication RequiredHeadersHTTP Response Format, etc.) and then click the Generate Script from Settings button to have LogicMonitor auto-generate request and response scripts based on those settigs.

The latter option produces a basic template for your Groovy scripts. (For more information on completing the fields found under the Settings tab for both the HTTP request and response, see Adding a Web Check).

So with LM platform tool, you can also auto-generate request and response scripts script as shown in above screenshot.

Now here is an sample script to providing a code snippet in Groovy that's using the Santaba HTTP library to make an HTTP GET request to a specified URL (in this case, "") and retrieve headers from the response. Additionally, it appears to set basic authentication credentials for the request.

The script here is just for reference, to test the scripted HTTP responses.This code block here is the part which makes the http get to google

Here's a breakdown of your code:

import com.santaba.agent.groovyapi.http.*;

// Instantiate an http client object for the target system
httpClient =;

// Set basic authentication credentials
httpClient.setAuthentication("myusername", "mypassword");

// Specify the URL
url = "";

// Perform an HTTP GET request
def getResponse = httpClient.get(url);

// Get headers from the response
headers = httpClient.getHeaders();

// Close the http client

Alternatively you can leverage the LM tool to monitored the Few things to note for the code here :

  • The code appears to be setting basic authentication credentials (myusername and mypassword), but it's important to note that sending credentials in plaintext might not be secure. Consider using HTTPS and more secure authentication methods if available.

  • The code is making an HTTP GET request to the specified URL ("") and storing the response in the getResponse variable.

  • After the request, the code retrieves headers from the response using httpClient.getHeaders() and stores them in the headers variable.

  • Finally, the HTTP client is closed using httpClient.close().

Link for more references :

Keep Learning & Keep Exploring with LM !!!!!!

Interested in learning more about features of your LogicMonitor portal?

Published 10 months ago
Version 1.0
No CommentsBe the first to comment