Testing groovy script on local ubuntu machine
I am searching for a way to run groovy scripts on my local ubuntu (WSL) while being able to work with the same classes that are used by the collectors. To achieve this I installed a java+groovy and deployed a collector. However I am unable to import the classes like“com.santaba.agent.groovyapi.snmp.Snmp” Is there any way to achieve this? Or can I somehow locally access the collector shell to test groovy code without the need to use the LM web UI? So, I am basically searching for a way to develop scripted DataSources using CLI, without fiddling with the web UI. Any guidance very much appreciated.Solved159Views17likes9CommentsOracle jdbc JAR file update
LogicMonitor's collector utilizes an outdated version of the Oracle JDBC jar file. It's essential to upgrade to the most recent version available in the Maven repository to take advantage of new secure database connection types. However, users should note a significant change in behavior with the new jar: while the old version automatically closed abandoned Oracle database connections, the new version does not, potentially leading to an excessive number of open connections. This surge in open connections can overload and crash an Oracle server where connections aren’t limited by user. Therefore, clients must either ensure that customizations explicitly close database connections or adjust their server settings to impose limits on the number of concurrent open connections. All of the newest Logicmonitor datasources properly close connections but some of the older modules did not do this. Logicmonitor has created a module to test for this problem and alert if it occurs. Oracle_Database_MonitorUser will keep track of the number of connections in use by the monitoring user and alert if the number of connections is too high. This update is scheduled for collector 35.400. Make sure this module is installed before upgrading to collect 35.400 and monitor your database connections before rolling this out to general release.63Views15likes0CommentsRunning a Perl script on an AIX box over SSH?
Hi, We have an old monitoring system that we’re trying to decommission and move everything into LM. The current system connects to an AIX server using an SSH Key, and then runs a perl script that’s located in a particular folder. It then takes the output from that script and determines if there’s an alert condition to tell someone about. I need to move this same functionality into LM. I’m assuming the SSH access part shouldn’t be a big deal. I can either manually setup a username/password or I found into on putting a key in LM somewhere and using that. Once LM can connect to the server, can it launch a script file that’s located on the server? I’m not sure if I need to recreate the script inside of LM, or if it can just tell the server to execute the script it already has. If the script runs remotely, can LM then parse the returned data to determine if something is an error or not? If anyone has any tutorials or anything on how I can start working on this, let me know. I don’t know anything about scripting and LM and so far, don’t really know where to start. Thanks!Solved74Views15likes1CommentEntering enable mode using JSch
Does anybody have any example code on how to enter enable mode when using JSch? I already have the script working for 95% of my devices, so i don’t want to have to switch to expect. The channel mode is currently exec, which i think is the issue. It’s trying to execute `enable\n${enable_pass}\n${cmd}` all at once and the device is choking on it. Would rather not have to switch to shell mode, but if there’s no way to do it without shell mode, i guess i’ll have to take a stab at it.Solved133Views13likes3CommentsSAP_HANA_SystemDatabaseAvailability Test DataSource Script failed
I have a wrong Java environment ? The script failed, elapsed time: 21 seconds - Unable to load Snippet - lm.emit java.lang.Exception: Unable to load Snippet - lm.emit at java.base/jdk.internal.reflect.GeneratedConstructorAccessor103.newInstance(Unknown Source) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83) at org.codehaus.groovy.reflection.CachedConstructor.doConstructorInvoke(CachedConstructor.java:77) at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrap.callConstructor(ConstructorSite.java:84) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:59) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:238) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:250) at Script1.get(Script1.groovy:70) at Script1.load(Script1.groovy:19) at Script1$load$0.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:157) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185) at Script1.load(Script1.groovy:15) at Script1$load.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) at Script1$load.call(Unknown Source) at Script7.run(Script7.groovy:6)Solved111Views11likes7CommentsAPI Groovy HttpPatch?
Is it possible to do an HttpPatch, or to use the PATCH verb, when updating devices? I looked over on one of the LM pages for updataing devices with the API and as usual, most of the examples were in Python, but PUT did have one Groovy example, but PATCH did not. I’ve seen mention somewhere that at some point PATCH would be supported, wondering if it is or not. I ended up getting my script working with a Get (so I dont lose all my device custom settings etc) and then changing theautoBalancedCollectorGroupId value, and then doing a PUT and it worked, and I didnt lose any of my custom properties. And I have a working filter all set up to run it against a target set of devices. But still, I would rather just patch the fields I want without risk. I’m wondering if thats possible, or if GET/tweak/PUT is still the main go-to?Solved87Views9likes9CommentsFinding VMware's most recent vulnerability
I woke up this morning to an email pointing me to this:https://www.vmware.com/security/advisories/VMSA-2021-0002.html My boss -Can LM tell us which ones need attention? We’d like to notify our customers proactively. Me - Sure! Oh wait, I only have version info for the ESX servers. I’ll have to build out something to grab the vCenter versions. So, I built a custom property source. AppliesTo: system.virtualization =~ "VMware ESX vcenter" && (vcsa.user || esx.user) && (vcsa.pass || esx.pass) Then the script looks like this: /******************************************************************************* * © 2023 Aqueduct Technologies Inc. * * External Resources: * - https://developer.vmware.com/apis/vsphere-automation/v7.0U1/appliance/rest/appliance/system/version/get/ * ******************************************************************************/ import groovy.json.JsonSlurper user = hostProps.get("vcsa.user")?: hostProps.get("esx.user") pass = hostProps.get("vcsa.pass")?: hostProps.get("esx.pass") host = hostProps.get("system.hostname") session_endpoint = "/rest/com/vmware/cis/session" //endpoint for establishing an ssl session vsphere_version_endpoint = "/rest/appliance/system/version" //endpoint for determining vsphere version jSlurp = new JsonSlurper() globalHeaders = [:] genSessionId()//get session ID for future API requests try{ def resp = httpRequest(vsphere_version_endpoint) if (!resp) {return 1} println("auto.vcenter.version=${resp.version}") } finally{deleteSessionId()} return 0 def genSessionId(){ String auth = "Basic " + "$user:$pass".getBytes().encodeBase64().toString() def headers = ["Authorization": (auth)] def resp = httpRequest(session_endpoint, headers, 'POST') globalHeaders.put('Cookie', "vmware-api-session-id=${resp as String}") } def deleteSessionId(){ httpRequest(session_endpoint, [:], 'DELETE') } def httpRequest(def endpoint, Map<String, String> headers = [:], def method = 'GET', String query = null){ URI _uri = new URI('https', null, host, 443, endpoint, query, null) def _session = _uri.toURL().openConnection() _session.setRequestMethod(method) (headers + globalHeaders).each { k, v -> _session.setRequestProperty(k, v) } def response = _session.getInputStream().getText() _session.disconnect() return (response) ? jSlurp.parseText(response).value : null } If you don’t have one under /Devices by Type, create a dynamic group for ESX hosts and another dynamic group for vCenter. We called ours “VMware Hosts” (AppliesTo system.virtualization =~ "VMware ESX host") and “VMware vCenters” (AppliesTo system.virtualization =~ "VMware ESX vcenter") respectively. Then create a Resource Inventory report where the Resource Group is “Devices by Type/VMware*”. Add the system.virtualization, auto.vcenter.version, and system.version properties and run it. Voila, you now know the version numbers of your ESX and vCenter resources and you can compare that to the versions in the VMware Advisory.99Views9likes3CommentsGroovy4, FastStringService, V.206, etc
I noticed in the detailed release notes for V.206 some discussion of Groovy2 vs Groovy4, because apparently at some point in the future Groovy2 may go away and so Groovy4 will be required. There is some info on mitigation, including updating official modules (with its usual issues, IMO) but also updating custom modules. But it looks like the latest collector doesnt force this now, but just supports both Groovy2 and Groovy4. But I want to move on this as soon as I can. So I did some testing on one of my custom groovy configsources and discovered that when I force the script to use Groovy4 (//!/lib-groovy/v4 on the 1st line) I get one of the errors mentioned in the release notes for V.206 ( https://www.logicmonitor.com/release-notes/v-206-release-notes ). Specifically "Unable to load FastStringService". But unlike some of the other known issues, no workaround or example was given. import groovy.json.*; def JsonSlurper jsonSlurper = new JsonSlurper(); def jsonParsed = jsonSlurper.parseText(responseBody) The first 2 lines are fine, so I believe there is nothing to be changed with how I'm importing it. The docs I see for latest groovy still show I'd use groovy.json.jsonSlurper. But the 3rd line in the code throws the "Unable to load FastStringService" error. So I guess I'm just wondering if the community has dealt with this specific issue, or if there is a document that contains a workaround for this case and others. I know LM will be updating their modules, or maybe they already have (I havent looked; their new Modules UI hurts my brain a bit, not looking forward to the old version under settings going away). But updating all our custom code is going to be painful. Somehow I didnt realize this conversion from Groovy2 to Groovy4 was coming, so I'm trying to figure out when that will be a hard line in the sand. But in the meantime, I'm just wondering if anyone has found a way around this issue? Thanks!32Views7likes2CommentsGroovy IDE recommendations for DataSource/ConfigSource development?
As I develop more and more ConfigSource and DataSource items in our portal, I find that I’m pretty hampered at times by the limited window space. Maybe its been silly of me all along to be developing in that window. But I’m wondering if anyone here has a recommendation on a Groovy IDE …. I havent researched yet so I dont know if there are multiple ones, or just one main one people use. But I’m wondering if any of you have suggestions on the best IDE, or if there are some ways to make sure the IDE environment is as similar to the ConfigSource window in terms of which imports are needed or available etc. Any advice on a best IDE or best practices for developing Groovy for LogicMonitor on the regular? Thanks!Solved119Views7likes4Comments