ContributionsMost RecentMost LikesSolutionsHow to post an API key on a header with the post() method using Groovy? I'm trying to write a script in Groovy that makes an API request to check the status of VPN tunnels. I've been trying the implement the post() method from the HTTP library to update the header of the url with the API key. I keep running into an error "no signature on method". This is my code so far. import com.santaba.agent.groovyapi.http.*; ip = "api-mp.meraki.com"; httpClient = HTTP.open(ip, 443); url = "https://"+ip+"/api/v1/organizations/999999/appliance/vpn/statuses"; def postResponse = httpClient.post(url,["X-Cisco-Meraki-API-Key":"ApiKey"]); I just followed the example from this tutorial: https://www.logicmonitor.com/support/terminology-syntax/scripting-support/access-a-website-from-groovy I'm wondering if I'm getting the error because I'm not inserting a payload in my method. But I don't have a payload... I'm just trying to update the header. 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. Re: Need help trying to figure out this DataSource I found online. 2 hours ago, mnagel said: It will use whatever you provide. If it is a name and the collector can resolve the name, then it should work. I just looked at the code and I don't see where it would have emitted sftp:// at all -- that is a URL format and it wants just the hostname (or IP). If you included sftp:// in the hostname, please remove it :). def session = jsch.getSession(user, host, port.toInteger()); // Get a session session.setPassword(pass) // Set the password to use for the session Thank you so much. I was able to script to connect to the sftp site. Re: Need help trying to figure out this DataSource I found online. 2 hours ago, mnagel said: If that is literally what came out of the script, it sounds like the hostname is being confused with the password. If that is not the issue, I would add debugging statements to the code and exit 1 to ensure they are printed when you run Poll Now. I just used the asterisks to hide the name of my sftp site. What it actually printed out was the name of the sftp site that I used for the host property. I tried debugging with print statements, and it looks like the code fails at session.connect(). Am I supposed to be using an IP address for the host? Or the actual name? Do I need to make sure something is installed on my collector for the script to make the sftp connection? THanks for your help. Re: Need help trying to figure out this DataSource I found online. On 7/31/2020 at 3:12 PM, mnagel said: The strings are host properties, so set them on the collector you want to run this from. Those would have to be bound to a collector host. As written, that supports only a single remote SFTP test. If you wanted to do more, you would need to rewrite that to handle instances either manual or active discovery. I do the latter often even with a manual property list as it is the only way to define automatic instance properties. It may be possible to do this via an internal "website" check, but I have not tried going full groovy on those yet :). Even then, each would be a separate copy of code, so better to use this and perhaps extend to support multiple checks. Hi mnagel. I set the host properties on the collector, and when I test the script, I return the following: com.jcraft.jsch.JSchException: java.net.UnknownHostException: sftp://******** That sftp site is what I'm using for the sftp.site host property. That's the host I always use to connect to my sftp site, but it looks like it's not working. For science, I checked to make sure that I could connect to the sftp site directly from my collector host, and I successfully able to. Re: Need help trying to figure out this DataSource I found online. Hi mnagel. I set the host properties on the collector, and when I test the script, I return the following: com.jcraft.jsch.JSchException: java.net.UnknownHostException: sftp://******** That sftp site is what I'm using for the sftp.site host property. That's the host I always use to connect to my sftp site, but it looks like it's not working. For science, I checked to make sure that I could connect to the sftp site directly from my collector host, and I successfully able to. Need help trying to figure out this DataSource I found online. Hey everyone. I found this DataSource online that monitors if an SFTP connection is working. The source is here: blog.mikesuding.com/2017/04/08/monitor-sftp-site-connection-and-login/ Unfortunately, I haven't been able to get the groovy script working. There's not much documentation that comes with the script. The only info it provides says to set the sftp.site = wowie.us, sftp-user = mike, sftp-pass = ***. Now, I'm sure that I'm supposed to using my OWN sftp site, my OWN sftp user, and my OWN sftp pass, but I could be wrong. The other thing I'm confused about is where In the groovy script I'm supposed to change these properties. Inside the "Applies To" textfield, it's automatically populated with sftp.site && sftp.user && sftp.pass, but isn't this field supposed to be for the device that you want the datasource attached to? If it's asking me to substitute the variables here, then how do I do that? I'm unsure of the syntax. There's also a few function calls in the groovy script. def host = hostProps.get("sftp.site") def user = hostProps.get("sftp.user") def pass = hostProps.get("sftp.pass") def port = hostProps.get("port") ?: '22'; It seems reasonable that this is where I want substitute my own sftp credentials. Of course, when I do this and run it, I return a error that says "Host cannot be NULL". Something is breaking, and I don't know what it is.
Top ContributionsMonitoring an IPSec tunnel in LM?How to post an API key on a header with the post() method using Groovy?Re: Need help trying to figure out this DataSource I found online.Re: Need help trying to figure out this DataSource I found online.Re: Need help trying to figure out this DataSource I found online.Re: Need help trying to figure out this DataSource I found online.Need help trying to figure out this DataSource I found online.