API 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?Solved62Views9likes9CommentsOracle 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.61Views15likes0CommentsWindows Services Monitoring with quite a bit more Automation applied
So today we use LM's Microsoft Windows ServicesDataSource to monitor Windows Services. This DS uses Groovy Script and WMI calls under the hood to fetch the service metrics like state, start mode, status, etc... Everything works fine but one of the prerequisites is to go and manually populate the list of Windows services which then the DS parses out as a WILDVALUE variable in the script. You know, go to the device, click on Down Arrow (Manage Resource Options) --> Add Additional Monitoring --> and CHOOSE from the list of Windows Services. Rinse and Repeat and Save. Then the DS goes to work. Well, what if you have a list of over 100 Windows Services you need to add to let's say 20 Windows devices? That would take forever to populate that list manually... That's a problem number 1. Scratch that. This is not really a problem since one can run a PowerShell script (or Groovy Script) to perform this task using undocumented - but working very well - LM API calls. That problem is solved. Next - This list of over 100 Services needs to be *refreshed* every let's say 24 hours to remove nonexistent services and add new ones based on the Regex filter. That's a problem number 2. And again, one can do it programmatically running API calls but this is where I am trying to figure out how to do it. Run my script as a custom PropertySource? I am not really writing Resource Properties, I am updating instance list (Windows Services) within Additional Monitoring on bunch of Resources. Plus PropertySources are applied when ActiveDiscovery is run which is what, every 24 hours? Or should I write custom DataSource that would accomplish this refresh and specify 1 day collection period? Thanks.Solved134Views4likes2CommentsTesting 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.Solved142Views17likes9CommentsGroovy 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!Solved99Views7likes4CommentsEntering 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.Solved107Views12likes3CommentsSAP_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)Solved104Views11likes7CommentsRunning 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!Solved68Views15likes1CommentFinding 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.89Views9likes3Comments